Socket
Socket
Sign inDemoInstall

@dialpad/telemetry-js

Package Overview
Dependencies
Maintainers
17
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dialpad/telemetry-js

An open telemetry library to export metrics and traces


Version published
Weekly downloads
0
Maintainers
17
Weekly downloads
 
Created
Source

telemetry-js

JS opentelemetry library for Dialpad applications. This library can be used to send metrics data to a collector.

Methods

  • init
    • This method initialize the otel library and needs to be called before any other method.
      • Parameters
          options = {
              "url" : "<metrics collector endpoint>", 
              "authToken" :  "<API key for authorization>";
          }
          
          // This is an optional parameter. These labels will be set to all instruments.
          labels  = { key : value }.
      
  • initialized
    • This method return whether the library has been initialized or not.
    • Return
      true - initialized
      false - Not initialized
      
  • addApplicationLabels
    • This method add application level labels
      • Parameters
          // These labels will be set to all instruments.
          labels  = { key : value }
      
  • clearApplicationLabels
    • This method clears application level labels
      • Parameters
      None
      
  • add
    • This metrics type will increment the counter by the value specified. Used for instruments that are counters.
      • Parameters
          name = "<name of the instrument>"
          val = integer value to increment
          // This is an optional parameter. These labels will be appended to application level labels.
          labels  = { key : value }
      
  • record
    • This metrics type will record the value specified for the instrument. Used for instruments that are measurements.
      • Parameters
          name = "<name of the instrument>"
          val = integer value to increment
          // This is an optional parameter. These labels will be appended to application level labels.
          labels  = { key : value }
          unit = "string value to indicate unit. eg: 'ms'"
      

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.

FAQs

Package last updated on 28 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc