client_java icon indicating copy to clipboard operation
client_java copied to clipboard

Code Quality Improvement Plan

Open zeitlinger opened this issue 9 months ago • 2 comments

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

  • [x] 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).
  • [x] Eliminate Dropwizard Module Duplication — Created AbstractDropwizardExports base class with generics. Reduced both modules by ~30%.
  • [x] 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.
  • [x] Improve Exception Handling — Replaced broad catch (Exception e) with specific exception types in 6 locations.
  • [x] Add Branch Coverage to JaCoCo — Added BRANCH counter check with 50% minimum threshold.
  • [x] Raise Minimum Coverage Thresholds — Raised 4 modules to consistent 60% line coverage.
  • [x] Narrow Checkstyle Suppressions — Replaced global Javadoc suppression with targeted rules for internal/example/benchmark/test packages.

zeitlinger avatar Feb 16 '26 14:02 zeitlinger

Hi @zeitlinger, I'd like to pick this up! Could you pls assign it to me :)

kkukadia avatar Mar 31 '26 16:03 kkukadia

I’m narrowing this tracker to the configuration documentation cleanup in PR #2644. I’m dropping the broad Histogram refactor, servlet deduplication, and additional SpotBugs/Pitest setup from this plan; I’ll revisit those only for a concrete problem. The OTel configuration documentation is already present. I’ll close this tracker when the documentation PR merges.

zeitlinger avatar Nov 03 '26 13:11 zeitlinger