Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@opentelemetry/instrumentation-long-task

Package Overview
Dependencies
Maintainers
0
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/instrumentation-long-task

OpenTelemetry instrumentation for long task Web API

  • 0.43.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
increased by10.43%
Maintainers
0
Weekly downloads
 
Created
Source

OpenTelemetry Long Task Instrumentation for web

NPM Published Version Apache License

This module provides automatic instrumentation for Long Task API which may be loaded using the @opentelemetry/sdk-trace-web package. It creates spans from tasks that take more than 50 milliseconds, all of the data reported via PerformanceLongTaskTiming is included as span attributes.

If total installation size is not constrained, it is recommended to use the @opentelemetry/auto-instrumentations-web bundle with @opentelemetry/sdk-trace-web for the most seamless instrumentation experience.

Compatible with OpenTelemetry JS API and SDK 1.0+.

Installation

npm install --save @opentelemetry/instrumentation-long-task

Usage

import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
import { LongTaskInstrumentation } from '@opentelemetry/instrumentation-long-task';
import { registerInstrumentations } from '@opentelemetry/instrumentation';

const provider = new WebTracerProvider();

provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));

registerInstrumentations({
  tracerProvider: provider,
  instrumentations: [
    new LongTaskInstrumentation({
      // see under for available configuration
    }),
  ],
});

longtask Instrumentation Options

OptionsTypeDescription
observerCallbackObserverCallbackCallback executed on observed longtask, allowing additional attributes to be attached to the span.

The observerCallback function is passed the created span and the longtask PerformanceEntry, allowing the user to add custom attributes to the span with any logic. For example, a web app with client-side routing can add contextual information on the current page, even if the tracer was instantiated before navigation.

Usage Example:

longtaskInstrumentationConfig = {
  observerCallback: (span, longtaskEvent) => {
    span.setAttribute('location.pathname', window.location.pathname)
  }
}

Semantic Conventions

This package does not currently generate any attributes from semantic conventions.

License

Apache 2.0 - See LICENSE for more information.

Keywords

FAQs

Package last updated on 05 Dec 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc