2.3.8 • Published 2 years ago

@cisco-telescope/auto-instrumentations-node v2.3.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Cisco Auto Node Instrumentations

NPM Published Version Apache License

This module provides a simple way to initialize multiple Node instrumentations, and to get all Cisco additional payloads

NOTE: This is useful for OTel native user who only wants to get our extra data

Installation

npm install --save @cisco-telescope/auto-instrumentations-node

Usage

Cisco OpenTelemetry Auto instrumentations for Node automatically loads instrumentations for Node builtin modules and common packages.

Custom configuration for each of the instrumentations can be passed to the function, by providing an object with the name of the instrumentation as a key, and its configuration as the value.

Also, user can also config the Telescope data collection behavior by passing Options (see Configuration).

// tracing.js

const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const {
  getCiscoNodeAutoInstrumentations,
} = require('@cisco-telescope/auto-instrumentations-node');
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector');
const { Resource } = require('@opentelemetry/resources');
const {
  SemanticResourceAttributes,
} = require('@opentelemetry/semantic-conventions');
const { SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-base');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');

const exporter = new CollectorTraceExporter();
const provider = new NodeTracerProvider({
  resource: new Resource({
    [SemanticResourceAttributes.SERVICE_NAME]: 'basic-service',
  }),
});
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.register();

registerInstrumentations({
  instrumentations: [
    getCiscoNodeAutoInstrumentations(
      {
        // load custom configuration for http instrumentation
        '@opentelemetry/instrumentation-http': {
          applyCustomAttributesOnSpan: span => {
            span.setAttribute('foo2', 'bar2');
          },
        },
      },
      // config Telecope payloads config (All have default values)
      {
        maxPayloadSize: 1337,
      }
    ),
  ],
});

Configuration

Advanced options can be configured as a parameter to the init() method:

ParameterEnvTypeDefaultDescription
payloadsEnabledCISCO_PAYLOADS_ENABLEDbooleantrueWhether the span should include paylaods or not according to this list.
maxPayloadSizeMAX_PAYLOAD_SIZEint1024Max payload size to collect per attribute

License

APACHE 2.0 - See LICENSE for more information.