@totalsoft/opentelemetry-instrumentation-ws
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

opentelemetry-instrumentation-ws

This package provides opentelemetry instrumentation for ws library.

Installation

npm i @totalsoft/opentelemetry-instrumentation-ws

or

yarn add @totalsoft/opentelemetry-instrumentation-ws

Usage

const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { WSInstrumentation } = require('@totalsoft/opentelemetry-instrumentation-ws');

const provider = new NodeTracerProvider();
provider.register();

registerInstrumentations({
  instrumentations: [
    new WSInstrumentation(),
  ],
});

Config

The ws instrumentation has few options available to choose from. You can set the following:

Options Type Description
generateSendSpans boolean should the tracing library add spans for each sent message. Default: false
generateReceiveSpans boolean should the tracing library add spans for each incoming message. Default: false
sendHook (span: Span, hookInfo: HookInfo) => void hook for adding custom attributes to the ws send span when a websocket sends a message
closeHook (span: Span, hookInfo: HookInfo) => void hook for adding custom attributes to the ws close span when a websocket is imperatively closed
handleUpgradeHook (span: Span, hookInfo: HookInfo) => void hook for adding custom attributes to the ws.Server handleUpgrade span when a socket is opened against a server
maxMessageLength number max message length in the message attribute. "..." is added to the end when the message is truncated. Set 0 to omit the message attribute. Default: 1022.

Readme

Keywords

Package Sidebar

Install

npm i @totalsoft/opentelemetry-instrumentation-ws

Weekly Downloads

165

Version

2.0.0

License

MIT

Unpacked Size

108 kB

Total Files

25

Last publish

Collaborators

  • osstotalsoft