Metrics
The transport has a Meter named Elastic.Transport (OpenTelemetry.ElasticTransportMeterName, the same name as its ActivitySource). It measures what sits above a single HTTP request, because HttpClient already measures the request itself.
// OpenTelemetry SDK
builder.Services.AddOpenTelemetry().WithMetrics(m => m
.AddMeter(OpenTelemetry.ElasticTransportMeterName)
.AddMeter("System.Net.Http", "System.Net.NameResolution"));
- what the transport measures
- what HttpClient measures
With no listener subscribed nothing is timed and nothing is recorded: a request allocates what it did before.
| You want to know | Look at | From |
|---|---|---|
| How long one HTTP request took, its status, why it failed | http.client.request.duration (http.response.status_code, error.type) |
HttpClient |
| Requests in flight, open connections, how long a connection lived, time in the queue | http.client.active_requests, open_connections, connection.duration, request.time_in_queue |
HttpClient |
| How long a DNS lookup took | dns.lookup.duration |
the runtime |
| How long a request through the transport took, retries and failover included, and how it ended | elastic.transport.request.duration (outcome) |
the transport |
| How many nodes a request needed (1 means no retry) | elastic.transport.request.attempts |
the transport |
| How often a node is taken out of rotation, and which | elastic.transport.node.dead (server.address, server.port) |
the transport |
| How many nodes are usable right now | elastic.transport.nodes (state = alive or dead) |
the transport |
| How pings and sniffs are doing, apart from API calls | elastic.transport.cluster.operations (operation = ping or sniff, outcome) |
the transport |
HttpClient counts a ping and a sniff as any other HTTP request, and does not know a request was a retry of another or that a node was marked dead. The transport does. The transport's metrics also work when the invoker is not HttpClient: HttpWebRequestInvoker on .NET Framework, InMemoryRequestInvoker in tests, or your own IRequestInvoker.
| Name | Type, unit | Tags |
|---|---|---|
elastic.transport.request.duration |
histogram, s |
outcome: success, or the name of the PipelineFailure (BadResponse, BadRequest, BadAuthentication, MaxRetriesReached, MaxTimeoutReached, NoNodesAttempted, Unexpected, ...) |
elastic.transport.request.attempts |
histogram, {attempt} |
outcome, as above. Counts nodes attempted for the API call; pings and sniffs are separate |
elastic.transport.node.dead |
counter, {node} |
server.address, server.port |
elastic.transport.nodes |
observable gauge, {node} |
state: alive or dead. Summed over the node pools of the transports in the process |
elastic.transport.cluster.operations |
counter, {operation} |
operation: ping or sniff; outcome: success, PingFailure, SniffFailure, or BadAuthentication for a ping |
A request that fails without throwing (ThrowExceptions off) is recorded as the failure it is. Tags never carry a URL, path or body, so their cardinality is bounded by the number of nodes and PipelineFailure values.
Anything per HTTP request (duration, status, connections, DNS) is http.client.* and dns.*; a test fails the build if the transport's meter ever contains an instrument with one of those prefixes. Request and response body sizes are not emitted by HttpClient either, and are not measured here yet: open an issue if you need them.