express-opentracing provides middleware for Express.js applications to instrument incoming HTTP requests using the OpenTracing API. This allows developers to integrate distributed tracing into their Express routes, creating spans for requests and associating them with a configured OpenTracing-compatible tracer. The package is currently at version 0.1.1 and appears to be unmaintained, with its last commit occurring several years ago. Crucially, the underlying OpenTracing project itself has been officially deprecated and archived since 2019, having merged with OpenCensus to form OpenTelemetry. OpenTelemetry is now the recommended, actively developed standard for comprehensive observability, encompassing traces, metrics, and logs. Users are strongly advised to migrate from OpenTracing-based solutions to OpenTelemetry for ongoing support, features, and security.
npm install express-opentracingVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `express-opentracing` into an Express.js application using a basic `MockTracer` for logging. It shows how to initialize the middleware and access the request span within a route handler.
Migrate your observability instrumentation to OpenTelemetry. This will require replacing `express-opentracing` with an OpenTelemetry Express instrumentation package (e.g., `@opentelemetry/instrumentation-express`) and adopting the OpenTelemetry SDK.
As with the OpenTracing deprecation, the primary fix is to migrate to OpenTelemetry-based solutions that are actively maintained and compatible with modern JavaScript ecosystems.
Ensure `opentracing` is installed at a compatible version. However, given the project's status, the recommended long-term solution is migration to OpenTelemetry.
Always explicitly pass an initialized tracer instance (e.g., from Jaeger, LightStep, or a MockTracer for testing) to the middleware options: `app.use(middleware({ tracer: myTracer }));`.Install the `opentracing` package: `npm install opentracing` or `yarn add opentracing`.
Ensure a valid `Tracer` instance is passed in the middleware options: `app.use(middleware({ tracer: myTracer }));`. If using `opentracing.initGlobalTracer()`, ensure it's called before `express-opentracing` is initialized.