Conversation
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
There was a problem hiding this comment.
Pull request overview
Replaces several TODOs with clearer inline documentation/Javadoc and adds a small set of unit tests to cover Histogram.Builder#nativeResetDuration(...) validation/configuration.
Changes:
- Expanded TODO comments into explanatory notes (OpenTelemetry exporter filtering, Summary exemplars, SlidingWindow thread-safety/perf).
- Added tests for
nativeResetDuration(...)positive/zero/negative inputs. - Added class and builder-method Javadocs for
ExporterOpenTelemetryProperties.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| prometheus-metrics-exporter-opentelemetry/src/main/java/io/prometheus/metrics/exporter/opentelemetry/PrometheusMetricProducer.java | Replaces TODO with guidance on how filtering could be added in the future. |
| prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/HistogramTest.java | Adds tests around nativeResetDuration(...). |
| prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics/Summary.java | Documents current behavior/limitations for Summary exemplars. |
| prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics/SlidingWindow.java | Improves class-level documentation about thread safety and performance. |
| prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics/Histogram.java | Removes a TODO related to missing reset-duration tests. |
| prometheus-metrics-config/src/main/java/io/prometheus/metrics/config/ExporterOpenTelemetryProperties.java | Adds comprehensive Javadoc for properties and builder methods. |
Comments suppressed due to low confidence (1)
prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics/Histogram.java:969
- nativeResetDurationSeconds is derived via unit.toSeconds(duration), which truncates sub-second values to 0. That means calls like nativeResetDuration(500, MILLISECONDS) silently disable resets despite passing the duration > 0 validation. Consider either rejecting durations that round to 0 seconds, documenting second-level granularity, or rounding up to at least 1 second.
public Builder nativeResetDuration(long duration, TimeUnit unit) {
if (duration <= 0) {
throw new IllegalArgumentException(duration + ": value > 0 expected");
}
nativeResetDurationSeconds = unit.toSeconds(duration);
return this;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics/Summary.java
Outdated
Show resolved
Hide resolved
...trics-config/src/main/java/io/prometheus/metrics/config/ExporterOpenTelemetryProperties.java
Outdated
Show resolved
Hide resolved
prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/HistogramTest.java
Show resolved
Hide resolved
| * observations. Potential optimizations include: | ||
| * | ||
| * <ul> | ||
| * <li>Using {@link java.util.concurrent.locks.ReadWriteLock} to allow concurrent observations | ||
| * <li>Using lock-free data structures with {@link java.util.concurrent.atomic atomic} operations | ||
| * <li>Implementing a lock-free ring buffer with striped buckets | ||
| * </ul> |
There was a problem hiding this comment.
maybe this one could be converted into an issue if we want to improve it, or we just remove the TODO comment entirely? I'm not sure the addition of this new comment is all that useful
There was a problem hiding this comment.
not mention that it's synchronized - or just leave out the optimizations?
There was a problem hiding this comment.
the "Potential optimizations include:" list. it looks like this geared towards people who might refactor the code, as opposed to someone using it?
| } | ||
|
|
||
| @Test | ||
| public void testNativeResetDuration() { |
There was a problem hiding this comment.
| public void testNativeResetDuration() { | |
| void testNativeResetDuration() { |
| } | ||
|
|
||
| @Test | ||
| public void testNativeResetDurationNegativeValue() { |
There was a problem hiding this comment.
| public void testNativeResetDurationNegativeValue() { | |
| void testNativeResetDurationNegativeValue() { |
| } | ||
|
|
||
| @Test | ||
| public void testNativeResetDurationZeroValue() { |
There was a problem hiding this comment.
| public void testNativeResetDurationZeroValue() { | |
| void testNativeResetDurationZeroValue() { |
| } | ||
|
|
||
| @Test | ||
| public void testNativeResetDurationSubSecond() { |
There was a problem hiding this comment.
| public void testNativeResetDurationSubSecond() { | |
| void testNativeResetDurationSubSecond() { |
No description provided.