Have ideas to improve npm?Join in the discussion! »

    TypeScript icon, indicating that this package has built-in type declarations

    0.1.0-beta.2 • Public • Published

    Dynatrace OpenTelemetry Metrics Exporter for JavaScript

    This project is developed and maintained by Dynatrace R&D. Currently, this is a prototype and not intended for production use. It is not covered by Dynatrace support.

    This exporter plugs into the OpenTelemetry Metrics SDK for JavaScript, which is in alpha/preview state and neither considered stable nor complete as of this writing.

    See open-telemetry/opentelemetry-js for the current state of the OpenTelemetry SDK for JavaScript.

    Getting started

    The general setup of OpenTelemetry JS is explained in the official Getting Started Guide.

    Using the Metrics API is explained in the Monitor Your NodeJS Application section.

    The Dynatrace exporter is added and set up like this:

    const { MeterProvider } = require('@opentelemetry/metrics');
    const {
    } = require('@dynatrace/opentelemetry-exporter-metrics');
    // configure API endpoint and authentication token
    const exporter = new DynatraceMetricExporter({
        // don't put this in your code, read it from an env var or config file
        url: 'https://myenv123.live.dynatrace.com/api/v2/metrics/ingest',
        APIToken: 'token123',
        prefix: 'MyPrefix', // optional
    const meter = new MeterProvider({
      interval: 1000,
    const requestCounter = meter.createCounter('requests', {
      description: 'Example of a Counter',
    const upDownCounter = meter.createUpDownCounter('test_up_down_counter', {
      description: 'Example of a UpDownCounter',
    const labels = { pid: process.pid, environment: 'staging' };
    setInterval(() => {
      upDownCounter.bind(labels).add(Math.random() > 0.5 ? 1 : -1);
    }, 1000);

    A full setup is provided in our example project.


    The exporter allows for configuring the following settings by passing them to the constructor:

    Dynatrace API Endpoint

    The endpoint to which the metrics are sent is specified using the url parameter.

    Given an environment ID myenv123 on Dynatrace SaaS, the metrics ingest endpoint would be https://myenv123.live.dynatrace.com/api/v2/metrics/ingest.

    If a OneAgent is installed on the host, it can provide a local endpoint for providing metrics directly without the need for an API token. This feature is currently in an Early Adopter phase and has to be enabled as described in the OneAgent metric API documentation. Using the local API endpoint, the host ID and host name context are automatically added to each metric as dimensions. The default metric API endpoint exposed by the OneAgent is http://localhost:14499/metrics/ingest.

    Dynatrace API Token

    The Dynatrace API token to be used by the exporter is specified using the APIToken parameter and could, for example, be read from an environment variable.

    Creating an API token for your Dynatrace environment is described in the Dynatrace API documentation. The scope required for sending metrics is the Ingest metrics scope in the API v2 section:

    API token creation

    Metric Key Prefix

    The prefix parameter specifies an optional prefix, which is prepended to each metric key, separated by a dot (<prefix>.<namespace>.<name>).

    Default Labels/Dimensions

    The tags parameter can be used to optionally specify a list of key/value pairs, which will be added as additional labels/dimensions to all data points.




    npm i @dynatrace/opentelemetry-exporter-metrics

    DownloadsWeekly Downloads






    Unpacked Size

    37.9 kB

    Total Files


    Last publish


    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar