Giter Site home page Giter Site logo

janwieremjewicz / opentelemetry-metric-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dynatrace-oss/opentelemetry-metric-js

0.0 0.0 0.0 141 KB

Dynatrace OpenTelemetry Metrics Exporter for JavaScript

Home Page: https://www.dynatrace.com/integrations/opentelemetry/

License: Apache License 2.0

TypeScript 99.53% JavaScript 0.47%

opentelemetry-metric-js's Introduction

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 {
  DynatraceMetricExporter,
} = 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({
  exporter,
  interval: 1000,
}).getMeter('opentelemetry-metrics-sample-dynatrace');

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(() => {
  requestCounter.bind(labels).add(1);
  upDownCounter.bind(labels).add(Math.random() > 0.5 ? 1 : -1);
}, 1000);

A full setup is provided in our example project.

Configuration

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.

opentelemetry-metric-js's People

Contributors

dyladan avatar danielkhan avatar arminru avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.