opentelemetry-instrumentation-socket.io
opentelemetry-instrumentation-socket.io
npm i opentelemetry-instrumentation-socket.io
opentelemetry-instrumentation-socket.io

opentelemetry-instrumentation-socket.io

js extensions for the open-telemetry project

by aspecto-io

0.34.0 (see all)License:Apache-2.0TypeScript:Not Found
npm i opentelemetry-instrumentation-socket.io
Readme

OpenTelemetry socket.io Instrumentation for Node.js

NPM version

This module provides automatic instrumentation for socket.io.

Installation

npm install --save opentelemetry-instrumentation-socket.io

Usage

For further automatic instrumentation instruction see the @opentelemetry/instrumentation package.

const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { SocketIoInstrumentation } = require('opentelemetry-instrumentation-socket.io');

registerInstrumentations({
  tracerProvider,
  instrumentations: [
    new SocketIoInstrumentation({
      // see under for available configuration
    })
  ]
});

socket.io Instrumentation Options

socket.io instrumentation has few options available to choose from. You can set the following:

OptionsTypeDescription
emitHookSocketIoHookFunctionhook for adding custom attributes before socket.io emits the event
emitIgnoreEventListstring[]names of emitted events to ignore tracing for
onHookSocketIoHookFunctionhook for adding custom attributes before the event listener (callback) is invoked
onIgnoreEventListstring[]names of listened events to ignore tracing for
traceReservedbooleanset to true if you want to trace socket.io reserved events (see https://socket.io/docs/v4/emit-cheatsheet/#Reserved-events)
filterHttpTransportHttpTransportInstrumentationConfigset if you want to filter out the HTTP traces when using HTTP polling as the transport (see below)

HttpTransportInstrumentationConfig

If you use opentelemetry-instrumentation-socket.io alongside instrumentation-http, socket.io might use HTTP polling as the transport method. Therefore, you will see an HTTP span created as the parent of the socket.io span. To filter out those spans; we use HttpTransportInstrumentationConfig.

HttpTransportInstrumentationConfig has a few options available to choose from. You can set the following:

OptionsTypeDescription
httpInstrumentationHttpInstrumentationthe instance of HttpInstrumentation you pass to registerInstrumentations
socketPathstringthe socket.io endpoint path (defaults to /socket.io/)

This extension (and many others) was developed by Aspecto with ❤️

VersionTagPublished
0.34.0
latest
4mos ago
0.0.0-2022-07-11--08-09
alpha
8mos ago
No alternatives found
No tutorials found
Add a tutorial
No dependencies found

Rate & Review

100
No reviews found
Be the first to rate