prometheus / prometheus/client_java

Code quality improvements

オープン
#1,816 コメント 0 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Java
スター
2.3k
フォーク
833
平均マージ
2日 16時間
マージ済み PR(30日)
86

説明

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
  • prometheus-metrics-exporter-common - base module, no tests
  • prometheus-metrics-exporter-servlet-jakarta - no tests
  • prometheus-metrics-exporter-servlet-javax - no tests
  • prometheus-metrics-exporter-opentelemetry-otel-agent-resources - no tests
2. Eliminate Dropwizard Module Duplication
  • Create shared base class or use generics for prometheus-metrics-instrumentation-dropwizard and prometheus-metrics-instrumentation-dropwizard5 (~297 lines each, nearly identical)
3. Address Technical Debt (TODOs)
  • prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics/Histogram.java:965 - "reset interval isn't tested yet"
  • prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics/Summary.java:205 - "Exemplars (are hard-coded as empty)"
  • prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics/SlidingWindow.java:18 - "synchronized implementation, room for optimization"
  • prometheus-metrics-config/src/main/java/io/prometheus/metrics/config/PrometheusPropertiesLoader.java:105 - "Add environment variables like EXEMPLARS_ENABLED"
  • prometheus-metrics-exporter-opentelemetry/src/main/java/io/prometheus/metrics/exporter/opentelemetry/PrometheusMetricProducer.java:44 - "filter configuration for OpenTelemetry exporter"
  • prometheus-metrics-config/src/main/java/io/prometheus/metrics/config/ExporterOpenTelemetryProperties.java:7 - "JavaDoc missing"
4. Improve Exception Handling

Replace broad catch (Exception e) with specific exception types:

  • prometheus-metrics-instrumentation-dropwizard5/src/main/java/.../DropwizardExports.java:237
  • prometheus-metrics-instrumentation-caffeine/src/main/java/.../CacheMetricsCollector.java:229
  • prometheus-metrics-exporter-opentelemetry/src/main/java/.../PrometheusInstrumentationScope.java:47
  • prometheus-metrics-exporter-opentelemetry/src/main/java/.../OtelAutoConfig.java:115
  • prometheus-metrics-instrumentation-jvm/src/main/java/.../JvmNativeMemoryMetrics.java:166
  • prometheus-metrics-exporter-httpserver/src/main/java/.../HttpExchangeAdapter.java:115

Medium Priority

5. Add Branch Coverage to JaCoCo
  • Update pom.xml to add branch coverage requirement (~50% minimum)
<limit>
  <counter>BRANCH</counter>
  <value>COVEREDRATIO</value>
  <minimum>0.50</minimum>
</limit>
6. Raise Minimum Coverage Thresholds

Current thresholds to review:

  • prometheus-metrics-exporter-httpserver - 45% (raise to 60%)
  • prometheus-metrics-instrumentation-dropwizard5 - 50% (raise to 60%)
  • prometheus-metrics-exposition-textformats - 50% (raise to 60%)
  • prometheus-metrics-instrumentation-jvm - 55% (raise to 60%)
7. Add SpotBugs
  • Add spotbugs-maven-plugin to pom.xml
  • Configure with appropriate rule set
8. Narrow Checkstyle Suppressions
  • Review checkstyle-suppressions.xml - currently suppresses ALL Javadoc checks globally
  • Narrow to specific packages/classes that need exceptions

Lower Priority

9. Refactor Large Classes
  • prometheus-metrics-core/src/main/java/.../Histogram.java (978 lines) - consider extracting native histogram logic
10. Document Configuration Classes
  • PrometheusPropertiesLoader - add JavaDoc
  • ExporterProperties and related classes - add JavaDoc
  • ExporterOpenTelemetryProperties - add JavaDoc (noted in TODO)
11. Consolidate Servlet Exporter Duplication
  • Extract common logic from servlet-jakarta and servlet-javax into exporter-common
12. Add Mutation Testing
  • Add Pitest (pitest-maven) for critical modules
  • Start with prometheus-metrics-core and prometheus-metrics-model

Progress Notes

Add notes here as items are completed:

Date Item Notes
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.
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).

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

これを単一の変更ではなく、追跡計画として扱ってください。まず未チェックの項目を1つ選択し、そこに記載された file、pom.xml、または checkstyle-suppressions.xml のエントリを読みます。変更を加える前に、その項目の完了条件を定義してください。関連するモジュールテストまたはビルドチェックを実行し、選択した作業が検証された場合にのみチェックリストを更新してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
build-system, testing, tooling
issue の種類
リファクタリング
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。