@sophonz/instrumentation-socket.io-client
v0.0.9
Published
Readme
@sophonz/instrumentation-socket.io-client
Instruments Socket.IO client to trace real-time bidirectional communication events, tracking both emitted and received messages with full context propagation.
Part of the Sophonz OpenTelemetry suite.
Install
bun add @sophonz/instrumentation-socket.io-client
# or
pnpm add @sophonz/instrumentation-socket.io-client
# or
npm install @sophonz/instrumentation-socket.io-clientUsage
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { SophonzSocketIoClientInstrumentation } from '@sophonz/instrumentation-socket.io-client';
registerInstrumentations({
instrumentations: [
new SophonzSocketIoClientInstrumentation({
target: 'io', // window.io, or pass the io object directly
screenNameOption: 'full', // optional
}),
],
});The instrumentation patches Socket.IO emit and on methods to create spans for sent and received messages.
API
| Export | Purpose |
|--------|---------|
| SophonzSocketIoClientInstrumentation | Patches Socket.IO client to trace emit() (producer spans) and on() (consumer spans). |
| SocketIoClientInstrumentationConfig | Config with target (string or Socket.IO object) and screenNameOption. |
Peer dependencies
@opentelemetry/api^1.9.1@opentelemetry/instrumentation^0.217.0@opentelemetry/semantic-conventions^1.40.0
License
See LICENSE in this package.
Part of sophonz-js.
