Title: Code quality improvements · Issue #1816 · prometheus/client_java · GitHub
Open Graph Title: Code quality improvements · Issue #1816 · prometheus/client_java
X Title: Code quality improvements · Issue #1816 · prometheus/client_java
Description: Code Quality Improvement Plan This document tracks code quality improvements for the Prometheus Java Client library. Work through these items incrementally across sessions. High Priority 1. Add Missing Test Coverage for Exporter Modules ...
Open Graph Description: Code Quality Improvement Plan This document tracks code quality improvements for the Prometheus Java Client library. Work through these items incrementally across sessions. High Priority 1. Add Mis...
X Description: Code Quality Improvement Plan This document tracks code quality improvements for the Prometheus Java Client library. Work through these items incrementally across sessions. High Priority 1. Add Mis...
Opengraph URL: https://github.com/prometheus/client_java/issues/1816
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Code quality improvements","articleBody":"# Code Quality Improvement Plan\n\nThis document tracks code quality improvements for the Prometheus Java Client library. Work through these items incrementally across sessions.\n\n## High Priority\n\n### 1. Add Missing Test Coverage for Exporter Modules\n- [x] `prometheus-metrics-exporter-common` - base module, no tests\n- [x] `prometheus-metrics-exporter-servlet-jakarta` - no tests\n- [x] `prometheus-metrics-exporter-servlet-javax` - no tests\n- [x] `prometheus-metrics-exporter-opentelemetry-otel-agent-resources` - no tests\n\n### 2. Eliminate Dropwizard Module Duplication\n- [x] Create shared base class or use generics for `prometheus-metrics-instrumentation-dropwizard` and `prometheus-metrics-instrumentation-dropwizard5` (~297 lines each, nearly identical)\n\n### 3. Address Technical Debt (TODOs)\n- [ ] `prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics/Histogram.java:965` - \"reset interval isn't tested yet\"\n- [ ] `prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics/Summary.java:205` - \"Exemplars (are hard-coded as empty)\"\n- [ ] `prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics/SlidingWindow.java:18` - \"synchronized implementation, room for optimization\"\n- [ ] `prometheus-metrics-config/src/main/java/io/prometheus/metrics/config/PrometheusPropertiesLoader.java:105` - \"Add environment variables like EXEMPLARS_ENABLED\"\n- [ ] `prometheus-metrics-exporter-opentelemetry/src/main/java/io/prometheus/metrics/exporter/opentelemetry/PrometheusMetricProducer.java:44` - \"filter configuration for OpenTelemetry exporter\"\n- [ ] `prometheus-metrics-config/src/main/java/io/prometheus/metrics/config/ExporterOpenTelemetryProperties.java:7` - \"JavaDoc missing\"\n\n### 4. Improve Exception Handling\nReplace broad `catch (Exception e)` with specific exception types:\n- [ ] `prometheus-metrics-instrumentation-dropwizard5/src/main/java/.../DropwizardExports.java:237`\n- [ ] `prometheus-metrics-instrumentation-caffeine/src/main/java/.../CacheMetricsCollector.java:229`\n- [ ] `prometheus-metrics-exporter-opentelemetry/src/main/java/.../PrometheusInstrumentationScope.java:47`\n- [ ] `prometheus-metrics-exporter-opentelemetry/src/main/java/.../OtelAutoConfig.java:115`\n- [ ] `prometheus-metrics-instrumentation-jvm/src/main/java/.../JvmNativeMemoryMetrics.java:166`\n- [ ] `prometheus-metrics-exporter-httpserver/src/main/java/.../HttpExchangeAdapter.java:115`\n\n## Medium Priority\n\n### 5. Add Branch Coverage to JaCoCo\n- [ ] Update `pom.xml` to add branch coverage requirement (~50% minimum)\n```xml\n\u003climit>\n \u003ccounter>BRANCH\u003c/counter>\n \u003cvalue>COVEREDRATIO\u003c/value>\n \u003cminimum>0.50\u003c/minimum>\n\u003c/limit>\n```\n\n### 6. Raise Minimum Coverage Thresholds\nCurrent thresholds to review:\n- [ ] `prometheus-metrics-exporter-httpserver` - 45% (raise to 60%)\n- [ ] `prometheus-metrics-instrumentation-dropwizard5` - 50% (raise to 60%)\n- [ ] `prometheus-metrics-exposition-textformats` - 50% (raise to 60%)\n- [ ] `prometheus-metrics-instrumentation-jvm` - 55% (raise to 60%)\n\n### 7. Add SpotBugs\n- [ ] Add `spotbugs-maven-plugin` to `pom.xml`\n- [ ] Configure with appropriate rule set\n\n### 8. Narrow Checkstyle Suppressions\n- [ ] Review `checkstyle-suppressions.xml` - currently suppresses ALL Javadoc checks globally\n- [ ] Narrow to specific packages/classes that need exceptions\n\n## Lower Priority\n\n### 9. Refactor Large Classes\n- [ ] `prometheus-metrics-core/src/main/java/.../Histogram.java` (978 lines) - consider extracting native histogram logic\n\n### 10. Document Configuration Classes\n- [ ] `PrometheusPropertiesLoader` - add JavaDoc\n- [ ] `ExporterProperties` and related classes - add JavaDoc\n- [ ] `ExporterOpenTelemetryProperties` - add JavaDoc (noted in TODO)\n\n### 11. Consolidate Servlet Exporter Duplication\n- [ ] Extract common logic from `servlet-jakarta` and `servlet-javax` into `exporter-common`\n\n### 12. Add Mutation Testing\n- [ ] Add Pitest (`pitest-maven`) for critical modules\n- [ ] Start with `prometheus-metrics-core` and `prometheus-metrics-model`\n\n---\n\n## Progress Notes\n\n_Add notes here as items are completed:_\n\n| Date | Item | Notes |\n|------|------|-------|\n| 2026-01-24 | Missing Test Coverage for Exporter Modules | Added 55 tests across 4 modules: exporter-common (22 tests), servlet-jakarta (14 tests), servlet-javax (14 tests), otel-agent-resources (5 tests). All tests passing. |\n| 2026-01-24 | Eliminate Dropwizard Module Duplication | Created AbstractDropwizardExports base class (267 lines) with generic type parameters. Reduced dropwizard module from 297 to 209 lines (-88 lines, -30%), dropwizard5 module from 297 to 212 lines (-85 lines, -29%). All tests passing (32 tests dropwizard5, 13 tests dropwizard). |\n","author":{"url":"https://github.com/zeitlinger","@type":"Person","name":"zeitlinger"},"datePublished":"2026-01-26T11:58:10Z","url":"https://github.com/prometheus/client_java/issues/1816"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d44b53bf-dbe4-4275-bdd5-05922e63e59c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D796:B6082:292DBD:36A427:6AFBB70B |
| html-safe-nonce | a2d14b672eea5dc82cf0f48db4873d6730494f9cc0f7ad6d5df01727dc31762d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzk2OkI2MDgyOjI5MkRCRDozNkE0Mjc6NkFGQkI3MEIiLCJ2aXNpdG9yX2lkIjoiNDMyMjQ4OTQzOTYzNzcxNDY5OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5f203078a43207f6eb0d1ea5729c1cc8af908efb487c9e63796fb6e84e53b6ed |
| hovercard-subject-tag | issue:3855664022 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/prometheus/client_java/1816/issue_layout |
| twitter:image | https://opengraph.githubassets.com/92af31db7f8e59fcc9b258e630aad47805470471dc7d0d45f6e9b99a9dc11937/prometheus/client_java/issues/1816 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/92af31db7f8e59fcc9b258e630aad47805470471dc7d0d45f6e9b99a9dc11937/prometheus/client_java/issues/1816 |
| og:image:alt | Code Quality Improvement Plan This document tracks code quality improvements for the Prometheus Java Client library. Work through these items incrementally across sessions. High Priority 1. Add Mis... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zeitlinger |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2b2ef9c1578c18d8ed27027940544c958743213cf4461659f14d3ccdf51e162c |
| turbo-cache-control | no-preview |
| go-import | github.com/prometheus/client_java git https://github.com/prometheus/client_java.git |
| octolytics-dimension-user_id | 3380462 |
| octolytics-dimension-user_login | prometheus |
| octolytics-dimension-repository_id | 7997879 |
| octolytics-dimension-repository_nwo | prometheus/client_java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7997879 |
| octolytics-dimension-repository_network_root_nwo | prometheus/client_java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e4cce0e99cf61481a318ff12c2e8580153a6c7c6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width