Skip to content

Commit 808c4ad

Browse files
committed
add checkstyle
Signed-off-by: Gregor Zeitlinger <[email protected]>
1 parent ab2a2c3 commit 808c4ad

File tree

10 files changed

+55
-40
lines changed

10 files changed

+55
-40
lines changed

examples/example-exemplars-tail-sampling/example-greeting-service/src/main/java/io/prometheus/metrics/examples/otel/exemplars/greeting/GreetingServlet.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
package io.prometheus.metrics.examples.otel.exemplars.greeting;
22

3+
import static io.prometheus.metrics.model.snapshots.Unit.nanosToSeconds;
4+
35
import io.prometheus.metrics.core.metrics.Histogram;
46
import io.prometheus.metrics.model.snapshots.Unit;
57
import jakarta.servlet.http.HttpServlet;
68
import jakarta.servlet.http.HttpServletRequest;
79
import jakarta.servlet.http.HttpServletResponse;
8-
910
import java.io.IOException;
1011
import java.util.Random;
1112

12-
import static io.prometheus.metrics.model.snapshots.Unit.nanosToSeconds;
13-
1413
/** Hello World REST servlet, with an example counter and an example histogram. */
1514
public class GreetingServlet extends HttpServlet {
1615

integration-tests/it-exporter/it-exporter-servlet-tomcat-sample/src/main/java/io/prometheus/metrics/it/exporter/servlet/tomcat/ExporterServletTomcatSample.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
import io.prometheus.metrics.model.registry.Collector;
88
import io.prometheus.metrics.model.registry.PrometheusRegistry;
99
import io.prometheus.metrics.model.snapshots.Unit;
10-
import org.apache.catalina.Context;
11-
import org.apache.catalina.LifecycleException;
12-
import org.apache.catalina.startup.Tomcat;
13-
1410
import java.io.File;
1511
import java.io.IOException;
1612
import java.nio.file.Files;
1713
import java.nio.file.Path;
14+
import org.apache.catalina.Context;
15+
import org.apache.catalina.LifecycleException;
16+
import org.apache.catalina.startup.Tomcat;
1817

1918
/** Sample application using the {@link PrometheusMetricsServlet} in Tomcat. */
2019
public class ExporterServletTomcatSample {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ MetricSnapshot fromMeter(String dropwizardName, Meter meter) {
196196
@Override
197197
public MetricSnapshots collect() {
198198
MetricSnapshots.Builder metricSnapshots = MetricSnapshots.builder();
199-
for (@SuppressWarnings("rawtypes")
200-
Map.Entry<MetricName, Gauge> entry : registry.getGauges(metricFilter).entrySet()) {
199+
for (Map.Entry<MetricName, Gauge> entry : registry.getGauges(metricFilter).entrySet()) {
201200
Optional.ofNullable(fromGauge(entry.getKey().getKey(), entry.getValue()))
202201
.ifPresent(metricSnapshots::metricSnapshot);
203202
}

prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/snapshots/Label.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ public String toString() {
3434

3535
@Override
3636
public boolean equals(Object o) {
37-
if (this == o) return true;
38-
if (o == null || getClass() != o.getClass()) return false;
37+
if (this == o) {
38+
return true;
39+
}
40+
if (o == null || getClass() != o.getClass()) {
41+
return false;
42+
}
3943
Label label = (Label) o;
4044
return Objects.equals(name, label.name) && Objects.equals(value, label.value);
4145
}

prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/snapshots/Labels.java

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,6 @@ public static Labels of(String... keyValuePairs) {
7070
}
7171

7272
// package private for testing
73-
static String[] makePrometheusNames(String[] names) {
74-
String[] prometheusNames = names;
75-
for (int i = 0; i < names.length; i++) {
76-
if (names[i].contains(".")) {
77-
if (prometheusNames == names) {
78-
prometheusNames = Arrays.copyOf(names, names.length);
79-
}
80-
prometheusNames[i] = PrometheusNaming.prometheusName(names[i]);
81-
}
82-
}
83-
return prometheusNames;
84-
}
85-
8673
/**
8774
* Create a new Labels instance. You can either create Labels with one of the static {@code
8875
* Labels.of(...)} methods, or you can use the {@link Labels#builder()}.
@@ -129,6 +116,19 @@ public static Labels of(String[] names, String[] values) {
129116
return new Labels(namesCopy, prometheusNames, valuesCopy);
130117
}
131118

119+
static String[] makePrometheusNames(String[] names) {
120+
String[] prometheusNames = names;
121+
for (int i = 0; i < names.length; i++) {
122+
if (names[i].contains(".")) {
123+
if (prometheusNames == names) {
124+
prometheusNames = Arrays.copyOf(names, names.length);
125+
}
126+
prometheusNames[i] = PrometheusNaming.prometheusName(names[i]);
127+
}
128+
}
129+
return prometheusNames;
130+
}
131+
132132
/**
133133
* Test if these labels contain a specific label name.
134134
*
@@ -286,14 +286,6 @@ public Labels merge(Labels other) {
286286
return new Labels(names, prometheusNames, values);
287287
}
288288

289-
/**
290-
* Create a new Labels instance containing the labels of this and the label passed as name and
291-
* value. The label name must not already be contained in this Labels instance.
292-
*/
293-
public Labels add(String name, String value) {
294-
return merge(Labels.of(name, value));
295-
}
296-
297289
/**
298290
* Create a new Labels instance containing the labels of this and the labels passed as names and
299291
* values. The new label names must not already be contained in this Labels instance.
@@ -313,6 +305,14 @@ public Labels merge(String[] names, String[] values) {
313305
return new Labels(mergedNames, prometheusNames, mergedValues);
314306
}
315307

308+
/**
309+
* Create a new Labels instance containing the labels of this and the label passed as name and
310+
* value. The label name must not already be contained in this Labels instance.
311+
*/
312+
public Labels add(String name, String value) {
313+
return merge(Labels.of(name, value));
314+
}
315+
316316
public boolean hasSameNames(Labels other) {
317317
return Arrays.equals(prometheusNames, other.prometheusNames);
318318
}
@@ -400,8 +400,12 @@ private void appendEscapedLabelValue(StringBuilder b, String value) {
400400

401401
@Override
402402
public boolean equals(Object o) {
403-
if (this == o) return true;
404-
if (o == null || getClass() != o.getClass()) return false;
403+
if (this == o) {
404+
return true;
405+
}
406+
if (o == null || getClass() != o.getClass()) {
407+
return false;
408+
}
405409
Labels labels = (Labels) o;
406410
return labels.hasSameNames(this) && labels.hasSameValues(this);
407411
}

prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/snapshots/MetricMetadata.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ private void validate() {
108108
throw new IllegalArgumentException(
109109
"'"
110110
+ name
111-
+ "': Illegal metric name. If the unit is non-null, the name must end with the unit: _"
111+
+ "': Illegal metric name. If the unit is non-null, "
112+
+ "the name must end with the unit: _"
112113
+ unit
113114
+ "."
114115
+ " Call "

prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/snapshots/Quantiles.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package io.prometheus.metrics.model.snapshots;
22

3-
import java.util.*;
3+
import java.util.ArrayList;
4+
import java.util.Arrays;
5+
import java.util.Collections;
6+
import java.util.Comparator;
7+
import java.util.Iterator;
8+
import java.util.List;
49

510
/** Immutable list of quantiles. */
611
public class Quantiles implements Iterable<Quantile> {

prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/snapshots/Unit.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,12 @@ public static double kiloBytesToBytes(double kilobytes) {
6161

6262
@Override
6363
public boolean equals(Object o) {
64-
if (this == o) return true;
65-
if (o == null || getClass() != o.getClass()) return false;
64+
if (this == o) {
65+
return true;
66+
}
67+
if (o == null || getClass() != o.getClass()) {
68+
return false;
69+
}
6670
Unit unit = (Unit) o;
6771
return Objects.equals(name, unit.name);
6872
}

prometheus-metrics-tracer/prometheus-metrics-tracer-initializer/src/main/java/io/prometheus/metrics/tracer/initializer/SpanContextSupplier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package io.prometheus.metrics.tracer.initializer;
22

3+
import io.prometheus.metrics.tracer.agent.OpenTelemetryAgentSpanContext;
34
import io.prometheus.metrics.tracer.common.SpanContext;
45
import io.prometheus.metrics.tracer.otel.OpenTelemetrySpanContext;
5-
import io.prometheus.metrics.tracer.otel_agent.OpenTelemetryAgentSpanContext;
66
import java.util.concurrent.atomic.AtomicReference;
77

88
public class SpanContextSupplier {

prometheus-metrics-tracer/prometheus-metrics-tracer-otel-agent/src/main/java/io/prometheus/metrics/tracer/otel_agent/OpenTelemetryAgentSpanContext.java renamed to prometheus-metrics-tracer/prometheus-metrics-tracer-otel-agent/src/main/java/io/prometheus/metrics/tracer/agent/OpenTelemetryAgentSpanContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.prometheus.metrics.tracer.otel_agent;
1+
package io.prometheus.metrics.tracer.agent;
22

33
import io.opentelemetry.api.trace.Span;
44
import io.opentelemetry.api.trace.SpanId;

0 commit comments

Comments
 (0)