otel_http 0.2.0
otel_http: ^0.2.0 copied to clipboard
OpenTelemetry instrumentation for `package:http`. Wraps any `http.Client` to emit a CLIENT-kind span per request with HTTP semconv attributes and W3C trace-context injection.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.2.0 - 2026-08-10 #
Changed #
- Semantic conventions updated to the current OTel registry; no
deprecated attribute keys are emitted (only the current
http.request.method, never the legacyhttp.method). - Dependency floors raised to
dartastic_opentelemetry ^1.1.0-beta.12anddartastic_opentelemetry_api ^1.0.0-rc.1. The previous floors declared compatibility with API versions that predate the semconv enums this package uses and could not actually resolve-and-compile. repositoryURL corrected to the canonicalDartasticorg casing so pub.dev repository verification succeeds.
Added #
-
ignoreUrlPatterns— URL patterns (substring orRegExp) excluded from instrumentation entirely (no span, no header injection), e.g. telemetry-upload endpoints — closes the self-instrumentation double-count trap for exporters sharing the client. Zone-scoped suppression remains the call-site tool. -
OTelHttpClient— ahttp.BaseClientthat wraps anotherhttp.Clientand emits aCLIENT-kind span per request with the HTTP semantic-convention attributes set (http.request.method,url.full,url.scheme,url.path,url.query,server.address,server.port,http.request.body.size,user_agent.original,http.response.status_code,http.response.body.size). -
W3C
traceparent/tracestate/baggageheaders injected into outbound requests so downstream services join the same trace. -
4xx / 5xx responses flip span status to
Error. Thrown exceptions triggerrecordException(with stack trace) andsetStatus(Error), in OTel-spec order, witherror.typeset to the exception's runtime class. -
URL
userInfo(https://alice:secret@host/...) is redacted inurl.fullper the OTel HTTP semconv guidance. -
spanNameBuilderconstructor option for callers that know a URL template (recommended span name is{METHOD} {url-template}). -
runWithoutHttpInstrumentation/runWithoutHttpInstrumentationAsync— zone-scoped suppression helpers.OTelHttpClient.sendchecks a zone flag at the top of every call and skips span creation AND header injection when set. Backs the self-recursion guarantee: the SDK's OTLP/HTTP exporter usespackage:httpitself, so wrapping an exporter call in this helper prevents the export-creates-span-creates- export loop. Matches the pattern used bydartastic_grpc_otel. -
10 unit tests covering happy path, header injection, 4xx, 5xx, transport exception, userinfo redaction, body size, custom span name, parent-span inheritance, and the suppression scope. 1 integration test polling an OTLP backend round-trip.
-
Targets
http: ^1.0.0.