otel_web_socket_channel 0.1.0
otel_web_socket_channel: ^0.1.0 copied to clipboard
OpenTelemetry instrumentation for `package:web_socket_channel`. Wraps a channel to emit a connection-lifetime span, opt-in per-frame events and `messaging.*` semconv attributes.
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.1.0 - 2026-08-10 #
Added #
OTelWebSocketChannel— wraps anyWebSocketChanneland opens a single connection-lifetimeCLIENTspan. Setsmessaging.system=websocket,url.*/server.*info, the negotiated subprotocol, and close-code / close-reason on the way out.- Connection-failure path: if the inner channel's
readyfuture errors, the span is flipped to Error viarecordException+setStatus(Error)in OTel-spec order. - Stream-error path: an error on the inbound stream also marks the
span Error and surfaces
error.type. OTelWebSocketChannel.connect(uri)factory: convenience that callsWebSocketChannel.connectand wraps the result.- Per-frame events (opt-in via
recordFrames: true): eachsink.addand inbound message emits awebsocket.send/websocket.receivechild span carrying frame type and size. WebSocketSemantics— typed attribute-key enum implementingOTelSemantic, package-local pending the upstream OTel messaging-spec websocket sub-spec.runWithoutWebSocketInstrumentation/runWithoutWebSocketInstrumentationAsync— zone-scoped suppression helpers, mirroringdartastic_grpc_otelanddartastic_http_otel. Preemptive: the dartastic SDK doesn't use websockets for export today, but log streaming over websockets is a plausible future and the recursion shape would be identical.- 5 unit tests pin: happy path with full attribute set + close codes, server-initiated close, handshake failure, per-frame spans (both text + binary), and the suppression scope.