Skip to content

Commit 6906efc

Browse files
committed
lint
Signed-off-by: Gregor Zeitlinger <[email protected]>
1 parent c5b6fad commit 6906efc

File tree

10 files changed

+91
-52
lines changed

10 files changed

+91
-52
lines changed

docs/content/exporters/httpserver.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ HTTPServer server = HTTPServer.builder()
1414
```
1515

1616
By default, `HTTPServer` binds to any IP address, you can change this with
17-
[hostname()](</client_java/api/io/prometheus/metrics/exporter/httpserver/HTTPServer.Builder.html#hostname(java.lang.String)>)
18-
or [inetAddress()](</client_java/api/io/prometheus/metrics/exporter/httpserver/HTTPServer.Builder.html#inetAddress(java.net.InetAddress)>).
17+
[hostname()](</client_java/api/io/prometheus/metrics/exporter/httpserver/HTTPServer.Builder.html#hostname(java.lang.String)>) <!-- editorconfig-checker-disable-line -->
18+
or [inetAddress()](</client_java/api/io/prometheus/metrics/exporter/httpserver/HTTPServer.Builder.html#inetAddress(java.net.InetAddress)>). <!-- editorconfig-checker-disable-line -->
1919

2020
`HTTPServer` is configured with three endpoints:
2121

@@ -24,7 +24,7 @@ or [inetAddress()](</client_java/api/io/prometheus/metrics/exporter/httpserver/H
2424
- `/` the default handler is a static HTML page.
2525

2626
The default handler can be changed
27-
with [defaultHandler()](</client_java/api/io/prometheus/metrics/exporter/httpserver/HTTPServer.Builder.html#defaultHandler(com.sun.net.httpserver.HttpHandler)>).
27+
with [defaultHandler()](</client_java/api/io/prometheus/metrics/exporter/httpserver/HTTPServer.Builder.html#defaultHandler(com.sun.net.httpserver.HttpHandler)>). <!-- editorconfig-checker-disable-line -->
2828

2929
## Authentication and HTTPS
3030

@@ -33,7 +33,7 @@ with [defaultHandler()](</client_java/api/io/prometheus/metrics/exporter/httpser
3333
- [httpsConfigurator()](</client_java/api/io/prometheus/metrics/exporter/httpserver/HTTPServer.Builder.html#httpsConfigurator(com.sun.net.httpserver.HttpsConfigurator)>)
3434
is for configuring HTTPS.
3535

36-
You can find an example of authentication and SSL in the [jmx_exporter](https://github.com/prometheus/jmx_exporter).
36+
You can find an example of authentication and SSL in the [jmx_exporter](https://github.com/prometheus/jmx_exporter). <!-- editorconfig-checker-disable-line -->
3737

3838
## Properties
3939

docs/content/exporters/pushgateway.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ title: Pushgateway
33
weight: 5
44
---
55

6-
The [Prometheus Pushgateway](https://github.com/prometheus/pushgateway) exists to allow ephemeral and batch jobs to expose their metrics to Prometheus.
7-
Since these kinds of jobs may not exist long enough to be scraped, they can instead push their metrics to a Pushgateway.
6+
The [Prometheus Pushgateway](https://github.com/prometheus/pushgateway) exists to allow ephemeral
7+
and batch jobs to expose their metrics to Prometheus.
8+
Since these kinds of jobs may not exist long enough to be scraped, they can instead push their
9+
metrics to a Pushgateway.
810
The Pushgateway then exposes these metrics to Prometheus.
911

10-
The [PushGateway](/client_java/api/io/prometheus/metrics/exporter/pushgateway/PushGateway.html) Java class allows you to push metrics to a Prometheus Pushgateway.
12+
The [PushGateway](/client_java/api/io/prometheus/metrics/exporter/pushgateway/PushGateway.html) Java
13+
class allows you to push metrics to a Prometheus Pushgateway.
1114

1215
## Example
1316

@@ -97,7 +100,8 @@ The `PushGatewayTestApp` in `integration-tests/it-pushgateway` has a complete ex
97100

98101
## SSL
99102

100-
The [PushGateway](/client_java/api/io/prometheus/metrics/exporter/pushgateway/PushGateway.html) supports SSL.
103+
The [PushGateway](/client_java/api/io/prometheus/metrics/exporter/pushgateway/PushGateway.html)
104+
supports SSL.
101105

102106
```java
103107
PushGateway pushGateway = PushGateway.builder()
@@ -109,10 +113,11 @@ PushGateway pushGateway = PushGateway.builder()
109113
However, this requires that the JVM can validate the server certificate.
110114

111115
If you want to skip certificate verification, you need to provide your own
112-
[HttpConnectionFactory](/client_java/api/io/prometheus/metrics/exporter/pushgateway/HttpConnectionFactory.html).
116+
[HttpConnectionFactory](/client_java/api/io/prometheus/metrics/exporter/pushgateway/HttpConnectionFactory.html). <!-- editorconfig-checker-disable-line -->
113117
The `PushGatewayTestApp` in `integration-tests/it-pushgateway` has a complete example of this.
114118

115119
## Configuration Properties
116120

117-
The [PushGateway](/client_java/api/io/prometheus/metrics/exporter/pushgateway/PushGateway.html) supports a couple of properties that can be configured at runtime.
121+
The [PushGateway](/client_java/api/io/prometheus/metrics/exporter/pushgateway/PushGateway.html)
122+
supports a couple of properties that can be configured at runtime.
118123
See [config]({{< relref "../config/config.md" >}}).

docs/content/exporters/servlet.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ weight: 4
44
---
55

66
The
7-
[PrometheusMetricsServlet](/client_java/api/io/prometheus/metrics/exporter/servlet/jakarta/PrometheusMetricsServlet.html)
7+
[PrometheusMetricsServlet](/client_java/api/io/prometheus/metrics/exporter/servlet/jakarta/PrometheusMetricsServlet.html) <!-- editorconfig-checker-disable-line -->
88
is a [Jakarta Servlet](https://jakarta.ee/specifications/servlet/) for exposing a metric endpoint.
99

1010
## web.xml
1111

1212
The old-school way of configuring a servlet is in a `web.xml` file:
1313

14+
<!-- editorconfig-checker-disable -->
1415
```xml
1516
<?xml version="1.0" encoding="UTF-8"?>
1617
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
@@ -27,6 +28,7 @@ The old-school way of configuring a servlet is in a `web.xml` file:
2728
</servlet-mapping>
2829
</web-app>
2930
```
31+
<!-- editorconfig-checker-enable -->
3032

3133
## Programmatic
3234

@@ -36,10 +38,12 @@ The API for that depends on the Servlet container.
3638
The [examples](https://github.com/prometheus/client_java/tree/1.0.x/examples) directory has an
3739
example of an embedded
3840
[Tomcat](https://tomcat.apache.org/) container with the
39-
[PrometheusMetricsServlet](/client_java/api/io/prometheus/metrics/exporter/servlet/jakarta/PrometheusMetricsServlet.html)
41+
[PrometheusMetricsServlet](/client_java/api/io/prometheus/metrics/exporter/servlet/jakarta/PrometheusMetricsServlet.html) <!-- editorconfig-checker-disable-line -->
4042
configured.
4143

4244
## Spring
4345

44-
You can use the [PrometheusMetricsServlet](/client_java/api/io/prometheus/metrics/exporter/servlet/jakarta/PrometheusMetricsServlet.html) in Spring applications.
46+
You can use
47+
the [PrometheusMetricsServlet](/client_java/api/io/prometheus/metrics/exporter/servlet/jakarta/PrometheusMetricsServlet.html) <!-- editorconfig-checker-disable-line -->
48+
in Spring applications.
4549
See [our Spring doc]({{< relref "spring.md" >}}).

docs/content/getting-started/labels.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ loginCount.labelValues(userId, timestamp).inc();
8080

8181
If you register a metric without labels, it will show up immediately with initial value of zero.
8282

83-
However, metrics with labels only show up after the label values are first used. In the example above
83+
However, metrics with labels only show up after the label values are first used. In the example
84+
above
8485

8586
```java
8687
counter.labelValues("paypal", "error").inc();
@@ -149,4 +150,4 @@ Counter counter = Counter.builder()
149150
However, most use cases for `constLabels()` are better covered by target labels set by the scraping
150151
Prometheus server,
151152
or by one specific metric (e.g. a `build_info` or a `machine_role` metric). See also
152-
[target labels, not static scraped labels](https://prometheus.io/docs/instrumenting/writing_exporters/#target-labels-not-static-scraped-labels).
153+
[target labels, not static scraped labels](https://prometheus.io/docs/instrumenting/writing_exporters/#target-labels-not-static-scraped-labels). <!-- editorconfig-checker-disable-line -->

docs/content/getting-started/metric-types.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ most important options:
111111
- `classicBuckets(...)`: Set the classic bucket boundaries. Default buckets are `.005`, `.01`,
112112
`.025`, `.05`, `.1`, `.25`, `.5`, `1`, `2.5`, `5`, `and 10`. The default bucket boundaries are
113113
designed for measuring request durations in seconds.
114-
- `nativeMaxNumberOfBuckets()`: Upper limit for the number of native histogram buckets. Default is 160. When the maximum is reached, the native histogram automatically reduces resolution to stay
114+
- `nativeMaxNumberOfBuckets()`: Upper limit for the number of native histogram buckets. Default is
115+
160. When the maximum is reached, the native histogram automatically reduces resolution to stay
115116
below the limit.
116117

117118
See Javadoc
@@ -198,14 +199,15 @@ be changed with `maxAgeSeconds()` and `numberOfAgeBuckets()`.
198199
Some options can be configured at runtime, see [config]({{< relref "../config/config.md" >}}).
199200

200201
In general you should prefer histograms over summaries. The Prometheus query language has a
201-
function [histogram_quantile()](https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile)
202+
function [histogram_quantile()](https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile) <!-- editorconfig-checker-disable-line -->
202203
for calculating quantiles from histograms. The advantage of query-time quantile calculation is that
203204
you can aggregate histograms before calculating the quantile. With summaries you must use the
204205
quantile with all its labels as it is.
205206

206207
## Info
207208

208-
Info metrics are used to expose textual information which should not change during process lifetime. The value of an Info metric is always `1`.
209+
Info metrics are used to expose textual information which should not change during process lifetime.
210+
The value of an Info metric is always `1`.
209211

210212
```java
211213
Info info = Info.builder()
@@ -223,11 +225,13 @@ info.setLabelValues(version, vendor, runtime);
223225

224226
The info above looks as follows in OpenMetrics text format:
225227

228+
<!-- editorconfig-checker-disable -->
226229
```text
227230
# TYPE jvm_runtime info
228231
# HELP jvm_runtime JVM runtime info
229232
jvm_runtime_info{runtime="OpenJDK Runtime Environment",vendor="Oracle Corporation",version="1.8.0_382-b05"} 1
230233
```
234+
<!-- editorconfig-checker-enable -->
231235

232236
The example is taken from the `prometheus-metrics-instrumentation-jvm` module, so if you have
233237
`JvmMetrics` registered you should have a `jvm_runtime_info` metric out-of-the-box.

docs/content/getting-started/multi-target.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ weight: 7
77
This is for the upcoming release 1.1.0.
88
{{< /hint >}}
99

10-
To support multi-target pattern you can create a custom collector overriding the purposed internal method in ExtendedMultiCollector
10+
To support multi-target pattern you can create a custom collector overriding the purposed internal
11+
method in ExtendedMultiCollector
1112
see SampleExtendedMultiCollector in io.prometheus.metrics.examples.httpserver
1213

14+
<!-- editorconfig-checker-disable -->
1315
```java
1416
public class SampleExtendedMultiCollector extends ExtendedMultiCollector {
1517

@@ -76,8 +78,11 @@ public class SampleExtendedMultiCollector extends ExtendedMultiCollector {
7678
}
7779

7880
```
81+
<!-- editorconfig-checker-enable -->
7982

80-
`PrometheusScrapeRequest` provides methods to access http-related infos from the request originally received by the endpoint
83+
84+
`PrometheusScrapeRequest` provides methods to access http-related infos from the request originally
85+
received by the endpoint
8186

8287
```java
8388
public interface PrometheusScrapeRequest {

docs/content/getting-started/performance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ In performance critical applications we recommend to use either the classic repr
5353
native representation, but not both.
5454

5555
You can either configure this in code for each histogram by
56-
calling [classicOnly()](</client_java/api/io/prometheus/metrics/core/metrics/Histogram.Builder.html#classicOnly()>)
56+
calling [classicOnly()](</client_java/api/io/prometheus/metrics/core/metrics/Histogram.Builder.html#classicOnly()>) <!-- editorconfig-checker-disable-line -->
5757
or [nativeOnly()](</client_java/api/io/prometheus/metrics/core/metrics/Histogram.Builder.html#nativeOnly()>),
5858
or you use the corresponding [config options]({{< relref "../config/config.md" >}}).
5959

docs/content/migration/simpleclient.md

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,31 @@ title: Simpleclient
33
weight: 1
44
---
55

6-
The Prometheus Java client library 1.0.0 is a complete rewrite of the underlying data model, and is not backward
6+
The Prometheus Java client library 1.0.0 is a complete rewrite of the underlying data model, and is
7+
not backward
78
compatible with releases 0.16.0 and older for a variety of reasons:
89

9-
- The old data model was based on [OpenMetrics](https://openmetrics.io). Native histograms don't fit with the
10-
OpenMetrics model because they don't follow the "every sample has exactly one double value" paradigm. It was a lot
11-
cleaner to implement a dedicated `prometheus-metrics-model` than trying to fit native histograms into the existing
10+
- The old data model was based on [OpenMetrics](https://openmetrics.io). Native histograms don't fit
11+
with the
12+
OpenMetrics model because they don't follow the "every sample has exactly one double value"
13+
paradigm. It was a lot
14+
cleaner to implement a dedicated `prometheus-metrics-model` than trying to fit native histograms
15+
into the existing
1216
OpenMetrics-based model.
13-
- Version 0.16.0 and older has multiple Maven modules sharing the same Java package name. This is not supported by the
14-
Java module system. To support users of Java modules, we renamed all packages and made sure no package is reused
17+
- Version 0.16.0 and older has multiple Maven modules sharing the same Java package name. This is
18+
not supported by the
19+
Java module system. To support users of Java modules, we renamed all packages and made sure no
20+
package is reused
1521
across multiple Maven modules.
1622

1723
## Migration using the Simpleclient Bridge
1824

19-
Good news: Users of version 0.16.0 and older do not need to refactor all their instrumentation code to get started with
25+
Good news: Users of version 0.16.0 and older do not need to refactor all their instrumentation code
26+
to get started with
2027
1.0.0.
2128

22-
We provide a migration module for bridging the old simpleclient `CollectorRegistry` to the new `PrometheusRegistry`.
29+
We provide a migration module for bridging the old simpleclient `CollectorRegistry` to the new
30+
`PrometheusRegistry`.
2331

2432
To use the bridge, add the following dependency:
2533

@@ -51,7 +59,8 @@ Then add the following to your code:
5159
SimpleclientCollector.builder().register();
5260
```
5361

54-
This will make all metrics registered with simpleclient's `CollectorRegistry.defaultRegistry` available in the new
62+
This will make all metrics registered with simpleclient's `CollectorRegistry.defaultRegistry`
63+
available in the new
5564
`PrometheusRegistry.defaultRegistry`.
5665

5766
If you are using custom registries, you can specify them like this:
@@ -60,12 +69,15 @@ If you are using custom registries, you can specify them like this:
6069
CollectorRegistry simpleclientRegistry = ...;
6170
PrometheusRegistry prometheusRegistry = ...;
6271

63-
SimpleclientCollector.builder().collectorRegistry(simpleclientRegistry).register(prometheusRegistry);
72+
SimpleclientCollector.builder()
73+
.collectorRegistry(simpleclientRegistry)
74+
.register(prometheusRegistry);
6475
```
6576

6677
## Refactoring the Instrumentation Code
6778

68-
If you decide to get rid of the old 0.16.0 dependencies and use 1.0.0 only, you need to refactor your code:
79+
If you decide to get rid of the old 0.16.0 dependencies and use 1.0.0 only, you need to refactor
80+
your code:
6981

7082
Dependencies:
7183

@@ -74,8 +86,10 @@ Dependencies:
7486
- `simpleclient_httpserver` -> `prometheus-metrics-exporter-httpserver`
7587
- `simpleclient_servlet_jakarta` -> `prometheus-metrics-exporter-servlet-jakarta`
7688

77-
As long as you are using high-level metric API like `Counter`, `Gauge`, `Histogram`, and `Summary` converting code to
78-
the new API is relatively straightforward. You will need to adapt the package name and apply some minor changes like
89+
As long as you are using high-level metric API like `Counter`, `Gauge`, `Histogram`, and `Summary`
90+
converting code to
91+
the new API is relatively straightforward. You will need to adapt the package name and apply some
92+
minor changes like
7993
using `builder()` instead of `build()` or using `labelValues()` instead of `labels()`.
8094

8195
Example of the old 0.16.0 API:
@@ -106,14 +120,20 @@ Counter counter = Counter.builder()
106120
counter.labelValues("/hello-world").inc();
107121
```
108122

109-
Reasons why we changed the API: Changing the package names was a necessity because the previous package names were
110-
incompatible with the Java module system. However, renaming packages requires changing code anyway, so we decided to
111-
clean up some things. For example, the name `builder()` for a builder method is very common in the Java ecosystem, it's
112-
used in Spring, Lombok, and so on. So naming the method `builder()` makes the Prometheus library more aligned with the
123+
Reasons why we changed the API: Changing the package names was a necessity because the previous
124+
package names were
125+
incompatible with the Java module system. However, renaming packages requires changing code anyway,
126+
so we decided to
127+
clean up some things. For example, the name `builder()` for a builder method is very common in the
128+
Java ecosystem, it's
129+
used in Spring, Lombok, and so on. So naming the method `builder()` makes the Prometheus library
130+
more aligned with the
113131
broader Java ecosystem.
114132

115-
If you are using the low level `Collector` API directly, you should have a look at the new callback metric types,
116-
see [/getting-started/callbacks/]({{< relref "../getting-started/callbacks.md" >}}). Chances are good that the new callback metrics have
133+
If you are using the low level `Collector` API directly, you should have a look at the new callback
134+
metric types,
135+
see [/getting-started/callbacks/]({{< relref "../getting-started/callbacks.md" >}}). Chances are
136+
good that the new callback metrics have
117137
an easier way to achieve what you need than the old 0.16.0 code.
118138

119139
## JVM Metrics

docs/content/otel/names.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ weight: 3
55

66
OpenTelemetry naming conventions are different from Prometheus naming conventions. The mapping from
77
OpenTelemetry metric names to Prometheus metric names is well defined in
8-
OpenTelemetry's [Prometheus and OpenMetrics Compatibility](https://opentelemetry.io/docs/specs/otel/compatibility/prometheus_and_openmetrics/)
8+
OpenTelemetry's [Prometheus and OpenMetrics Compatibility](https://opentelemetry.io/docs/specs/otel/compatibility/prometheus_and_openmetrics/) <!-- editorconfig-checker-disable-line -->
99
spec, and
10-
the [OpenTelemetryExporter](/client_java/api/io/prometheus/metrics/exporter/opentelemetry/OpenTelemetryExporter.html)
10+
the [OpenTelemetryExporter](/client_java/api/io/prometheus/metrics/exporter/opentelemetry/OpenTelemetryExporter.html) <!-- editorconfig-checker-disable-line -->
1111
implements that specification.
1212

1313
The goal is, if you set up a pipeline as illustrated below, you will see the same metric names in
1414
the Prometheus server as if you had exposed Prometheus metrics directly.
1515

16-
![Image of a with the Prometheus client library pushing metrics to an OpenTelemetry collector](/client_java/images/otel-pipeline.png)
16+
![Image of a with the Prometheus client library pushing metrics to an OpenTelemetry collector](/client_java/images/otel-pipeline.png) <!-- editorconfig-checker-disable-line -->
1717

1818
The main steps when converting OpenTelemetry metric names to Prometheus metric names are:
1919

@@ -25,7 +25,7 @@ The main steps when converting OpenTelemetry metric names to Prometheus metric n
2525

2626
OpenTelemetry defines not only a line protocol, but also _semantic conventions_, i.e. standardized
2727
metric and label names. For example,
28-
OpenTelemetry's [Semantic Conventions for HTTP Metrics](https://opentelemetry.io/docs/specs/otel/metrics/semantic_conventions/http-metrics/)
28+
OpenTelemetry's [Semantic Conventions for HTTP Metrics](https://opentelemetry.io/docs/specs/otel/metrics/semantic_conventions/http-metrics/) <!-- editorconfig-checker-disable-line -->
2929
say that if you instrument an HTTP server with OpenTelemetry, you must have a histogram named
3030
`http.server.duration`.
3131

0 commit comments

Comments
 (0)