Package Exports
- @opentelemetry/web
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@opentelemetry/web) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
OpenTelemetry Web SDK
This module provides automated instrumentation and tracing for Web applications.
For manual instrumentation see the @opentelemetry/tracing package.
How does automatic tracing work?
This package exposes a class WebTracerProvider
that will be able to automatically trace things in Browser only.
See the example how to use it.
OpenTelemetry comes with a growing number of instrumentation plugins for well know modules (see supported modules) and an API to create custom plugins (see the plugin developer guide).
Web Tracer currently supports one plugin for document load.
Unlike Node Tracer (NodeTracerProvider
), the plugins needs to be initialised and passed in configuration.
The reason is to give user full control over which plugin will be bundled into web page.
You can choose to use the ZoneContextManager
if you want to trace asynchronous operations.
Installation
npm install --save @opentelemetry/web
Usage
import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/tracing';
import { WebTracerProvider } from '@opentelemetry/web';
import { DocumentLoad } from '@opentelemetry/plugin-document-load';
import { ZoneContextManager } from '@opentelemetry/context-zone';
// Minimum required setup - supports only synchronous operations
const provider = new WebTracerProvider({
plugins: [
new DocumentLoad()
]
});
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.register();
const providerWithZone = new WebTracerProvider({
plugins: [
new DocumentLoad()
]
});
providerWithZone.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
// Changing default contextManager to use ZoneContextManager - supports asynchronous operations
providerWithZone.register({
contextManager: new ZoneContextManager(),
});
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.