telemetry-js
JS opentelemetry library for Dialpad applications. This library can be used to send metrics data to a collector.
Methods
- init
- initialized
- addApplicationLabels
- This method add application level labels
labels = { key : value }
- clearApplicationLabels
- This method clears application level labels
None
- add
- record
Sample Code
import { Otel as otel } from '@dialpad/telemetry-js';
otel.init({
url: config.otelUrl,
authToken: config.otelAuthToken
});
otel.record({
name: 'outbound_call.ui.prepare_to_dial',
val: 20,
labels: {},
unit: 'ms',
});
Custom Exporter
Custom exporter class is used to override the metrics payload. This is required
to support the latest version of metrics payload as optelemetry-js is not compatible with latest version.
Refer: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/datamodel.md
TODO: Remove this custom exporter when opentelemetry-js support latest data model.
Custom Processor
This class is used to change the behavior of the processor class so we do not send duplicate metrics after certain attempt.
TODO: Figure out a way to clear the record from otel library which will help us to reduce the memory footprint. There is a lot of work going on currently with the
otel metrics module and need to revisit this later.