otel_http 0.2.0 copy "otel_http: ^0.2.0" to clipboard
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 legacy http.method).
  • Dependency floors raised to dartastic_opentelemetry ^1.1.0-beta.12 and dartastic_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.
  • repository URL corrected to the canonical Dartastic org casing so pub.dev repository verification succeeds.

Added #

  • ignoreUrlPatterns — URL patterns (substring or RegExp) 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 — a http.BaseClient that wraps another http.Client and emits a CLIENT-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 / baggage headers injected into outbound requests so downstream services join the same trace.

  • 4xx / 5xx responses flip span status to Error. Thrown exceptions trigger recordException (with stack trace) and setStatus(Error), in OTel-spec order, with error.type set to the exception's runtime class.

  • URL userInfo (https://alice:secret@host/...) is redacted in url.full per the OTel HTTP semconv guidance.

  • spanNameBuilder constructor option for callers that know a URL template (recommended span name is {METHOD} {url-template}).

  • runWithoutHttpInstrumentation / runWithoutHttpInstrumentationAsync — zone-scoped suppression helpers. OTelHttpClient.send checks 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 uses package:http itself, so wrapping an exporter call in this helper prevents the export-creates-span-creates- export loop. Matches the pattern used by dartastic_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.

0
likes
160
points
72
downloads

Documentation

API reference

Publisher

verified publisherdartastic.io

Weekly Downloads

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.

Homepage
Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

dartastic_opentelemetry, dartastic_opentelemetry_api, http

More

Packages that depend on otel_http