HttpClient Examples (Observation)

  • Observability quick start (classic)

    This example demonstrates enabling Micrometer observations and metrics on a classic client using HttpClientObservationSupport.enable(...), with a custom MetricConfig (prefix, SLO, percentiles) and a Prometheus scrape.

  • Observability quick start (async)

    This example demonstrates enabling observations and metrics on the async client, firing concurrent requests to show the http.client.inflight{kind=async} gauge and printing a Prometheus scrape.

  • Connection pool gauges (classic)

    This example demonstrates exposing connection pool gauges (<prefix>.pool.leased, <prefix>.pool.available, <prefix>.pool.pending) by binding a pooling manager via ConnPoolMeters.bindTo(...).

  • DNS metrics (classic)

    This example demonstrates wrapping the system DNS resolver with MeteredDnsResolver to record resolution timers and counters for resolve and resolveCanonicalHostname with result and optional host tags.

  • TLS handshake metrics (async)

    This example demonstrates recording TLS handshake latency and outcome counters by wrapping an async TlsStrategy with MeteredTlsStrategy on the connection manager (<prefix>.tls.handshake, <prefix>.tls.handshakes).

  • Span sampling & I/O counters

    This example demonstrates using ObservingOptions.spanSampling to skip observations/metrics for selected URIs and recording request/response byte counters (<prefix>.request.bytes, <prefix>.response.bytes).

  • Tag levels (LOW vs EXTENDED)

    This example demonstrates minimal vs extended metric tagging (adding protocol and target when EXTENDED) using different metric prefixes to avoid label-set clashes.

  • Tracing + metrics (classic, OpenTelemetry bridge)

    This example demonstrates wiring Micrometer ObservationRegistry to OpenTelemetry (in-memory exporter) while recording HttpClient timers/counters, printing an exported span and a Prometheus scrape.