@cisco-telescope/auto-instrumentations-node
v2.3.8
Published
Cisco auto instrumentations for OpenTelemetry
Downloads
10
Readme
Cisco Auto Node Instrumentations
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:
| Parameter | Env | Type | Default | Description |
| --------------- | ---------------------- | ------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| payloadsEnabled | CISCO_PAYLOADS_ENABLED | boolean | true
| Whether the span should include paylaods or not according to this list. |
| maxPayloadSize | MAX_PAYLOAD_SIZE | int | 1024 | Max payload size to collect per attribute |
License
APACHE 2.0 - See LICENSE for more information.