Skip to content

Commit 159329b

Browse files
committed
remove unneeded code since moved validation
Signed-off-by: Jay DeLuca <[email protected]>
1 parent 446e4bd commit 159329b

File tree

12 files changed

+15
-581
lines changed

12 files changed

+15
-581
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import io.prometheus.metrics.core.datapoints.CounterDataPoint;
66
import io.prometheus.metrics.core.exemplars.ExemplarSampler;
77
import io.prometheus.metrics.core.exemplars.ExemplarSamplerConfig;
8-
import io.prometheus.metrics.model.registry.MetricType;
98
import io.prometheus.metrics.model.snapshots.CounterSnapshot;
109
import io.prometheus.metrics.model.snapshots.Exemplar;
1110
import io.prometheus.metrics.model.snapshots.Labels;
@@ -93,11 +92,6 @@ protected CounterSnapshot collect(List<Labels> labels, List<DataPoint> metricDat
9392
return new CounterSnapshot(getMetadata(), data);
9493
}
9594

96-
@Override
97-
public MetricType getMetricType() {
98-
return MetricType.COUNTER;
99-
}
100-
10195
@Override
10296
protected DataPoint newDataPoint() {
10397
if (exemplarSamplerConfig != null) {

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import io.prometheus.metrics.core.datapoints.GaugeDataPoint;
66
import io.prometheus.metrics.core.exemplars.ExemplarSampler;
77
import io.prometheus.metrics.core.exemplars.ExemplarSamplerConfig;
8-
import io.prometheus.metrics.model.registry.MetricType;
98
import io.prometheus.metrics.model.snapshots.Exemplar;
109
import io.prometheus.metrics.model.snapshots.GaugeSnapshot;
1110
import io.prometheus.metrics.model.snapshots.Labels;
@@ -95,11 +94,6 @@ protected GaugeSnapshot collect(List<Labels> labels, List<DataPoint> metricData)
9594
return new GaugeSnapshot(getMetadata(), dataPointSnapshots);
9695
}
9796

98-
@Override
99-
public MetricType getMetricType() {
100-
return MetricType.GAUGE;
101-
}
102-
10397
@Override
10498
protected DataPoint newDataPoint() {
10599
if (exemplarSamplerConfig != null) {

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import io.prometheus.metrics.core.exemplars.ExemplarSampler;
88
import io.prometheus.metrics.core.exemplars.ExemplarSamplerConfig;
99
import io.prometheus.metrics.core.util.Scheduler;
10-
import io.prometheus.metrics.model.registry.MetricType;
1110
import io.prometheus.metrics.model.snapshots.ClassicHistogramBuckets;
1211
import io.prometheus.metrics.model.snapshots.Exemplars;
1312
import io.prometheus.metrics.model.snapshots.HistogramSnapshot;
@@ -650,11 +649,6 @@ protected HistogramSnapshot collect(List<Labels> labels, List<DataPoint> metricD
650649
return new HistogramSnapshot(getMetadata(), data);
651650
}
652651

653-
@Override
654-
public MetricType getMetricType() {
655-
return MetricType.HISTOGRAM;
656-
}
657-
658652
@Override
659653
protected DataPoint newDataPoint() {
660654
return new DataPoint();

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.prometheus.metrics.core.metrics;
22

33
import io.prometheus.metrics.config.PrometheusProperties;
4-
import io.prometheus.metrics.model.registry.MetricType;
54
import io.prometheus.metrics.model.snapshots.InfoSnapshot;
65
import io.prometheus.metrics.model.snapshots.Labels;
76
import io.prometheus.metrics.model.snapshots.Unit;
@@ -106,11 +105,6 @@ public InfoSnapshot collect() {
106105
return new InfoSnapshot(getMetadata(), data);
107106
}
108107

109-
@Override
110-
public MetricType getMetricType() {
111-
return MetricType.INFO;
112-
}
113-
114108
public static Builder builder() {
115109
return new Builder(PrometheusProperties.get());
116110
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import io.prometheus.metrics.config.PrometheusProperties;
66
import io.prometheus.metrics.core.datapoints.StateSetDataPoint;
7-
import io.prometheus.metrics.model.registry.MetricType;
87
import io.prometheus.metrics.model.snapshots.Labels;
98
import io.prometheus.metrics.model.snapshots.StateSetSnapshot;
109
import java.util.ArrayList;
@@ -85,11 +84,6 @@ protected StateSetSnapshot collect(List<Labels> labels, List<DataPoint> metricDa
8584
return new StateSetSnapshot(getMetadata(), data);
8685
}
8786

88-
@Override
89-
public MetricType getMetricType() {
90-
return MetricType.STATESET;
91-
}
92-
9387
@Override
9488
public void setTrue(String state) {
9589
getNoLabels().setTrue(state);

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import io.prometheus.metrics.core.datapoints.DistributionDataPoint;
88
import io.prometheus.metrics.core.exemplars.ExemplarSampler;
99
import io.prometheus.metrics.core.exemplars.ExemplarSamplerConfig;
10-
import io.prometheus.metrics.model.registry.MetricType;
1110
import io.prometheus.metrics.model.snapshots.Exemplars;
1211
import io.prometheus.metrics.model.snapshots.Labels;
1312
import io.prometheus.metrics.model.snapshots.Quantile;
@@ -119,11 +118,6 @@ protected SummarySnapshot collect(List<Labels> labels, List<DataPoint> metricDat
119118
return new SummarySnapshot(getMetadata(), data);
120119
}
121120

122-
@Override
123-
public MetricType getMetricType() {
124-
return MetricType.SUMMARY;
125-
}
126-
127121
@Override
128122
protected DataPoint newDataPoint() {
129123
return new DataPoint();

prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/registry/Collector.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,4 @@ default MetricSnapshot collect(
7878
default String getPrometheusName() {
7979
return null;
8080
}
81-
82-
/**
83-
* Returns the type of metric this collector produces.
84-
*
85-
* <p>This is used during registration to validate that all collectors with the same Prometheus
86-
* name have the same metric type. If two collectors return the same non-null Prometheus name but
87-
* different metric types, registration will fail with an exception.
88-
*
89-
* <p>Returning {@code null} means the type is unknown, and type validation will be skipped for
90-
* this collector.
91-
*
92-
* <p>All metrics in {@code prometheus-metrics-core} override this to return their specific type.
93-
*
94-
* @return the metric type, or {@code null} if unknown
95-
*/
96-
@Nullable
97-
MetricType getMetricType();
9881
}

prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/registry/MetricIdentifier.java

Lines changed: 0 additions & 57 deletions
This file was deleted.

prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/registry/MetricType.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/registry/MultiCollector.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import javax.annotation.Nullable;
99

1010
/** Like {@link Collector}, but collecting multiple Snapshots at once. */
11+
@FunctionalInterface
1112
public interface MultiCollector {
1213

1314
/** Called when the Prometheus server scrapes metrics. */
@@ -69,21 +70,4 @@ default MetricSnapshots collect(
6970
default List<String> getPrometheusNames() {
7071
return Collections.emptyList();
7172
}
72-
73-
/**
74-
* Returns the metric type for a given Prometheus name produced by this MultiCollector.
75-
*
76-
* <p>This is used during registration to validate that all collectors with the same Prometheus
77-
* name have the same metric type. If this method returns {@code null} for a given name, type
78-
* validation will be skipped for that metric.
79-
*
80-
* <p>If your collector returns metrics with constant types that do not change at runtime, it is a
81-
* good idea to override this method to enable early type validation at registration time instead
82-
* of at scrape time.
83-
*
84-
* @param prometheusName the Prometheus name to get the type for
85-
* @return the metric type, or {@code null} if unknown
86-
*/
87-
@Nullable
88-
MetricType getMetricType(String prometheusName);
8973
}

0 commit comments

Comments
 (0)