OpenTelemetry Web
This module provides automated instrumentation and tracing for Web applications.
For manual instrumentation see the
@opentelemetry/web package.
How does automatic tracing work?
import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/tracing';
import { WebTracer } from '@opentelemetry/web';
import { DocumentLoad } from '@opentelemetry/plugin-document-load';
const webTracer = new WebTracer({
plugins: [
new DocumentLoad()
]
});
webTracer.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
Installation
npm install --save @opentelemetry/web
Usage
const { WebTracer } = require('@opentelemetry/web');
const webTracer = new WebTracer();
const span = webTracer.startSpan('span1');
webTracer.withSpan(span, function () {
this.addEvent('start');
});
span.addEvent('middle');
span.end();
Useful links
License
Apache 2.0 - See LICENSE for more information.