@mzahor-test-org/open-telemetry-exporter-collector
v0.0.24
Published
OpenTelemetry Collector Exporter allows user to send collected traces to the OpenTelemetry Collector
Downloads
37
Readme
OpenTelemetry Collector Exporter for web and node
This module provides exporter for web and node to be used with opentelemetry-collector.
Installation
npm install --save @opentelemetry/exporter-collector
Usage in Web
import { SimpleSpanProcessor } from '@opentelemetry/tracing';
import { WebTracerProvider } from '@opentelemetry/web';
import { CollectorExporter } from '@opentelemetry/exporter-collector'
const collectorOptions = {
url: '<opentelemetry-collector-url>' // url is optional and can be omitted - default is http://localhost:55678/v1/trace
};
const provider = new WebTracerProvider();
const exporter = new CollectorExporter(collectorOptions);
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.register();
Usage in Node
const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { CollectorExporter } = require('@opentelemetry/exporter-collector');
const collectorOptions = {
serviceName: 'basic-service',
url: '<opentelemetry-collector-url>' // url is optional and can be omitted - default is http://localhost:55678/v1/trace
};
const provider = new BasicTracerProvider();
const exporter = new CollectorExporter(collectorOptions);
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.register();
Running opentelemetry-collector locally to see the traces
- Go to examples/basic-tracer-node
- run
npm run collector:docker:ot
- Open page at
http://localhost:9411/zipkin/
to observe the traces
Useful links
- For more information on OpenTelemetry, visit: https://opentelemetry.io/
- For more about OpenTelemetry JavaScript: https://github.com/open-telemetry/opentelemetry-js
- For help or feedback on this project, join us on gitter
License
Apache 2.0 - See LICENSE for more information.