nhttp_otel (nhttp v1.0.0)
View SourceOpenTelemetry integration for nhttp server.
Provides distributed tracing (spans) and metrics for connection and request lifecycle events. Telemetry is configurable via the otel option in server settings.
Configuration:
otel => #{traces => true, metrics => true}- Enable bothotel => true- Shorthand for bothotel => false- Disabled (default)
Spans follow HTTP semantic conventions:
- Connection span: long-lived, parent of request spans
- Request spans: method, path, status, duration
Active requests counter:
Use nhttp_otel:active_requests/0 to query the current count of
in-flight requests across all connections.
Summary
Functions
Get the current count of active (in-flight) requests. Returns 0 if the counter hasn't been initialized.
Parse otel configuration from server options.
Types
-type conn_attrs() :: #{version := nhttp_lib:version(), remote_ip := inet:ip_address(), remote_port := inet:port_number(), server_port => inet:port_number(), transport := tcp | ssl | udp}.
-type conn_end_attrs() :: #{reason := atom(), requests := non_neg_integer()}.
-type req_attrs() :: #{method := binary(), path := binary(), scheme := binary(), stream_id := non_neg_integer()}.
-type req_end_attrs() :: #{response_body_size => non_neg_integer(), status := 100..599}.
-type span_ctx() :: opentelemetry:span_ctx() | undefined.
Functions
-spec active_requests() -> non_neg_integer().
Get the current count of active (in-flight) requests. Returns 0 if the counter hasn't been initialized.
Parse otel configuration from server options.