Repository navigation
OpenTelemetry tracing and metrics #264
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or requestroadmapPart of the project roadmapPart of the project roadmap
Milestone
Description
Context
Only correlationId exists today, with no tracing or metrics. #322 adds messageId, sentAt and endpointName; #263 adds middleware and a headers bag that every transport carries.
This is also the foundation for the dashboard in Phase 4.
Decisions
Answered by the maintainer:
- A separate package,
@node-ts/bus-opentelemetry, with only@opentelemetry/apias a peer dependency. Core stays dependency-free, and churn in the messaging semantic conventions stays out of core.
Proposed:
- One function,
openTelemetry(options?), returns the{ incoming, handler, outgoing }middleware to pass towithMiddleware(). No classes, no global registration; each bus is instrumented separately. - Trace context is propagated as W3C
traceparent/tracestatein theheadersbag. - Semantic conventions. Span and metric names and attributes follow the OpenTelemetry messaging conventions. Those aren't stable yet, so the names are kept in one file, pinned to one version of the conventions.
Non-goals
- Queue-depth metrics. They're transport-specific and move to Monitoring dashboard: failed messages, endpoint health and workflow inspection #270.
- SDK and exporter setup.
- A logs bridge.
- Baggage.
- An
@opentelemetry/instrumentationauto-instrumentation plugin.
Approach
- Spans:
- Outgoing middleware: a PRODUCER span
send <$name>orpublish <$name>, which injects the context intoheaders. - Incoming middleware: a CONSUMER span
process <$name>, a child of the extracted context. - Per-handler middleware: an INTERNAL span per handler or workflow, named after it.
- Errors are recorded on the span.
- Attributes:
messaging.system,messaging.destination.name,messaging.message.id(messageId) andmessaging.message.conversation_id(correlationId).
- Outgoing middleware: a PRODUCER span
- Metrics: process duration, plus sent, consumed, failed and retried counts, plus critical time (time since
sentAt). Failed and retried come from the outcome of Configurable recoverability policy and error queue with failure metadata #262's recoverability policy once it has landed; until then, failed only.
Acceptance criteria
- A test with an in-memory span exporter shows send → process → handler parentage and the semantic-convention attributes
- Trace context propagates over every transport (the
headersround trip intransportTests, added by Incoming and outgoing pipeline behaviours (middleware) #263) - Metrics recorded and tested with an in-memory metric reader
- Package published with the same packaging as the others (
check:packages); docs page/guide/opentelemetry; changeset
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestroadmapPart of the project roadmapPart of the project roadmap
Activity