Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit da91960

Browse files
authored
revert incompatible api change (#1192)
Signed-off-by: Gregor Zeitlinger <[email protected]>
1 parent 7bc442f commit da91960

File tree

28 files changed

+92
-91
lines changed

28 files changed

+92
-91
lines changed

examples/example-exporter-multi-target/src/main/java/io/prometheus/metrics/examples/multitarget/SampleMultiCollector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected MetricSnapshots collectMetricSnapshots(PrometheusScrapeRequest scrapeR
7171
gaugeBuilder.dataPoint(gaugeDataPointBuilder.build());
7272
}
7373
}
74-
Collection<MetricSnapshot<?>> snaps = new ArrayList<>();
74+
Collection<MetricSnapshot> snaps = new ArrayList<>();
7575
snaps.add(counterBuilder.build());
7676
snaps.add(gaugeBuilder.build());
7777
return new MetricSnapshots(snaps);

prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics/Metric.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ protected Metric(Builder<?, ?> builder) {
1919
}
2020

2121
@Override
22-
public abstract MetricSnapshot<?> collect();
22+
public abstract MetricSnapshot collect();
2323

2424
protected abstract static class Builder<B extends Builder<B, M>, M extends Metric> {
2525

prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics/StatefulMetric.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ protected StatefulMetric(Builder<?, ?> builder) {
4545
/**
4646
* labels and metricData have the same size. labels.get(i) are the labels for metricData.get(i).
4747
*/
48-
protected abstract MetricSnapshot<?> collect(List<Labels> labels, List<T> metricData);
48+
protected abstract MetricSnapshot collect(List<Labels> labels, List<T> metricData);
4949

5050
@Override
51-
public MetricSnapshot<?> collect() {
51+
public MetricSnapshot collect() {
5252
if (labelNames.length == 0 && data.isEmpty()) {
5353
// This is a metric without labels that has not been used yet. Initialize the data on the fly.
5454
labelValues();

prometheus-metrics-exporter-opentelemetry/src/main/java/io/prometheus/metrics/exporter/opentelemetry/PrometheusMetricProducer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public Collection<MetricData> collectAllMetrics() {
5151
resourceWithTargetInfo,
5252
scopeFromInfo != null ? scopeFromInfo : instrumentationScopeInfo,
5353
System.currentTimeMillis());
54-
for (MetricSnapshot<?> snapshot : snapshots) {
54+
for (MetricSnapshot snapshot : snapshots) {
5555
if (snapshot instanceof CounterSnapshot) {
5656
addUnlessNull(result, factory.create((CounterSnapshot) snapshot));
5757
} else if (snapshot instanceof GaugeSnapshot) {
@@ -78,7 +78,7 @@ public Collection<MetricData> collectAllMetrics() {
7878

7979
private Resource resourceFromTargetInfo(MetricSnapshots snapshots) {
8080
ResourceBuilder result = Resource.builder();
81-
for (MetricSnapshot<?> snapshot : snapshots) {
81+
for (MetricSnapshot snapshot : snapshots) {
8282
if (snapshot.getMetadata().getName().equals("target") && snapshot instanceof InfoSnapshot) {
8383
InfoSnapshot targetInfo = (InfoSnapshot) snapshot;
8484
if (!targetInfo.getDataPoints().isEmpty()) {
@@ -95,7 +95,7 @@ private Resource resourceFromTargetInfo(MetricSnapshots snapshots) {
9595

9696
private InstrumentationScopeInfo instrumentationScopeFromOTelScopeInfo(
9797
MetricSnapshots snapshots) {
98-
for (MetricSnapshot<?> snapshot : snapshots) {
98+
for (MetricSnapshot snapshot : snapshots) {
9999
if (snapshot.getMetadata().getPrometheusName().equals("otel_scope")
100100
&& snapshot instanceof InfoSnapshot) {
101101
InfoSnapshot scopeInfo = (InfoSnapshot) snapshot;

prometheus-metrics-exposition-formats/src/main/java/io/prometheus/metrics/expositionformats/OpenMetricsTextFormatWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public String getContentType() {
6666
@Override
6767
public void write(OutputStream out, MetricSnapshots metricSnapshots) throws IOException {
6868
OutputStreamWriter writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
69-
for (MetricSnapshot<?> snapshot : metricSnapshots) {
69+
for (MetricSnapshot snapshot : metricSnapshots) {
7070
if (!snapshot.getDataPoints().isEmpty()) {
7171
if (snapshot instanceof CounterSnapshot) {
7272
writeCounter(writer, (CounterSnapshot) snapshot);

prometheus-metrics-exposition-formats/src/main/java/io/prometheus/metrics/expositionformats/PrometheusProtobufWriter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public String getContentType() {
5252

5353
public String toDebugString(MetricSnapshots metricSnapshots) {
5454
StringBuilder stringBuilder = new StringBuilder();
55-
for (MetricSnapshot<?> snapshot : metricSnapshots) {
55+
for (MetricSnapshot snapshot : metricSnapshots) {
5656
if (snapshot.getDataPoints().size() > 0) {
5757
stringBuilder.append(TextFormat.printer().printToString(convert(snapshot)));
5858
}
@@ -62,14 +62,14 @@ public String toDebugString(MetricSnapshots metricSnapshots) {
6262

6363
@Override
6464
public void write(OutputStream out, MetricSnapshots metricSnapshots) throws IOException {
65-
for (MetricSnapshot<?> snapshot : metricSnapshots) {
65+
for (MetricSnapshot snapshot : metricSnapshots) {
6666
if (snapshot.getDataPoints().size() > 0) {
6767
convert(snapshot).writeDelimitedTo(out);
6868
}
6969
}
7070
}
7171

72-
public Metrics.MetricFamily convert(MetricSnapshot<?> snapshot) {
72+
public Metrics.MetricFamily convert(MetricSnapshot snapshot) {
7373
Metrics.MetricFamily.Builder builder = Metrics.MetricFamily.newBuilder();
7474
if (snapshot instanceof CounterSnapshot) {
7575
for (CounterDataPointSnapshot data : ((CounterSnapshot) snapshot).getDataPoints()) {

prometheus-metrics-exposition-formats/src/main/java/io/prometheus/metrics/expositionformats/PrometheusTextFormatWriter.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void write(OutputStream out, MetricSnapshots metricSnapshots) throws IOEx
6060
// "unknown", "gauge", "counter", "stateset", "info", "histogram", "gaugehistogram", and
6161
// "summary".
6262
OutputStreamWriter writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
63-
for (MetricSnapshot<?> snapshot : metricSnapshots) {
63+
for (MetricSnapshot snapshot : metricSnapshots) {
6464
if (snapshot.getDataPoints().size() > 0) {
6565
if (snapshot instanceof CounterSnapshot) {
6666
writeCounter(writer, (CounterSnapshot) snapshot);
@@ -80,7 +80,7 @@ public void write(OutputStream out, MetricSnapshots metricSnapshots) throws IOEx
8080
}
8181
}
8282
if (writeCreatedTimestamps) {
83-
for (MetricSnapshot<?> snapshot : metricSnapshots) {
83+
for (MetricSnapshot snapshot : metricSnapshots) {
8484
if (snapshot.getDataPoints().size() > 0) {
8585
if (snapshot instanceof CounterSnapshot) {
8686
writeCreated(writer, snapshot);
@@ -95,8 +95,7 @@ public void write(OutputStream out, MetricSnapshots metricSnapshots) throws IOEx
9595
writer.flush();
9696
}
9797

98-
public void writeCreated(OutputStreamWriter writer, MetricSnapshot<?> snapshot)
99-
throws IOException {
98+
public void writeCreated(OutputStreamWriter writer, MetricSnapshot snapshot) throws IOException {
10099
boolean metadataWritten = false;
101100
MetricMetadata metadata = snapshot.getMetadata();
102101
for (DataPointSnapshot data : snapshot.getDataPoints()) {

prometheus-metrics-exposition-formats/src/test/java/io/prometheus/metrics/expositionformats/ExpositionFormatsTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2619,47 +2619,45 @@ public void testLabelValueEscape() throws IOException {
26192619
assertPrometheusText(prometheus, counter);
26202620
}
26212621

2622-
private void assertOpenMetricsText(String expected, MetricSnapshot<?> snapshot)
2623-
throws IOException {
2622+
private void assertOpenMetricsText(String expected, MetricSnapshot snapshot) throws IOException {
26242623
ByteArrayOutputStream out = new ByteArrayOutputStream();
26252624
OpenMetricsTextFormatWriter writer = new OpenMetricsTextFormatWriter(true, false);
26262625
writer.write(out, MetricSnapshots.of(snapshot));
26272626
assertThat(out).hasToString(expected);
26282627
}
26292628

26302629
private void assertOpenMetricsTextWithExemplarsOnAllTimeSeries(
2631-
String expected, MetricSnapshot<?> snapshot) throws IOException {
2630+
String expected, MetricSnapshot snapshot) throws IOException {
26322631
ByteArrayOutputStream out = new ByteArrayOutputStream();
26332632
OpenMetricsTextFormatWriter writer = new OpenMetricsTextFormatWriter(true, true);
26342633
writer.write(out, MetricSnapshots.of(snapshot));
26352634
assertThat(out).hasToString(expected);
26362635
}
26372636

2638-
private void assertOpenMetricsTextWithoutCreated(String expected, MetricSnapshot<?> snapshot)
2637+
private void assertOpenMetricsTextWithoutCreated(String expected, MetricSnapshot snapshot)
26392638
throws IOException {
26402639
ByteArrayOutputStream out = new ByteArrayOutputStream();
26412640
OpenMetricsTextFormatWriter writer = new OpenMetricsTextFormatWriter(false, false);
26422641
writer.write(out, MetricSnapshots.of(snapshot));
26432642
assertThat(out).hasToString(expected);
26442643
}
26452644

2646-
private void assertPrometheusText(String expected, MetricSnapshot<?> snapshot)
2647-
throws IOException {
2645+
private void assertPrometheusText(String expected, MetricSnapshot snapshot) throws IOException {
26482646
ByteArrayOutputStream out = new ByteArrayOutputStream();
26492647
PrometheusTextFormatWriter writer = new PrometheusTextFormatWriter(true);
26502648
writer.write(out, MetricSnapshots.of(snapshot));
26512649
assertThat(out).hasToString(expected);
26522650
}
26532651

2654-
private void assertPrometheusTextWithoutCreated(String expected, MetricSnapshot<?> snapshot)
2652+
private void assertPrometheusTextWithoutCreated(String expected, MetricSnapshot snapshot)
26552653
throws IOException {
26562654
ByteArrayOutputStream out = new ByteArrayOutputStream();
26572655
PrometheusTextFormatWriter writer = new PrometheusTextFormatWriter(false);
26582656
writer.write(out, MetricSnapshots.of(snapshot));
26592657
assertThat(out).hasToString(expected);
26602658
}
26612659

2662-
private void assertPrometheusProtobuf(String expected, MetricSnapshot<?> snapshot) {
2660+
private void assertPrometheusProtobuf(String expected, MetricSnapshot snapshot) {
26632661
PrometheusProtobufWriter writer = new PrometheusProtobufWriter();
26642662
Metrics.MetricFamily protobufData = writer.convert(snapshot);
26652663
String actual = TextFormatUtil.shortDebugString(protobufData);

prometheus-metrics-instrumentation-dropwizard5/src/main/java/io/prometheus/metrics/instrumentation/dropwizard5/DropwizardExports.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private MetricMetadata getMetricMetaData(String metricName, Metric metric) {
7070
* Export counter as Prometheus <a
7171
* href="https://prometheus.io/docs/concepts/metric_types/#gauge">Gauge</a>.
7272
*/
73-
MetricSnapshot<?> fromCounter(String dropwizardName, Counter counter) {
73+
MetricSnapshot fromCounter(String dropwizardName, Counter counter) {
7474
MetricMetadata metadata = getMetricMetaData(dropwizardName, counter);
7575
CounterSnapshot.CounterDataPointSnapshot.Builder dataPointBuilder =
7676
CounterSnapshot.CounterDataPointSnapshot.builder()
@@ -84,7 +84,7 @@ MetricSnapshot<?> fromCounter(String dropwizardName, Counter counter) {
8484
}
8585

8686
/** Export gauge as a prometheus gauge. */
87-
MetricSnapshot<?> fromGauge(String dropwizardName, Gauge<?> gauge) {
87+
MetricSnapshot fromGauge(String dropwizardName, Gauge<?> gauge) {
8888
Object obj = gauge.getValue();
8989
double value;
9090
if (obj instanceof Number) {
@@ -119,7 +119,7 @@ MetricSnapshot<?> fromGauge(String dropwizardName, Gauge<?> gauge) {
119119
* @param count the total sample count for this snapshot.
120120
* @param factor a factor to apply to histogram values.
121121
*/
122-
MetricSnapshot<?> fromSnapshotAndCount(
122+
MetricSnapshot fromSnapshotAndCount(
123123
String dropwizardName, Snapshot snapshot, long count, double factor, String helpMessage) {
124124
Quantiles quantiles =
125125
Quantiles.builder()
@@ -144,7 +144,7 @@ MetricSnapshot<?> fromSnapshotAndCount(
144144
}
145145

146146
/** Convert histogram snapshot. */
147-
MetricSnapshot<?> fromHistogram(String dropwizardName, Histogram histogram) {
147+
MetricSnapshot fromHistogram(String dropwizardName, Histogram histogram) {
148148
return fromSnapshotAndCount(
149149
dropwizardName,
150150
histogram.getSnapshot(),
@@ -154,7 +154,7 @@ MetricSnapshot<?> fromHistogram(String dropwizardName, Histogram histogram) {
154154
}
155155

156156
/** Export Dropwizard Timer as a histogram. Use TIME_UNIT as time unit. */
157-
MetricSnapshot<?> fromTimer(String dropwizardName, Timer timer) {
157+
MetricSnapshot fromTimer(String dropwizardName, Timer timer) {
158158
return fromSnapshotAndCount(
159159
dropwizardName,
160160
timer.getSnapshot(),
@@ -164,7 +164,7 @@ MetricSnapshot<?> fromTimer(String dropwizardName, Timer timer) {
164164
}
165165

166166
/** Export a Meter as a prometheus COUNTER. */
167-
MetricSnapshot<?> fromMeter(String dropwizardName, Meter meter) {
167+
MetricSnapshot fromMeter(String dropwizardName, Meter meter) {
168168
MetricMetadata metadata = getMetricMetaData(dropwizardName + "_total", meter);
169169
CounterSnapshot.CounterDataPointSnapshot.Builder dataPointBuilder =
170170
CounterSnapshot.CounterDataPointSnapshot.builder().value(meter.getCount());

prometheus-metrics-instrumentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmMemoryPoolAllocationMetricsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void testListenerLogic() {
5050
}
5151

5252
private double getCountByPool(String metricName, String poolName, MetricSnapshots snapshots) {
53-
for (MetricSnapshot<?> snapshot : snapshots) {
53+
for (MetricSnapshot snapshot : snapshots) {
5454
if (snapshot.getMetadata().getPrometheusName().equals(metricName)) {
5555
for (CounterSnapshot.CounterDataPointSnapshot data :
5656
((CounterSnapshot) snapshot).getDataPoints()) {

0 commit comments

Comments
 (0)