@sophonz/instrumentation-websocket
v0.0.9
Published
Readme
@sophonz/instrumentation-websocket
OpenTelemetry instrumentation for WebSocket connections, including send/receive and lifecycle events.
Part of the Sophonz OpenTelemetry suite.
Install
bun add @sophonz/instrumentation-websocket
# or
pnpm add @sophonz/instrumentation-websocket
# or
npm install @sophonz/instrumentation-websocketUsage
import { SophonzWebSocketInstrumentation } from '@sophonz/instrumentation-websocket';
const instrumentation = new SophonzWebSocketInstrumentation({
ignoreUrls: ['/health'], // optional URL patterns to exclude
screenNameOption: { /* optional */ }
});
instrumentation.enable();
// WebSocket connections are now instrumented
const ws = new WebSocket('wss://example.com/stream');
ws.send('message'); // traced
ws.addEventListener('message', (event) => {
// traced
});API
SophonzWebSocketInstrumentation- Main instrumentation classSophonzWebSocketInstrumentationConfig- ConfigurationignoreUrls?: (string | RegExp)[]- URLs to exclude from tracingscreenNameOption?: ScreenNameOption- Screen name detection
Peer dependencies
@opentelemetry/api@opentelemetry/instrumentation@opentelemetry/core
License
See LICENSE in this package.
Part of sophonz-js.
