Skip to content

Traces and metrics — the deferred half of @btravstack/observability #64

Description

@btravers

From a gap analysis against NestJS and AdonisJS.

packages/observability/CLAUDE.md and the root CLAUDE.md's Deferred, deliberately section already describe this; opening it as an issue so it is trackable rather than only narrated.

The package is named for the whole because logs, traces and metrics share a correlation id, a resource, a config slice and a flush-on-shutdown lifecycle. Only the logging half ships. The root CLAUDE.md is explicit that the rest must never be described as shipped.

The shape is already written down in packages/observability/CLAUDE.md: Tracer / Meter ports, the OTel NodeSDK as a resourceful provider whose release flushes, a span per unit through StartOptions.unit, and W3C traceparent feeding UnitMeta.traceId in the three transport starters — which is the piece that makes a trace started elsewhere join a trace here, and is why traceId is a runtime-suppliable field in the first place.

Two things make this more than a port to write:

  • The flush-on-shutdown lifecycle is the kernel's problem, and the kernel already solves it. A resourceful provider's release runs on every exit path including startup failure, and the drain's three beats give a real window to flush in. Getting spans out before the process dies is the part most OTel integrations get wrong; here the primitive exists.
  • The auto-instrumentation constraint noted in the package's own CLAUDE.md does not go away, and should be settled before the port is written rather than after.

Acceptance

  • Tracer and Meter ports with an OTel-backed provider, flushing through release.
  • A span per kernel unit, correlated with the same traceId the logger already stamps.
  • traceparent honoured inbound by @btravstack/http, @btravstack/amqp and @btravstack/temporal, feeding UnitMeta.traceId.
  • The Deferred, deliberately entries in the root and package CLAUDE.md removed when it lands — and until then, still never described as shipped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Wanted, not urgentenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions