Skip to content

Commit

Permalink
fix(deps): update dependency io.prometheus:prometheus-metrics-exporte…
Browse files Browse the repository at this point in the history
…r-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]>
  • Loading branch information
renovate[bot] and jack-berg authored Oct 29, 2024
1 parent 1e3cf0b commit 2de12fe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion dependencyManagement/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ val DEPENDENCIES = listOf(
"io.opentelemetry.proto:opentelemetry-proto:1.3.2-alpha",
"io.opentracing:opentracing-api:0.33.0",
"io.opentracing:opentracing-noop:0.33.0",
"io.prometheus:prometheus-metrics-exporter-httpserver:1.3.1",
"io.prometheus:prometheus-metrics-exporter-httpserver:1.3.2",
"junit:junit:4.13.2",
"nl.jqno.equalsverifier:equalsverifier:3.17.1",
"org.awaitility:awaitility:4.2.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import io.prometheus.metrics.model.snapshots.ClassicHistogramBuckets;
import io.prometheus.metrics.model.snapshots.CounterSnapshot;
import io.prometheus.metrics.model.snapshots.CounterSnapshot.CounterDataPointSnapshot;
import io.prometheus.metrics.model.snapshots.DataPointSnapshot;
import io.prometheus.metrics.model.snapshots.Exemplar;
import io.prometheus.metrics.model.snapshots.Exemplars;
import io.prometheus.metrics.model.snapshots.GaugeSnapshot;
Expand Down Expand Up @@ -109,11 +110,11 @@ MetricSnapshots convert(@Nullable Collection<MetricData> metricDataCollection) {
if (metricDataCollection == null || metricDataCollection.isEmpty()) {
return MetricSnapshots.of();
}
Map<String, MetricSnapshot> snapshotsByName = new HashMap<>(metricDataCollection.size());
Map<String, MetricSnapshot<?>> snapshotsByName = new HashMap<>(metricDataCollection.size());
Resource resource = null;
Set<InstrumentationScopeInfo> scopes = new LinkedHashSet<>();
for (MetricData metricData : metricDataCollection) {
MetricSnapshot snapshot = convert(metricData);
MetricSnapshot<?> snapshot = convert(metricData);
if (snapshot == null) {
continue;
}
Expand All @@ -135,7 +136,7 @@ MetricSnapshots convert(@Nullable Collection<MetricData> metricDataCollection) {
}

@Nullable
private MetricSnapshot convert(MetricData metricData) {
private MetricSnapshot<?> convert(MetricData metricData) {

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

private static void putOrMerge(
Map<String, MetricSnapshot> snapshotsByName, MetricSnapshot snapshot) {
Map<String, MetricSnapshot<?>> snapshotsByName, MetricSnapshot<?> snapshot) {
String name = snapshot.getMetadata().getPrometheusName();
if (snapshotsByName.containsKey(name)) {
MetricSnapshot merged = merge(snapshotsByName.get(name), snapshot);
MetricSnapshot<?> merged = merge(snapshotsByName.get(name), snapshot);
if (merged != null) {
snapshotsByName.put(name, merged);
}
Expand All @@ -567,7 +568,9 @@ private static void putOrMerge(
* type. If the type differs, we log a message and drop one of them.
*/
@Nullable
private static MetricSnapshot merge(MetricSnapshot a, MetricSnapshot b) {
@SuppressWarnings("unchecked")
private static <T extends DataPointSnapshot> MetricSnapshot<T> merge(
MetricSnapshot<?> a, MetricSnapshot<?> b) {
MetricMetadata metadata = mergeMetadata(a.getMetadata(), b.getMetadata());
if (metadata == null) {
return null;
Expand All @@ -577,27 +580,27 @@ private static MetricSnapshot merge(MetricSnapshot a, MetricSnapshot b) {
List<GaugeDataPointSnapshot> dataPoints = new ArrayList<>(numberOfDataPoints);
dataPoints.addAll(((GaugeSnapshot) a).getDataPoints());
dataPoints.addAll(((GaugeSnapshot) b).getDataPoints());
return new GaugeSnapshot(metadata, dataPoints);
return (MetricSnapshot<T>) new GaugeSnapshot(metadata, dataPoints);
} else if (a instanceof CounterSnapshot && b instanceof CounterSnapshot) {
List<CounterDataPointSnapshot> dataPoints = new ArrayList<>(numberOfDataPoints);
dataPoints.addAll(((CounterSnapshot) a).getDataPoints());
dataPoints.addAll(((CounterSnapshot) b).getDataPoints());
return new CounterSnapshot(metadata, dataPoints);
return (MetricSnapshot<T>) new CounterSnapshot(metadata, dataPoints);
} else if (a instanceof HistogramSnapshot && b instanceof HistogramSnapshot) {
List<HistogramDataPointSnapshot> dataPoints = new ArrayList<>(numberOfDataPoints);
dataPoints.addAll(((HistogramSnapshot) a).getDataPoints());
dataPoints.addAll(((HistogramSnapshot) b).getDataPoints());
return new HistogramSnapshot(metadata, dataPoints);
return (MetricSnapshot<T>) new HistogramSnapshot(metadata, dataPoints);
} else if (a instanceof SummarySnapshot && b instanceof SummarySnapshot) {
List<SummaryDataPointSnapshot> dataPoints = new ArrayList<>(numberOfDataPoints);
dataPoints.addAll(((SummarySnapshot) a).getDataPoints());
dataPoints.addAll(((SummarySnapshot) b).getDataPoints());
return new SummarySnapshot(metadata, dataPoints);
return (MetricSnapshot<T>) new SummarySnapshot(metadata, dataPoints);
} else if (a instanceof InfoSnapshot && b instanceof InfoSnapshot) {
List<InfoDataPointSnapshot> dataPoints = new ArrayList<>(numberOfDataPoints);
dataPoints.addAll(((InfoSnapshot) a).getDataPoints());
dataPoints.addAll(((InfoSnapshot) b).getDataPoints());
return new InfoSnapshot(metadata, dataPoints);
return (MetricSnapshot<T>) new InfoSnapshot(metadata, dataPoints);
} else {
THROTTLING_LOGGER.log(
Level.WARNING,
Expand Down Expand Up @@ -638,7 +641,7 @@ private static MetricMetadata mergeMetadata(MetricMetadata a, MetricMetadata b)
return new MetricMetadata(name, help, unit);
}

private static String typeString(MetricSnapshot snapshot) {
private static String typeString(MetricSnapshot<?> snapshot) {
// Simple helper for a log message.
return snapshot.getClass().getSimpleName().replace("Snapshot", "").toLowerCase(Locale.ENGLISH);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
import io.opentelemetry.sdk.resources.Resource;
import io.prometheus.metrics.exporter.httpserver.HTTPServer;
import io.prometheus.metrics.exporter.httpserver.MetricsHandler;
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_3_25_3.Metrics;
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_28_2.Metrics;
import io.prometheus.metrics.model.registry.PrometheusRegistry;
import io.prometheus.metrics.shaded.com_google_protobuf_3_25_3.TextFormat;
import io.prometheus.metrics.shaded.com_google_protobuf_4_28_2.TextFormat;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.ServerSocket;
Expand Down

0 comments on commit 2de12fe

Please sign in to comment.