Registry / devops / axios-opentracing

axios-opentracing

JSON →
library0.1.3jsnpmunverified

Axios interceptor that wraps HTTP requests with OpenTracing spans for distributed tracing. Version 0.1.3 requires peer dependencies axios ^0.18.0 and opentracing ^0.14.0 (both outdated). Ships TypeScript definitions. Allows either passing an existing span or creating a child span with a given name. Supports any OpenTracing-compatible tracer (Jaeger, Elastic APM, Lightstep). Provides a function that applies request/response interceptors to an axios instance. Low maintenance; last release 4 years ago.

npm install axios-opentracing
INSTALL
IMPORT
SIG · AXIOS-OPENTRACING
A
axios-opentracing
devopsjavascriptv0.1.3
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.

default
import createAxiosTracing from 'axios-opentracing'
const createAxiosTracing = require('axios-opentracing')
The package uses CommonJS exports but ships TypeScript types; named import does not work.
createAxiosTracing
import createAxiosTracing from 'axios-opentracing'
import { createAxiosTracing } from 'axios-opentracing'
The package exports a single function as default. Named import will be undefined.
type definitions
import createAxiosTracing from 'axios-opentracing'
import axiosOpentracing from 'axios-opentracing'; const applyTracing = axiosOpentracing.default
With TypeScript, default import works directly; no need to access .default.

Create an axios instance, apply tracing interceptors with a root span, and make a request.

import axios from 'axios'; import createAxiosTracing from 'axios-opentracing'; import opentracing from 'opentracing'; // Assume tracer is already initialized (e.g., Jaeger) const tracer = opentracing.globalTracer(); const applyTracingInterceptors = createAxiosTracing(tracer); const api = axios.create({ baseURL: 'https://api.example.com' }); // Start root span const rootSpan = tracer.startSpan('http_call'); // Apply interceptors applyTracingInterceptors(api, { span: rootSpan }); // Make requests api.get('/endpoint').then(() => { rootSpan.finish(); }).catch(err => console.error(err));
Debug
Known issues
deprecatedPeer dependencies axios ^0.18.0 and opentracing ^0.14.0 are outdated. Use with newer versions may cause incompatibilities.
fix
Pin axios to 0.18.x and opentracing to 0.14.x, or use a different tracing library.
affects: >=0.1.0
gotchaThe library does not handle span lifecycle automatically; spans must be finished manually.
fix
Ensure rootSpan.finish() is called after all requests complete, or use a wrapper that does so.
affects: >=0.1.0
gotchaWhen using global tracer via createAxiosTracing() with no arguments, opentracing.globalTracer() must be set before calling applyTracingInterceptors.
fix
Initialize global tracer via opentracing.initGlobalTracer() before calling createAxiosTracing().
affects: >=0.1.0
Errors
Common errors & fixes
Cannot read property 'addTags' of undefined
applyTracingInterceptors was called without passing a span or spanName in options.
fix
Provide options object with either 'span' or 'spanName' property.
TypeError: createAxiosTracing is not a function
Attempted to import named export instead of default.
fix
Use import createAxiosTracing from 'axios-opentracing' (default import).
Module not found: Can't resolve 'axios-opentracing'
Missing npm install or incorrect import path.
fix
Run npm install axios-opentracing axios opentracing.
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies
axiosrequiredpeer dependency for HTTP requests
opentracingrequiredpeer dependency for tracing API
Agent activity
13 hits · last 30 days
node
10
Amazon
1
OpenAI (training)
1
Resources
axios-opentracing — npm install axios-opentracing · libregistry