You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: integration-tests/it-exporter/it-exporter-duplicate-metrics-sample/src/main/java/io/prometheus/metrics/it/exporter/duplicatemetrics/DuplicateMetricsSample.java
+2-6Lines changed: 2 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -6,16 +6,12 @@
6
6
importio.prometheus.metrics.model.snapshots.Unit;
7
7
importjava.io.IOException;
8
8
9
-
/**
10
-
* Integration test sample demonstrating metrics with duplicate names but different label sets. This
11
-
* validates that the duplicate metrics feature works end-to-end.
12
-
*/
9
+
/** Integration test sample demonstrating metrics with duplicate names but different label sets. */
Copy file name to clipboardExpand all lines: integration-tests/it-exporter/it-exporter-test/src/test/java/io/prometheus/metrics/it/exporter/test/DuplicateMetricsIT.java
Copy file name to clipboardExpand all lines: integration-tests/it-spring-boot-smoke-test/src/main/java/io/prometheus/metrics/it/springboot/Application.java
Copy file name to clipboardExpand all lines: prometheus-metrics-exposition-formats/src/test/java/io/prometheus/metrics/expositionformats/DuplicateNamesProtobufTest.java
+7-5Lines changed: 7 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -271,7 +271,7 @@ public MetricSnapshot collect() {
271
271
.help("Active sessions gauge")
272
272
.dataPoint(
273
273
GaugeSnapshot.GaugeDataPointSnapshot.builder()
274
-
.labels(Labels.of("method", "POST"))
274
+
.labels(Labels.of("region", "us-east-1"))
275
275
.value(50)
276
276
.build())
277
277
.build();
@@ -286,12 +286,14 @@ public String getPrometheusName() {
Copy file name to clipboardExpand all lines: prometheus-metrics-exposition-textformats/src/main/java/io/prometheus/metrics/expositionformats/TextFormatUtil.java
+44-34Lines changed: 44 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,41 @@
23
23
importjava.util.Map;
24
24
importjavax.annotation.Nullable;
25
25
26
+
/**
27
+
* Utility methods for writing Prometheus text exposition formats.
28
+
*
29
+
* <p>This class provides low-level formatting utilities used by both Prometheus text format and
30
+
* OpenMetrics format writers. It handles escaping, label formatting, timestamp conversion, and
31
+
* merging of duplicate metric names.
32
+
*/
26
33
publicclassTextFormatUtil {
34
+
/**
35
+
* Merges snapshots with duplicate Prometheus names by combining their data points. This ensures
36
+
* only one HELP/TYPE declaration per metric family.
Copy file name to clipboardExpand all lines: prometheus-metrics-exposition-textformats/src/test/java/io/prometheus/metrics/expositionformats/TextFormatUtilTest.java
0 commit comments