zipkin-instrumentation-hapi provides middleware for integrating Hapi.js applications with Zipkin for distributed tracing. It enables automatic span creation for incoming requests and outgoing responses, propagating trace context across service boundaries. The current stable version is 0.22.0, released as part of the broader zipkin-js monorepo. Releases appear to be somewhat frequent, often including bug fixes, new transport support (like AWS SQS in v0.21.0), and improvements to instrumentation across various libraries. Key differentiators include its adherence to the OpenZipkin specification and its tight integration within the zipkin-js ecosystem, offering consistent tracing across different frameworks and transport layers.
npm install zipkin-instrumentation-hapiVerified import paths — ran on the pinned version, not inferred.
This example sets up a basic Hapi server with Zipkin tracing enabled, using `hapiInstrumentation`. It demonstrates configuring a `Tracer` with `BatchRecorder` (for production) or `ConsoleRecorder` (for development), and registering the Hapi plugin. It also includes a basic route and an example of creating a custom child span.
Upgrade Node.js to a supported version (e.g., Node.js 10 or higher).
Upgrade Node.js to a supported version (e.g., Node.js 8 or higher, preferably 10+).
Use a consistent version range for all `zipkin-js` related packages, e.g., using `^` or `~` in `package.json`, or explicitly updating all to the latest major release.
Always initialize `Tracer` with a `recorder` (e.g., `BatchRecorder` or `ConsoleRecorder`) and a descriptive `serviceName`.
Upgrade `zipkin-instrumentation-hapi` to version 0.17.1 or newer for robust Hapi 17+ compatibility.
Ensure your build process correctly transpiles the `zipkin-js` library. This was notably fixed in v0.18.6.
Verify that `hapiInstrumentation` is correctly imported and that the `server.register` call adheres to Hapi's plugin registration syntax, including wrapping the plugin in an object `{ plugin: hapiInstrumentation, options: {...} }`.