Skip to content

Basics

The Exot Inspector integration can be initiated with just a few simple steps, primarily by creating an instance of the Inspector class.

import { Inspector } from '@exotjs/inspector';
import { MemoryStore } from '@exotjs/inspector/store';
const inspector = new Inspector({
store: new MemoryStore(),
});

This code initializes an instance of the Inspector, configuring it to use a MemoryStore as its storage backend. With this setup, all instruments are automatically activated. These instruments are versatile tools for recording and querying various types of data. For further details on specific instruments such as Metrics, Logs, Traces, please consult the documentation.

Connecting the App

To link your server with the Inspector Application, you need to create a WebSocket server.

Typically, when a WebSocket connection is established on the server, you should create a new session using the inspector.createSession() function and then attach relevant message handlers.

webSocketServer.on('connection', (ws, req) => {
const session = inspector.createSession({
remoteAddress: req.socket.remoteAddress,
});
session.on('message', (data) => {
ws.send(data);
});
ws.on('close', () => {
session.destroy();
});
ws.on('message', (message) => {
session.handleMessage(message);
});
});

In this code snippet, upon establishing a WebSocket connection, a session is created using contextual information such as the remote address. Message handlers are then attached to facilitate communication between the server and the connected WebSocket client.

Frameworks

Exot Inspector seamlessly integrates with popular frameworks: