Skip to content
Open
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
6 changes: 6 additions & 0 deletions docs/content/exporters/formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ You can exclude the shaded protobuf classes including the
`prometheus-metrics-exposition-formats-no-protobuf` module and excluding the
`prometheus-metrics-exposition-formats` module in your build file.

If you are using the PushGateway in a shaded jar with `minimizeJar=true`, do not use this setup.
The PushGateway loads the protobuf writer implementation via reflection, so the full
`prometheus-metrics-exposition-formats` artifact must stay on the classpath and the relevant
packages must be preserved during shading. See the [PushGateway docs]({{< relref
"./pushgateway.md" >}}) for the recommended Maven Shade configuration.

For example, in Maven:

```xml
Expand Down
34 changes: 33 additions & 1 deletion docs/content/exporters/pushgateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,43 @@ PushGateway pushGateway = PushGateway.builder()
However, this requires that the JVM can validate the server certificate.

If you want to skip certificate verification, you need to provide your own
[HttpConnectionFactory](/client_java/api/io/prometheus/metrics/exporter/pushgateway/HttpConnectionFactory.html).
`HttpConnectionFactory`. See the
[API docs](/client_java/api/io/prometheus/metrics/exporter/pushgateway/HttpConnectionFactory.html).
The `PushGatewayTestApp` in `integration-tests/it-pushgateway` has a complete example of this.

## Configuration Properties

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

## Troubleshooting shaded jars

If you build a shaded jar with the Maven Shade Plugin and `minimizeJar=true`, the PushGateway may
fail at runtime with an error like this:

```text
java.lang.RuntimeException: class
io.prometheus.metrics.expositionformats.PrometheusProtobufWriter is not available
```

This happens because the PushGateway loads the protobuf writer implementation via reflection. The
Maven Shade Plugin does not detect that reflective usage during minimization, so it may strip the
required classes from the final jar.

To avoid this, keep the `prometheus-metrics-exposition-formats` artifact on the classpath and
preserve the protobuf-related packages in your shade configuration:

```xml
<filters>
<filter>
<artifact>io.prometheus:prometheus-metrics-exposition-formats</artifact>
<includes>
<include>io/prometheus/metrics/expositionformats/**</include>
<include>io/prometheus/metrics/shaded/**</include>
</includes>
</filter>
</filters>
```

Alternatively, disable jar minimization for the shaded build.