@opentelemetry/sdk-trace-web
TypeScript icon, indicating that this package has built-in type declarations

1.28.0 • Public • Published

OpenTelemetry Web SDK

NPM Published Version Apache License

This module provides automated instrumentation and tracing for Web applications.

For manual instrumentation see the @opentelemetry/sdk-trace-base 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 instrumentations for well know modules (see supported modules) and an API to create custom instrumentations (see the instrumentation developer guide).

Web Tracer currently supports one plugin for document load. Unlike Node Tracer (NodeTracerProvider), the plugins needs to be initialized 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. Please note that the ZoneContextManager does not work with JS code targeting ES2017+. In order to use the ZoneContextManager, please transpile back to ES2015.

Installation

npm install --save @opentelemetry/sdk-trace-web

Usage

import {
  ConsoleSpanExporter,
  SimpleSpanProcessor,
  WebTracerProvider,
} from '@opentelemetry/sdk-trace-web';
import { DocumentLoad } from '@opentelemetry/plugin-document-load';
import { ZoneContextManager } from '@opentelemetry/context-zone';
import { registerInstrumentations } from '@opentelemetry/instrumentation';

const provider = new WebTracerProvider({
  spanProcessors: [new SimpleSpanProcessor(new ConsoleSpanExporter())]
});

provider.register({
  // Changing default contextManager to use ZoneContextManager - supports asynchronous operations - optional
  contextManager: new ZoneContextManager(),
});

// Registering instrumentations / plugins
registerInstrumentations({
  instrumentations: [
    new DocumentLoad(),
  ],
});

Useful links

License

Apache 2.0 - See LICENSE for more information.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.25.1-alpha.230canary
1.28.0
24,504latest
1.8.02,544next

Version History

VersionDownloads (Last 7 Days)Published
1.28.0
24,504
1.27.0
75,733
1.26.0154,989
1.25.1101,756
1.25.015,007
1.24.146,449
1.24.03,090
1.23.010,645
1.22.013,055
1.21.023,371
1.20.02,376
1.19.08,249
1.18.111,914
1.18.0303
1.17.112,921
1.17.040,214
1.16.01
1.15.210,983
1.15.1888
1.15.08,287
1.14.02,891
1.13.02,207
1.12.017,562
1.11.03,154
1.10.11,539
1.10.056
1.9.112,037
1.9.0361
1.8.02,544
1.7.0716
1.6.0799
1.5.093
1.4.02,948
1.3.1415
1.3.00
1.2.01,185
1.1.191
1.1.02
1.0.11,721
1.0.0192
0.26.04
0.25.1-alpha.230
0.25.1-alpha.160
0.25.1-alpha.130
0.25.1-alpha.120
0.25.1-alpha.70
0.25.1-alpha.40
0.25.1-alpha.20
0.25.051
0.25.1-alpha.210
0.24.1-alpha.203,041
0.24.1-alpha.190
0.24.1-alpha.180
0.24.1-alpha.140
0.24.1-alpha.90
0.24.1-alpha.80
0.24.1-alpha.70
0.24.1-alpha.60
0.24.1-alpha.50
0.24.1-alpha.40

Package Sidebar

Install

npm i @opentelemetry/sdk-trace-web

Weekly Downloads

618,344

Version

1.28.0

License

Apache-2.0

Unpacked Size

243 kB

Total Files

66

Last publish

Collaborators

  • pichlermarc
  • bogdandrutu
  • dyladan