-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Time-windowed max gauge for OTLP histograms #6159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -126,6 +126,8 @@ private void writeHistogramSupport(HistogramSupport histogramSupport) { | |
| double max = isTimeBased ? histogramSnapshot.max(baseTimeUnit) : histogramSnapshot.max(); | ||
| long count = histogramSnapshot.count(); | ||
|
|
||
| addMaxGaugeForTimer(id, tags, max); | ||
|
|
||
| // if percentiles configured, use summary | ||
| if (histogramSnapshot.percentileValues().length != 0) { | ||
| buildSummaryDataPoint(histogramSupport, tags, startTimeNanos, total, count, isTimeBased, histogramSnapshot); | ||
|
|
@@ -154,6 +156,20 @@ private static Optional<ExponentialHistogramSnapShot> getExponentialHistogramSna | |
| return Optional.empty(); | ||
| } | ||
|
|
||
| private void addMaxGaugeForTimer(Meter.Id id, Iterable<KeyValue> tags, double max) { | ||
| String metricName = id.getName() + ".max"; | ||
| Metric.Builder metricBuilder = getOrCreateMetricBuilder(id.withName(metricName), DataCase.GAUGE); | ||
| if (!metricBuilder.hasGauge()) { | ||
| metricBuilder.setGauge(io.opentelemetry.proto.metrics.v1.Gauge.newBuilder()); | ||
| } | ||
|
|
||
| metricBuilder.getGaugeBuilder() | ||
| .addDataPoints(NumberDataPoint.newBuilder() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems |
||
| .setTimeUnixNano(TimeUnit.MILLISECONDS.toNanos(clock.wallTime())) | ||
| .setAsDouble(max) | ||
| .addAllAttributes(tags)); | ||
| } | ||
|
|
||
| private void writeFunctionTimer(FunctionTimer functionTimer) { | ||
| Metric.Builder builder = getOrCreateMetricBuilder(functionTimer.getId(), DataCase.HISTOGRAM); | ||
| HistogramDataPoint.Builder histogramDataPoint = HistogramDataPoint.newBuilder() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,11 +107,13 @@ void collectorShouldExportMetrics() throws Exception { | |
| // see: https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/20519 | ||
| matchesPattern("(?s)^.*test_timer_milliseconds_sum\\{.+} 123\\.0\\n.*$"), | ||
| matchesPattern("(?s)^.*test_timer_milliseconds_bucket\\{.+,le=\"\\+Inf\"} 1\\n.*$"), | ||
| matchesPattern("(?s)^.*test_timer_max_milliseconds\\{.+} 123\\.0\n.*$"), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is a separate gauge, there should be two more lines, something like this should cover them: containsString("# HELP test_timer_max_milliseconds \n"),
containsString("# TYPE test_timer_max_milliseconds gauge\n"), |
||
|
|
||
| containsString("# HELP test_ds \n"), | ||
| containsString("# TYPE test_ds histogram\n"), | ||
| matchesPattern("(?s)^.*test_ds_count\\{.+} 1\\n.*$"), | ||
| matchesPattern("(?s)^.*test_ds_sum\\{.+} 24\\.0\\n.*$"), | ||
| matchesPattern("(?s)^.*test_ds_max\\{.+} 24\\.0\\n.*$"), | ||
| matchesPattern("(?s)^.*test_ds_bucket\\{.+,le=\"\\+Inf\"} 1\\n.*$") | ||
| ); | ||
| // @formatter:on | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addMaxGaugeForHistogramSupport?Since this is for both
TimerandDistributionSummary.