Socket
Socket
Sign inDemoInstall

@opentelemetry/exporter-metrics-otlp-grpc

Package Overview
Dependencies
96
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @opentelemetry/exporter-metrics-otlp-grpc

OpenTelemetry Collector Metrics Exporter allows user to send collected metrics to the OpenTelemetry Collector


Version published
Maintainers
2
Created

Readme

Source

OpenTelemetry Collector Metrics Exporter for node with grpc

NPM Published Version Apache License

This module provides exporter for web and node to be used with opentelemetry-collector - last tested with version 0.25.0.

Installation

npm install --save @opentelemetry/exporter-metrics-otlp-grpc

Service Name

The OpenTelemetry Collector Exporter does not have a service name configuration. In order to set the service name, use the service.name resource attribute as prescribed in the OpenTelemetry Resource Semantic Conventions. To see sample code and documentation for the traces exporter, as well as instructions for using TLS, visit the Collector Trace Exporter for web and node.

Metrics in Node - GRPC

The OTLPTraceExporter in Node expects the URL to only be the hostname. It will not work with /v1/metrics. All options that work with trace also work with metrics.

const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
const { OTLPMetricExporter } =  require('@opentelemetry/exporter-metrics-otlp-grpc');
const collectorOptions = {
  // url is optional and can be omitted - default is grpc://localhost:4317
  url: 'grpc://<collector-hostname>:<port>',
};
const exporter = new OTLPMetricExporter(collectorOptions);

// Register the exporter
const provider = new MeterProvider({
  exporter,
  interval: 60000,
})
['SIGINT', 'SIGTERM'].forEach(signal => {
  process.on(signal, () => provider.shutdown().catch(console.error));
});

// Now, start recording data
const meter = provider.getMeter('example-meter');
const counter = meter.createCounter('metric_name');
counter.add(10, { 'key': 'value' });

Running opentelemetry-collector locally to see the metrics

  1. Go to examples/otlp-exporter-node
  2. run npm run docker:start
  3. Open page at http://localhost:9411/zipkin/ to observe the metrics

License

Apache 2.0 - See LICENSE for more information.

Keywords

FAQs

Last updated on 22 Apr 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc