Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@
groupName: "protobuf",
separateMajorMinor: false,
},
{
"description": "Flint autofix: align extractVersion for protoc",
"extractVersion": "^(?<version>.+)\\.0\\.0$",
"matchDepNames": [
"protoc"
]
}
],
customManagers: [
{
customType: "regex",
managerFilePatterns: ["/^\\.github\\/workflows\\/micrometer-compatibility\\.yml$/"],
matchStrings: [
"# renovate: datasource=(?<datasource>\\S+) depName=(?<depName>\\S+) packageName=(?<packageName>\\S+) currentValue=(?<currentValue>\\S+)\\n\\s*DEFAULT_MICROMETER_REF:\\s*(?<currentDigest>[a-f0-9]{40})",
],
},
],
customManagers: [],
}
}
15 changes: 10 additions & 5 deletions .github/workflows/micrometer-compatibility.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Micrometer Compatibility
name: Micrometer Opt-In Compatibility

on:
pull_request:
Expand All @@ -8,14 +8,19 @@ on:
micrometer-repository:
description: Micrometer repository to test, in owner/name form
required: false
default: micrometer-metrics/micrometer
default: zeitlinger/micrometer
micrometer-ref:
description: Micrometer branch, tag, or commit to test
required: false
default: main
default: 1af1b3185058941eea57dc467bfe0df5a4786fe4

permissions: {}

env:
DEFAULT_MICROMETER_REPOSITORY: zeitlinger/micrometer
# renovate: datasource=git-refs depName=zeitlinger/micrometer packageName=https://github.com/zeitlinger/micrometer currentValue=feat/prometheus-client-opt-in
DEFAULT_MICROMETER_REF: 1af1b3185058941eea57dc467bfe0df5a4786fe4

jobs:
micrometer-compatibility:
runs-on: ubuntu-24.04
Expand All @@ -34,6 +39,6 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- name: Run Micrometer compatibility tests
env:
MICROMETER_REPOSITORY: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.micrometer-repository || 'micrometer-metrics/micrometer' }}
MICROMETER_REF: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.micrometer-ref || 'main' }}
MICROMETER_REPOSITORY: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.micrometer-repository || env.DEFAULT_MICROMETER_REPOSITORY }}
MICROMETER_REF: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.micrometer-ref || env.DEFAULT_MICROMETER_REF }}
run: mise run micrometer:test
6 changes: 4 additions & 2 deletions .mise/lib/micrometer_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
os.environ.get("MICROMETER_DIR", "/tmp/micrometer-compat")
)
DEFAULT_MICROMETER_REPOSITORY = os.environ.get(
"MICROMETER_REPOSITORY", "micrometer-metrics/micrometer"
"MICROMETER_REPOSITORY", "zeitlinger/micrometer"
)
DEFAULT_MICROMETER_REMOTE = os.environ.get("MICROMETER_REMOTE", "origin")
DEFAULT_MICROMETER_REF = os.environ.get("MICROMETER_REF", "main")
DEFAULT_MICROMETER_REF = os.environ.get(
"MICROMETER_REF", "feat/prometheus-client-opt-in"
)
DEFAULT_INIT_SCRIPT = Path(
os.environ.get("MICROMETER_INIT_SCRIPT", "/tmp/micrometer-prom-local.init.gradle")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ protected MetricSnapshots collectMetricSnapshots(PrometheusScrapeRequest scrapeR
return new MetricSnapshots(snaps);
}

/**
* @deprecated Use {@code getMetricFamilyDescriptors()} instead.
*/
@Override
@Deprecated
@SuppressWarnings("InlineMeSuggester")
public List<String> getPrometheusNames() {
List<String> names = new ArrayList<String>();
names.add("x_calls_total");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,15 @@ protected CounterSnapshot collect(List<Labels> labels, List<DataPoint> metricDat
for (int i = 0; i < labels.size(); i++) {
data.add(metricData.get(i).collect(labels.get(i)));
}
return new CounterSnapshot(getMetadata(), data);
return new CounterSnapshot(metadata, data);
}

/**
* @deprecated Use {@link #getMetricFamilyDescriptor()} instead.
*/
@Override
@Deprecated
@SuppressWarnings("InlineMeSuggester")
public MetricType getMetricType() {
return MetricType.COUNTER;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ public CounterSnapshot collect() {
new CounterSnapshot.CounterDataPointSnapshot(
value, makeLabels(labelValues), null, 0L));
});
return new CounterSnapshot(getMetadata(), dataPoints);
return new CounterSnapshot(metadata, dataPoints);
}

