prometheus / prometheus/client_java

Code Quality Improvement Plan

Open
#1,882 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
2.3k
Forks
833
Avg merge
2d 16h
Merged PRs (30d)
86

Description

This issue tracks code quality improvements for the Prometheus Java Client library. Work through these items incrementally.

Remaining Items

Add SpotBugs (Medium Priority)
  • Add spotbugs-maven-plugin to pom.xml
  • Configure with appropriate rule set
  • Note: Deferred due to Java 25 compatibility issues
Refactor Large Classes (Lower Priority)
  • prometheus-metrics-core/src/main/java/.../Histogram.java (978 lines) - consider extracting native histogram logic
Document Configuration Classes (Lower Priority)
  • PrometheusPropertiesLoader - add JavaDoc
  • ExporterProperties and related classes - add JavaDoc
  • ExporterOpenTelemetryProperties - add JavaDoc (noted in TODO)
Consolidate Servlet Exporter Duplication (Lower Priority)
  • Extract common logic from servlet-jakarta and servlet-javax into exporter-common
Add Mutation Testing (Lower Priority)
  • Add Pitest (pitest-maven) for critical modules
  • Start with prometheus-metrics-core and prometheus-metrics-model

Completed Items

  • Add Missing Test Coverage for Exporter Modules — Added 55 tests across 4 modules: exporter-common (22), servlet-jakarta (14), servlet-javax (14), otel-agent-resources (5).
  • Eliminate Dropwizard Module Duplication — Created AbstractDropwizardExports base class with generics. Reduced both modules by ~30%.
  • Address Technical Debt (TODOs) — Completed all 6 TODO items: JavaDoc for ExporterOpenTelemetryProperties, Histogram reset interval tests, environment variable support in PrometheusPropertiesLoader, OpenTelemetry filter documentation, Summary exemplars documentation, SlidingWindow synchronization documentation.
  • Improve Exception Handling — Replaced broad catch (Exception e) with specific exception types in 6 locations.
  • Add Branch Coverage to JaCoCo — Added BRANCH counter check with 50% minimum threshold.
  • Raise Minimum Coverage Thresholds — Raised 4 modules to consistent 60% line coverage.
  • Narrow Checkstyle Suppressions — Replaced global Javadoc suppression with targeted rules for internal/example/benchmark/test packages.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

This is a multi-item plan rather than a single task. Start by selecting one unchecked item, then inspect the named pom.xml, Histogram.java, configuration classes, or servlet modules and account for the SpotBugs Java 25 compatibility note. Done means the selected checklist item is implemented and its scope is verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.