Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Code quality improvements

未关闭
#1,816 0 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
重构
描述清晰度
需要澄清
活跃度
停滞
技术栈
java

调研方向

将其视为一项跟踪计划,而不是单一变更。首先选择一个未勾选的项目,并阅读其中指定的 file、pom.xml 或 checkstyle-suppressions.xml 条目;在进行更改之前,先定义该项目的完成标准。运行相关的模块测试或构建检查,并仅在所选工作得到验证后更新检查清单。

由索引模型根据 Issue 内容生成。

描述

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).
主要语言
Java
星标
2.3k
派生
833
平均合并
3 天 5 小时
30 天内合并 PR
65

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

prometheus/client_java 的其他 Issue

查看 prometheus/client_java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。