Socket
Socket
Sign inDemoInstall

@opentelemetry/sdk-trace-web

Package Overview
Dependencies
5
Maintainers
3
Versions
54
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @opentelemetry/sdk-trace-web

OpenTelemetry Web Tracer


Version published
Weekly downloads
343K
decreased by-2.06%
Maintainers
3
Install size
3.87 MB
Created
Weekly downloads
 

Changelog

Source

1.24.0

:rocket: (Enhancement)

  • feat(sdk-trace-base): log resource attributes in ConsoleSpanExporter #4605 @pichlermarc
  • feat(propagator-aws-xray): moved AWS Xray propagator from contrib 4603 @martinkuba
  • feat(resources): new experimental detector ServiceInstanceIdDetectorSync that sets the value for service.instance.id as random UUID. #4608 @maryliag

:bug: (Bug Fix)

  • fix(sdk-trace-web): fix invalid timings in span events #4486 @Abinet18
  • fix(resources): ensure BrowserDetector does not think Node.js v21 is a browser #4561 @trentm

Readme

Source

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();
provider.addSpanProcessor(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(),
  ],
});

License

Apache 2.0 - See LICENSE for more information.

Keywords

FAQs

Last updated on 24 Apr 2024

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