Measure Axios Request Performance & Reliability

In this article, you'll learn how to measure the performance and reliability of your Axios requests.

Prerequisites

Setup Axios interceptors

Now that you've connected your application to Polaris, you can start sending request measurements to Polaris. To do this, you'll need to set up Axios interceptors.

React
import axios from 'axios';
import { measure, Instrument } from '@getpolaris.ai/sdk';

let instrument: Instrument;
axios.interceptors.request.use((config) => {
  instrument = measure('request');
  return config;
});

axios.interceptors.response.use(
  (response) => {
    instrument.done();
    return response;
  },
  (error) => {
    instrument.fail({ error });
    return Promise.reject(error);
});

Now, you can use Axios to make requests. All requests made with Axios will send measurements to Polaris.