/**
* @deprecated Use {@link #getMetricFamilyDescriptor()} instead.
*/
@Override
@Deprecated
@SuppressWarnings("InlineMeSuggester")
public MetricType getMetricType() {
return MetricType.COUNTER;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@ protected GaugeSnapshot collect(List<Labels> labels, List<DataPoint> metricData)
for (int i = 0; i < labels.size(); i++) {
dataPointSnapshots.add(metricData.get(i).collect(labels.get(i)));
}
return new GaugeSnapshot(getMetadata(), dataPointSnapshots);
return new GaugeSnapshot(metadata, dataPointSnapshots);
}

/**
* @deprecated Use {@link #getMetricFamilyDescriptor()} instead.
*/
@Override
@Deprecated
@SuppressWarnings("InlineMeSuggester")
public MetricType getMetricType() {
return MetricType.GAUGE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,15 @@ public GaugeSnapshot collect() {
dataPoints.add(
new GaugeSnapshot.GaugeDataPointSnapshot(value, makeLabels(labelValues), null, 0L));
});
return new GaugeSnapshot(getMetadata(), dataPoints);
return new GaugeSnapshot(metadata, dataPoints);
}

/**
* @deprecated Use {@link #getMetricFamilyDescriptor()} instead.
*/
@Override
@Deprecated
@SuppressWarnings("InlineMeSuggester")
public MetricType getMetricType() {
return MetricType.GAUGE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,10 +647,15 @@ protected HistogramSnapshot collect(List<Labels> labels, List<DataPoint> metricD
for (int i = 0; i < labels.size(); i++) {
data.add(metricData.get(i).collect(labels.get(i)));
}
return new HistogramSnapshot(getMetadata(), data);
return new HistogramSnapshot(metadata, data);
}

/**
* @deprecated Use {@link #getMetricFamilyDescriptor()} instead.
*/
@Override
@Deprecated
@SuppressWarnings("InlineMeSuggester")
public MetricType getMetricType() {
return MetricType.HISTOGRAM;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void setLabelValues(String... labelValues) {
throw new IllegalArgumentException(
getClass().getSimpleName()
+ " "
+ getMetadata().getName()
+ metadata.getName()
+ " was created with "
+ labelNames.length
+ " label names, but you called setLabelValues() with "
Expand All @@ -66,7 +66,7 @@ public void addLabelValues(String... labelValues) {
throw new IllegalArgumentException(
getClass().getSimpleName()
+ " "
+ getMetadata().getName()
+ metadata.getName()
+ " was created with "
+ labelNames.length
+ " label names, but you called addLabelValues() with "
Expand All @@ -82,7 +82,7 @@ public void remove(String... labelValues) {
throw new IllegalArgumentException(
getClass().getSimpleName()
+ " "
+ getMetadata().getName()
+ metadata.getName()
+ " was created with "
+ labelNames.length
+ " label names, but you called remove() with "
Expand All @@ -103,10 +103,15 @@ public InfoSnapshot collect() {
data.add(new InfoSnapshot.InfoDataPointSnapshot(label.merge(constLabels)));
}
}
return new InfoSnapshot(getMetadata(), data);
return new InfoSnapshot(metadata, data);
}

/**
* @deprecated Use {@link #getMetricFamilyDescriptor()} instead.
*/
@Override
@Deprecated
@SuppressWarnings("InlineMeSuggester")
public MetricType getMetricType() {
return MetricType.INFO;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package io.prometheus.metrics.core.metrics;

import io.prometheus.metrics.config.PrometheusProperties;
import io.prometheus.metrics.model.registry.MetricType;
import io.prometheus.metrics.model.snapshots.Label;
import io.prometheus.metrics.model.snapshots.Labels;
import io.prometheus.metrics.model.snapshots.MetricFamilyDescriptor;
import io.prometheus.metrics.model.snapshots.MetricMetadata;
import io.prometheus.metrics.model.snapshots.PrometheusNaming;
import io.prometheus.metrics.model.snapshots.Unit;
Expand All @@ -20,7 +22,7 @@
*/
public abstract class MetricWithFixedMetadata extends Metric {

private final MetricMetadata metadata;
protected final MetricMetadata metadata;
protected final String[] labelNames;

protected MetricWithFixedMetadata(Builder<?, ?> builder) {
Expand All @@ -37,6 +39,22 @@ protected MetricWithFixedMetadata(Builder<?, ?> builder) {
}

@Override
@Nullable
@SuppressWarnings("deprecation")
public MetricFamilyDescriptor getMetricFamilyDescriptor() {
MetricType metricType = getMetricType();
if (metricType == null) {
return null;
}
return MetricFamilyDescriptor.of(metricType, metadata, getPrometheusLabels());
}

/**
* @deprecated Use {@link #getMetricFamilyDescriptor()} instead.
*/
@Override
@Deprecated
@SuppressWarnings("InlineMeSuggester")
public MetricMetadata getMetadata() {
return metadata;
}
Expand Down Expand Up @@ -65,13 +83,27 @@ private String makeExpositionBaseName(@Nullable String expositionBaseName, @Null
return expositionBaseName;
}

/**
* @deprecated Use {@link #getMetricFamilyDescriptor()} instead.
*/
@Override
@Deprecated
@SuppressWarnings("InlineMeSuggester")
public String getPrometheusName() {
return metadata.getPrometheusName();
}

/**
* @deprecated Use {@link #getMetricFamilyDescriptor()} instead.
*/
@Override
@Deprecated
@SuppressWarnings("InlineMeSuggester")
public Set<String> getLabelNames() {
return getPrometheusLabels();
}

private Set<String> getPrometheusLabels() {
Set<String> names = new HashSet<>();
for (String labelName : labelNames) {
names.add(PrometheusNaming.prometheusName(labelName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private StateSet(Builder builder, String[] names) {
super(builder);
this.names = names;
for (String name : names) {
if (this.getMetadata().getPrometheusName().equals(prometheusName(name))) {
if (metadata.getPrometheusName().equals(prometheusName(name))) {
throw new IllegalArgumentException(
"Label name "
+ name
Expand All @@ -82,10 +82,15 @@ protected StateSetSnapshot collect(List<Labels> labels, List<DataPoint> metricDa
new StateSetSnapshot.StateSetDataPointSnapshot(
names, metricDataList.get(i).values, labels.get(i)));
}
return new StateSetSnapshot(getMetadata(), data);
return new StateSetSnapshot(metadata, data);
}

/**
* @deprecated Use {@link #getMetricFamilyDescriptor()} instead.
*/
@Override
@Deprecated
@SuppressWarnings("InlineMeSuggester")
public MetricType getMetricType() {
return MetricType.STATESET;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public D labelValues(String... labelValues) {
throw new IllegalArgumentException(
getClass().getSimpleName()
+ " "
+ getMetadata().getName()
+ metadata.getName()
+ " was created with label names, so you must call labelValues(...)"
+ " when using it.");
} else {
Expand All @@ -120,7 +120,7 @@ public D labelValues(String... labelValues) {
if (l.get(i) == null) {
throw new IllegalArgumentException(
"null label value for metric "
+ getMetadata().getName()
+ metadata.getName()
+ " and label "
+ labelNames[i]);
}
Expand Down Expand Up @@ -171,7 +171,7 @@ protected MetricsProperties[] getMetricProperties(
if (Objects.equals(builder.exemplarsEnabled, false)) {
properties.add(MetricsProperties.builder().exemplarsEnabled(false).build());
}
String metricName = getMetadata().getName();
String metricName = metadata.getName();
if (prometheusProperties.getMetricProperties(metricName) != null) {
properties.add(prometheusProperties.getMetricProperties(metricName));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,15 @@ protected SummarySnapshot collect(List<Labels> labels, List<DataPoint> metricDat
for (int i = 0; i < labels.size(); i++) {
data.add(metricData.get(i).collect(labels.get(i)));
}
return new SummarySnapshot(getMetadata(), data);
return new SummarySnapshot(metadata, data);
}

/**
* @deprecated Use {@link #getMetricFamilyDescriptor()} instead.
*/
@Override
@Deprecated
@SuppressWarnings("InlineMeSuggester")
public MetricType getMetricType() {
return MetricType.SUMMARY;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,15 @@ public SummarySnapshot collect() {
new SummarySnapshot.SummaryDataPointSnapshot(
count, sum, quantiles, makeLabels(labelValues), Exemplars.EMPTY, 0L));
});
return new SummarySnapshot(getMetadata(), dataPoints);
return new SummarySnapshot(metadata, dataPoints);
}

/**
* @deprecated Use {@link #getMetricFamilyDescriptor()} instead.
*/
@Override
@Deprecated
@SuppressWarnings("InlineMeSuggester")
public MetricType getMetricType() {
return MetricType.SUMMARY;
}
Expand Down
Loading
Loading