Registry / devops / zipkin-instrumentation-axiosjs

zipkin-instrumentation-axiosjs

JSON →
library0.22.0jsnpmunverified

Library to instrument the axios HTTP client with Zipkin distributed tracing. Version 0.22.0 is the latest stable release, part of the openzipkin/zipkin-js monorepo. It wraps axios to automatically create and propagate trace headers for outgoing requests. Compared to other Zipkin instrumentations, it is specific to axios and requires both zipkin and axios as peer dependencies. Release cadence is tied to the zipkin-js monorepo; updates are infrequent but stable. Supports ESM and CommonJS via the npm package.

npm install zipkin-instrumentation-axiosjs
INSTALL
IMPORT
SIG · ZIPKIN-INSTRUMENTA
Z
zipkin-instrumentation-axiosjs
devopsjavascriptv0.22.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

wrapAxios
import wrapAxios from 'zipkin-instrumentation-axiosjs'
import { wrapAxios } from 'zipkin-instrumentation-axiosjs'
Default export; named import will not work.
wrapAxios (CJS)
const wrapAxios = require('zipkin-instrumentation-axiosjs')
const { wrapAxios } = require('zipkin-instrumentation-axiosjs')
CommonJS require gives the default export as a single function.
wrapAxios (TypeScript)
import wrapAxios from 'zipkin-instrumentation-axiosjs'
Package includes TypeScript type declarations; default import works.

Shows how to wrap axios with Zipkin tracing using a console recorder. Replace ConsoleRecorder with an actual Zipkin transport for production.

const wrapAxios = require('zipkin-instrumentation-axiosjs'); const axios = require('axios'); const {Tracer, BatchRecorder, ConsoleRecorder} = require('zipkin'); const recorder = new BatchRecorder({ logger: new ConsoleRecorder() }); const tracer = new Tracer({ ctxImpl: new ExplicitContext(), recorder: recorder, localServiceName: 'my-service' }); const tracedAxios = wrapAxios(axios, { tracer, serviceName: 'my-client' }); tracedAxios.get('http://example.com').then(resp => console.log(resp.status));
Debug
Known issues
gotchawrapAxios modifies the axios instance in place; it does not return a new instance and does not undo the instrumentation.
fix
Use a separate axios instance for instrumented vs non-instrumented requests.
affects: *
deprecatedThe package uses deprecated import patterns from zipkin (e.g., ExplicitContext).
fix
Use latest zipkin API if available, or ignore if no other context implementation is provided.
affects: >=0.19.0
gotchaRequires both zipkin and axios as peer dependencies; missing them will cause a runtime error.
fix
Ensure both 'zipkin' and 'axios' are installed and a compatible version.
affects: *
breakingVersion 0.22.0 removed support for Node.js 6 and 8.
fix
Upgrade Node.js to 10 or later.
affects: >=0.22.0
gotchaThe tracer configuration must include a context implementation; otherwise, traces will not be propagated.
fix
Pass an explicit context like ExplicitContext or the CLI context.
affects: *
Errors
Common errors & fixes
TypeError: wrapAxios is not a function
Using named import instead of default import.
fix
Use 'import wrapAxios from ...' or 'const wrapAxios = require(...)'
Error: Cannot find module 'zipkin' (or 'axios')
Missing peer dependency.
fix
Run 'npm install zipkin axios' to install required dependencies.
TypeError: Cannot read property 'record' of undefined
Tracer instance not properly configured with a recorder.
fix
Provide a recorder (e.g., BatchRecorder or ConsoleRecorder) to the Tracer constructor.
Upgrade
Version history
0.22.0latest on npm
Audit
Dependencies
zipkinrequiredcore Zipkin tracing library
axiosrequiredHTTP client to instrument
Agent activity
28 hits · last 30 days
node
24
Resources
zipkin-instrumentation-axiosjs — npm install zipkin-instrumentation-axiosjs · libregistry