{"id":18945,"library":"zipkin-instrumentation-express","title":"Zipkin Express Instrumentation","description":"Express middleware for distributed tracing with Zipkin.js. Version 0.22.0 is current stable, released as part of the openzipkin/zipkin-js monorepo with irregular release cadence. This package provides middleware that creates Zipkin spans for incoming HTTP requests to Express applications, automatically recording timing, tags, and annotations. Key differentiators: minimal configuration, tight integration with Zipkin's B3 propagation headers, support for custom sampler and tracer configurations. Suitable for Node.js Express apps requiring observability via Zipkin. Note: Not actively maintained (last release 0.22.0).","status":"maintenance","version":"0.22.0","language":"javascript","source_language":"en","source_url":"https://github.com/openzipkin/zipkin-js","tags":["javascript","typescript"],"install":[{"cmd":"npm install zipkin-instrumentation-express","lang":"bash","label":"npm"},{"cmd":"yarn add zipkin-instrumentation-express","lang":"bash","label":"yarn"},{"cmd":"pnpm add zipkin-instrumentation-express","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core Zipkin library required for tracer creation","package":"zipkin","optional":false},{"reason":"Peer dependency for instrumentation to work with Express app","package":"express","optional":false}],"imports":[{"note":"ESM and CommonJS both supported; TypeScript types included.","wrong":"const expressMiddleware = require('zipkin-instrumentation-express')","symbol":"expressMiddleware","correct":"import { expressMiddleware } from 'zipkin-instrumentation-express'"},{"note":"Package has a default export as well as named export; both work.","wrong":"import { expressMiddleware as default } from 'zipkin-instrumentation-express'","symbol":"expressMiddleware (default)","correct":"import expressMiddleware from 'zipkin-instrumentation-express'"}],"quickstart":{"code":"import { Tracer, BatchRecorder, jsonEncoder } from 'zipkin';\nimport { HttpLogger } from 'zipkin-transport-http';\nimport { expressMiddleware } from 'zipkin-instrumentation-express';\nimport express from 'express';\n\nconst tracer = new Tracer({\n  recorder: new BatchRecorder({\n    logger: new HttpLogger({\n      endpoint: process.env.ZIPKIN_ENDPOINT || 'http://localhost:9411/api/v2/spans',\n      jsonEncoder: jsonEncoder.JSON_V2\n    })\n  }),\n  localServiceName: 'my-service'\n});\n\nconst app = express();\napp.use(expressMiddleware({ tracer }));\n\napp.get('/', (req, res) => res.send('Hello tracing!'));\napp.listen(3000);","lang":"typescript","description":"Sets up Zipkin tracing middleware for Express app using batch recorder and HTTP transport."},"warnings":[{"fix":"Use import instead of require() for all zipkin packages.","message":"Require-style import of zipkin modules may break in future versions; prefer ESM imports.","severity":"deprecated","affected_versions":">=0.22.0"},{"fix":"Ensure the middleware is applied before app.get(), app.post(), etc.","message":"expressMiddleware must be added before route handlers to trace all requests.","severity":"gotcha","affected_versions":">=0.16.0"},{"fix":"Provide localServiceName when creating Tracer instance.","message":"Tracer's localServiceName must be set; otherwise, spans may be missing service name.","severity":"gotcha","affected_versions":">=0.19.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure Tracer is initialized with a valid sampler and recorder.","cause":"Incorrect or missing tracer configuration leads to invalid Zipkin trace IDs.","error":"Error: Must be valid TraceId instance"},{"fix":"Call expressMiddleware({ tracer }) where tracer is a valid Zipkin Tracer instance.","cause":"expressMiddleware() called without options object or missing tracer property.","error":"TypeError: Cannot destructure property 'tracer' of 'undefined' or 'null'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}