@nwire/observability
v0.7.1
Published
Nwire — dispatch tracing middleware. Logger-backed by default, with optional bridge to @opentelemetry/api (declared by the consumer, not by us).
Readme
@nwire/observability
Dispatch tracing — logger-backed by default, OTEL bridge when
@opentelemetry/apiis present.
What it does
Wraps every dispatch in a span. By default emits two structured log lines per dispatch (dispatch.start / dispatch.end with durationMs + ok/error) because ctx.logger already carries envelope ids. If consumers pass an OTEL tracer the middleware ALSO opens a span around next() — @opentelemetry/api stays an optional peer.
Install
pnpm add @nwire/observability
# optional:
pnpm add @opentelemetry/apiQuick start
import { tracingPlugin } from "@nwire/observability";
import { defineApp } from "@nwire/forge";
import { trace } from "@opentelemetry/api"; // optional
defineApp("my-app", {
plugins: [tracingPlugin({ tracer: trace.getTracer("my-app") })],
});Or as middleware:
import { tracingMiddleware } from "@nwire/observability";
app.runtime.use(tracingMiddleware());API surface
tracingPlugin({ tracer?, alwaysLog? })—PluginDefinitionform.tracingMiddleware({ tracer?, alwaysLog? })—DispatchMiddlewareform for ad-hoc wiring.
When to use
Every production app. Pair with @nwire/telemetry-otel for OTLP export to Tempo/Honeycomb/Datadog/GreptimeDB.
Within nwire-app
For developers using this package as part of the Nwire stack — register it via app.use(...) or it auto-wires when you compose createApp({ modules }).
import { createApp } from "@nwire/forge";
const app = createApp({
/* ...config... */
});
// Adapter/plugin wiring happens here when applicable.