opentelemetry-instrumentation-express is an enhanced instrumentation library for the `express` web framework, designed to integrate seamlessly with OpenTelemetry for Node.js applications. Currently at version 0.41.0, it is actively maintained and part of the `aspecto-io/opentelemetry-ext-js` project, which sees frequent updates. This package differentiates itself from the standard `@opentelemetry/instrumentation-express` by providing more granular and accurate route information through custom span attributes like `express.route.full`, `express.route.configured`, and `express.route.params`, which capture the full path and parsed parameters. It also tracks `express.unhandled` requests, offering better insights into unhandled routes and 404s. The instrumentation supports Express versions `^4.9.0` and is suitable for detailed tracing of Express applications where precise route context is crucial for observability.
npm install opentelemetry-instrumentation-expressVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to set up and register the ExpressInstrumentation with a NodeTracerProvider to automatically trace Express routes, including custom options.
Ensure your `express` dependency is within the `^4.9.0` range. Monitor for updates to this instrumentation that explicitly add Express v5.x support.
Choose one Express instrumentation library and ensure only one is installed and registered in your application. This package provides enhanced route attribute capturing.
When analyzing traces, understand the nuances of `http.route` and leverage the `express.route.full`, `express.route.configured`, and `express.route.params` attributes for a comprehensive understanding of the Express route.
Ensure `tracerProvider.register()` is called after creating your `NodeTracerProvider` instance to initialize the global tracer provider.
Verify that `registerInstrumentations` is called with `ExpressInstrumentation`, that a `tracerProvider` is registered, and that your `express` package version is `^4.9.0`. Ensure OpenTelemetry environment variables (e.g., `OTEL_SERVICE_NAME`) are correctly set.
The specific matched parameter values for a request are available in the `express.route.params` attribute (as a JSON stringified map). For the full resolved path, consider `express.route.full`.