Apache HttpComponents – Observability (Micrometer (original) (raw)

Observability (Micrometer / OpenTelemetry)

Since 5.6, HttpClient ships an optional module, httpclient5-observation, that plugs straight intoMicrometer (metrics + observations) and can bridge to OpenTelemetry (traces). The goal is simple: give you drop-in visibility of latency, throughput, I/O, connection-pool health, DNS, and TLS—without rewriting application code or coupling the core client to any monitoring stack.

What you get out of the box:

How it fits:

Typical flow:

  1. Add httpclient5-observation and whichever Micrometer bits you actually use (all Micrometer deps can stay optional).
  2. Build your client as usual; call HttpClientObservationSupport.enable(...) on the builder (classic/async/caching variants provided).
  3. (Optional) Bind pool gauges after you’ve attached a pooling connection manager.
  4. (Optional) Wrap your DNS resolver with MeteredDnsResolver and your TLS strategy with MeteredTlsStrategyif you want those timing/outcome meters as well.
  5. (Optional) Bridge the ObservationRegistry to OpenTelemetry to get client spans alongside metrics.

Practical notes:

Nothing is enabled unless you add Micrometer and call the opt-in helpers.

Status: Introduced in 5.6 (@since 5.6). Artifacts are optional; core modules do not depend on Micrometer/OTel.


Dependency

Maven

<dependency>
  <groupId>org.apache.httpcomponents.client5</groupId>
  <artifactId>httpclient5-observation</artifactId>
  <version>5.6-alpha1</version>
</dependency>

## Dependency

**Maven**

```xml
<!-- Required: the optional observability module itself -->
<dependency>
  <groupId>org.apache.httpcomponents.client5</groupId>
  <artifactId>httpclient5-observation</artifactId>
  <version>5.6-alpha1</version>
</dependency>

<!-- Optional: add only if you actually use Micrometer metrics / observations / Prometheus / tracing -->

<dependency>
  <groupId>io.micrometer</groupId>
  <artifactId>micrometer-core</artifactId>
  <version>${micrometer.version}</version>
  <optional>true</optional>
</dependency>

<dependency>
  <groupId>io.micrometer</groupId>
  <artifactId>micrometer-observation</artifactId>
  <version>${micrometer.version}</version>
  <optional>true</optional>
</dependency>

<!-- Choose one or more registries you use (e.g., Prometheus) -->
<dependency>
  <groupId>io.micrometer</groupId>
  <artifactId>micrometer-registry-prometheus</artifactId>
  <version>${micrometer.version}</version>
  <optional>true</optional>
</dependency>

<!-- Optional Micrometer→OpenTelemetry bridge for tracing spans -->
<dependency>
  <groupId>io.micrometer</groupId>
  <artifactId>micrometer-tracing-bridge-otel</artifactId>
  <version>${micrometer.tracing.version}</version>
  <optional>true</optional>
</dependency>