Skip to content

Commit 2de12fe

Browse files
fix(deps): update dependency io.prometheus:prometheus-metrics-exporter-httpserver to v1.3.2 (#6805)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jack Berg <[email protected]>
1 parent 1e3cf0b commit 2de12fe

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

dependencyManagement/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ val DEPENDENCIES = listOf(
7171
"io.opentelemetry.proto:opentelemetry-proto:1.3.2-alpha",
7272
"io.opentracing:opentracing-api:0.33.0",
7373
"io.opentracing:opentracing-noop:0.33.0",
74-
"io.prometheus:prometheus-metrics-exporter-httpserver:1.3.1",
74+
"io.prometheus:prometheus-metrics-exporter-httpserver:1.3.2",
7575
"junit:junit:4.13.2",
7676
"nl.jqno.equalsverifier:equalsverifier:3.17.1",
7777
"org.awaitility:awaitility:4.2.2",

exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/Otel2PrometheusConverter.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import io.prometheus.metrics.model.snapshots.ClassicHistogramBuckets;
3434
import io.prometheus.metrics.model.snapshots.CounterSnapshot;
3535
import io.prometheus.metrics.model.snapshots.CounterSnapshot.CounterDataPointSnapshot;
36+
import io.prometheus.metrics.model.snapshots.DataPointSnapshot;
3637
import io.prometheus.metrics.model.snapshots.Exemplar;
3738
import io.prometheus.metrics.model.snapshots.Exemplars;
3839
import io.prometheus.metrics.model.snapshots.GaugeSnapshot;
@@ -109,11 +110,11 @@ MetricSnapshots convert(@Nullable Collection<MetricData> metricDataCollection) {
109110
if (metricDataCollection == null || metricDataCollection.isEmpty()) {
110111
return MetricSnapshots.of();
111112
}
112-
Map<String, MetricSnapshot> snapshotsByName = new HashMap<>(metricDataCollection.size());
113+
Map<String, MetricSnapshot<?>> snapshotsByName = new HashMap<>(metricDataCollection.size());
113114
Resource resource = null;
114115
Set<InstrumentationScopeInfo> scopes = new LinkedHashSet<>();
115116
for (MetricData metricData : metricDataCollection) {
116-
MetricSnapshot snapshot = convert(metricData);
117+
MetricSnapshot<?> snapshot = convert(metricData);
117118
if (snapshot == null) {
118119
continue;
119120
}
@@ -135,7 +136,7 @@ MetricSnapshots convert(@Nullable Collection<MetricData> metricDataCollection) {
135136
}
136137

137138
@Nullable
138-
private MetricSnapshot convert(MetricData metricData) {
139+
private MetricSnapshot<?> convert(MetricData metricData) {
139140

140141
// Note that AggregationTemporality.DELTA should never happen
141142
// because PrometheusMetricReader#getAggregationTemporality returns CUMULATIVE.
@@ -548,10 +549,10 @@ private static MetricMetadata convertMetadata(MetricData metricData) {
548549
}
549550

550551
private static void putOrMerge(
551-
Map<String, MetricSnapshot> snapshotsByName, MetricSnapshot snapshot) {
552+
Map<String, MetricSnapshot<?>> snapshotsByName, MetricSnapshot<?> snapshot) {
552553
String name = snapshot.getMetadata().getPrometheusName();
553554
if (snapshotsByName.containsKey(name)) {
554-
MetricSnapshot merged = merge(snapshotsByName.get(name), snapshot);
555+
MetricSnapshot<?> merged = merge(snapshotsByName.get(name), snapshot);
555556
if (merged != null) {
556557
snapshotsByName.put(name, merged);
557558
}
@@ -567,7 +568,9 @@ private static void putOrMerge(
567568
* type. If the type differs, we log a message and drop one of them.
568569
*/
569570
@Nullable
570-
private static MetricSnapshot merge(MetricSnapshot a, MetricSnapshot b) {
571+
@SuppressWarnings("unchecked")
572+
private static <T extends DataPointSnapshot> MetricSnapshot<T> merge(
573+
MetricSnapshot<?> a, MetricSnapshot<?> b) {
571574
MetricMetadata metadata = mergeMetadata(a.getMetadata(), b.getMetadata());
572575
if (metadata == null) {
573576
return null;
@@ -577,27 +580,27 @@ private static MetricSnapshot merge(MetricSnapshot a, MetricSnapshot b) {
577580
List<GaugeDataPointSnapshot> dataPoints = new ArrayList<>(numberOfDataPoints);
578581
dataPoints.addAll(((GaugeSnapshot) a).getDataPoints());
579582
dataPoints.addAll(((GaugeSnapshot) b).getDataPoints());
580-
return new GaugeSnapshot(metadata, dataPoints);
583+
return (MetricSnapshot<T>) new GaugeSnapshot(metadata, dataPoints);
581584
} else if (a instanceof CounterSnapshot && b instanceof CounterSnapshot) {
582585
List<CounterDataPointSnapshot> dataPoints = new ArrayList<>(numberOfDataPoints);
583586
dataPoints.addAll(((CounterSnapshot) a).getDataPoints());
584587
dataPoints.addAll(((CounterSnapshot) b).getDataPoints());
585-
return new CounterSnapshot(metadata, dataPoints);
588+
return (MetricSnapshot<T>) new CounterSnapshot(metadata, dataPoints);
586589
} else if (a instanceof HistogramSnapshot && b instanceof HistogramSnapshot) {
587590
List<HistogramDataPointSnapshot> dataPoints = new ArrayList<>(numberOfDataPoints);
588591
dataPoints.addAll(((HistogramSnapshot) a).getDataPoints());
589592
dataPoints.addAll(((HistogramSnapshot) b).getDataPoints());
590-
return new HistogramSnapshot(metadata, dataPoints);
593+
return (MetricSnapshot<T>) new HistogramSnapshot(metadata, dataPoints);
591594
} else if (a instanceof SummarySnapshot && b instanceof SummarySnapshot) {
592595
List<SummaryDataPointSnapshot> dataPoints = new ArrayList<>(numberOfDataPoints);
593596
dataPoints.addAll(((SummarySnapshot) a).getDataPoints());
594597
dataPoints.addAll(((SummarySnapshot) b).getDataPoints());
595-
return new SummarySnapshot(metadata, dataPoints);
598+
return (MetricSnapshot<T>) new SummarySnapshot(metadata, dataPoints);
596599
} else if (a instanceof InfoSnapshot && b instanceof InfoSnapshot) {
597600
List<InfoDataPointSnapshot> dataPoints = new ArrayList<>(numberOfDataPoints);
598601
dataPoints.addAll(((InfoSnapshot) a).getDataPoints());
599602
dataPoints.addAll(((InfoSnapshot) b).getDataPoints());
600-
return new InfoSnapshot(metadata, dataPoints);
603+
return (MetricSnapshot<T>) new InfoSnapshot(metadata, dataPoints);
601604
} else {
602605
THROTTLING_LOGGER.log(
603606
Level.WARNING,
@@ -638,7 +641,7 @@ private static MetricMetadata mergeMetadata(MetricMetadata a, MetricMetadata b)
638641
return new MetricMetadata(name, help, unit);
639642
}
640643

641-
private static String typeString(MetricSnapshot snapshot) {
644+
private static String typeString(MetricSnapshot<?> snapshot) {
642645
// Simple helper for a log message.
643646
return snapshot.getClass().getSimpleName().replace("Snapshot", "").toLowerCase(Locale.ENGLISH);
644647
}

exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
import io.opentelemetry.sdk.resources.Resource;
4343
import io.prometheus.metrics.exporter.httpserver.HTTPServer;
4444
import io.prometheus.metrics.exporter.httpserver.MetricsHandler;
45-
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_3_25_3.Metrics;
45+
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_28_2.Metrics;
4646
import io.prometheus.metrics.model.registry.PrometheusRegistry;
47-
import io.prometheus.metrics.shaded.com_google_protobuf_3_25_3.TextFormat;
47+
import io.prometheus.metrics.shaded.com_google_protobuf_4_28_2.TextFormat;
4848
import java.io.ByteArrayInputStream;
4949
import java.io.IOException;
5050
import java.net.ServerSocket;

0 commit comments

Comments
 (0)