otel_shelf 0.1.0 copy "otel_shelf: ^0.1.0" to clipboard
otel_shelf: ^0.1.0 copied to clipboard

OpenTelemetry instrumentation for `package:shelf`. Middleware that opens a SERVER span per request, extracts the inbound W3C traceparent and records `http.*` semconv attributes.

otel_shelf #

OpenTelemetry instrumentation for package:shelf — server-side complement to the various client-side wrappers (http, dio, grpc, chopper). One SERVER span per incoming request, with W3C traceparent extracted from inbound headers so distributed traces stitch end-to-end.

import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart' as io;
import 'package:otel_shelf/otel_shelf.dart';

final handler = const Pipeline()
    .addMiddleware(otelShelfMiddleware())
    .addHandler(myRouter);

await io.serve(handler, 'localhost', 8080);

Each request:

  • name: HTTP <METHOD> (URL is on url.full, kept off the name for cardinality)
  • kind: SERVER
  • http.request.method, url.full, server.address, server.port, http.response.status_code
  • 5xx → span status Error. 4xx unset by default (per OTel HTTP semconv — override with errorStatusBuilder).

Trace propagation #

Extracts the W3C traceparent (and optional tracestate) from inbound headers. A client using otel_http, otel_dio, or otel_chopper injects those headers automatically, and this middleware stitches the server span into the same trace.

Suppression: runWithoutShelfInstrumentationAsync.

License #

Apache 2.0

0
likes
160
points
67
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

OpenTelemetry instrumentation for `package:shelf`. Middleware that opens a SERVER span per request, extracts the inbound W3C traceparent and records `http.*` semconv attributes.

Homepage
Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

dartastic_opentelemetry, dartastic_opentelemetry_api, shelf

More

Packages that depend on otel_shelf