Skip to content

Errors

Error tracking is a critical aspect of maintaining a stable and reliable application. By monitoring errors and exceptions, you can identify and address issues before they impact users.

The errors instrument in the Exot Inspector enables efficient tracking of errors and exceptions within your application, providing valuable insights to identify the root cause of these issues.

Instrument

Access the errors instrument via the errors namespace:

inspector.instruments.errors

Configuration

Configure the errors instrument using the main Inspector configuration options:

const inspector = new Inspector({
instruments: {
errors: {
disabled: false,
},
},
});

Available configuration options:

  • disabled: boolean: Disables the instrument. When disabled, the instrument cannot be activated, and no data will be recorded (default false).

Tracking Errors

To track an error, utilize the push method of the errors instrument. The message of the error is mandatory, while remaining properties are optional.

The labeling, such as “server” for server-side errors or “app” for front-end errors, should be appropriate to the context.

const error = new Error('error message');
inspector.instruments.events.push({
attributes: {
userId: '123',
},
message: error.message,
modules: ['some_module'],
stack: error.stack,
}, 'server');

Alternatively, you can provide an instance of an Error:

const error = new Error('error message');
inspector.instruments.events.push(error, 'app');

Module Detection

The error tracking instrument automatically detects npm modules from the stack trace (if an instance of an Error is provided) and sets the modules property. For example, if an error originates from the stripe npm package, the modules property will contain ["stripe"].

Querying Errors

While you can easily view tracked errors in the Application, sometimes you may need to perform more specific queries. In such cases, utilize the query() function, which is consistent across all instruments.

inspector.instruments.errors.query({
endTime: Date.now(),
startTime: Date.now() - 60000,
});