
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
zipkin-instrumentation-axiosjs
Advanced tools
Library to instrument the axios HTTP-client to support zipkin.
Adds Zipkin tracing support for the axios JS HTTP client library. It supports all features of axios.
npm install zipkin-instrumentation-axiosjs --save
You need to use wrapAxios function to wrap the native axios instance, and the axios instance's type/functions/attributes are not affected. As a result, you can use zipkinAxios the same as axios
For example:
const axios = require('axios');
const wrapAxios = require('zipkin-instrumentation-axiosjs');
const { Tracer, ExplicitContext, ConsoleRecorder } = require('zipkin');
const ctxImpl = new ExplicitContext(); // the in-process context
const recorder = new ConsoleRecorder();
const localServiceName = 'service-a'; // name of this application
const tracer = new Tracer({ ctxImpl, recorder, localServiceName });
const remoteServiceName = 'weather-api'; // name of the application you are
                                         // calling (optional)
const zipkinAxios = wrapAxios(axios, { tracer, remoteServiceName });
zipkinAxios.get('/user?ID=12345')
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });
  let axiosInstance = axios.create({
    baseURL: 'https://some-domain.com/api/',
    timeout: 1000,
    headers: {'X-Custom-Header': 'foobar'}
});
  axiosInstance = wrapAxios(axiosInstance, {tracer, remoteServiceName});
You can intercept requests or responses before they are handled by then or catch.
// Add a request interceptor
axios.interceptors.request.use(function (config) {
    // Do something before request is sent
    return config;
  }, function (error) {
    // Do something with request error
    return Promise.reject(error);
  });
// Add a response interceptor
axios.interceptors.response.use(function (response) {
    // Do something with response data
    return response;
  }, function (error) {
    // Do something with response error
    return Promise.reject(error);
  });
FAQs
Library to instrument the axios HTTP-client to support zipkin.
We found that zipkin-instrumentation-axiosjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.