Socket
Socket
Sign inDemoInstall

@opentelemetry/context-zone-peer-dep

Package Overview
Dependencies
Maintainers
3
Versions
122
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/context-zone-peer-dep


Version published
Weekly downloads
175K
increased by8.06%
Maintainers
3
Created
Weekly downloads
 

Changelog

Source

1.22.0

:rocket: (Enhancement)

  • feat(sdk-metrics): allow single bucket histograms #4456 @pichlermarc
  • feat(instrumentation): Make init() method public #4418
  • feat(context-zone-peer-dep, context-zone): support zone.js 0.13.x, 0.14.x #4469 @pichlermarc
  • chore: Semantic Conventions export individual strings 4185
  • feat(sdk-trace-base): allow adding span links after span creation #4536 @seemk

:bug: (Bug Fix)

  • fix(sdk-metrics): handle zero bucket counts in exponential histogram merge #4459 @mwear
  • fix(sdk-metrics): ignore NaN value recordings in Histograms #4455 @pichlermarc
    • fixes a bug where recording NaN on a histogram would result in the sum of bucket count values not matching the overall count
  • fix(sdk-metrics): allow single bucket histograms #4456 @pichlermarc
    • fixes a bug where Meter.createHistogram() with the advice explicitBucketBoundaries: [] would throw
  • fix(context-zone-peer-dep, context-zone): support zone.js 0.13.x, 0.14.x #4469 @pichlermarc

:books: (Refine Doc)

  • docs: shorten readme sections #4460 @legendecas

Readme

Source

OpenTelemetry Context Zone Peer Dependency

NPM Published Version Apache License

This module provides Zone Context Manager with a peer dependency for zone-js for Web applications. If you use Angular you already have the zone-js and you should use this package. If you don't have your own zone-js please use @opentelemetry/context-zone

Installation

Please note that due to an issue with zone.js, the ZoneContextManager does not work with JS code targeting ES2017+. In order to use the ZoneContextManager, please transpile back to ES2015.

npm install --save @opentelemetry/context-zone-peer-dep

Usage

import { context, trace } from '@opentelemetry/api';
import {
  ConsoleSpanExporter,
  SimpleSpanProcessor,
  WebTracerProvider,
} from '@opentelemetry/sdk-trace-web';
import { ZoneContextManager } from '@opentelemetry/context-zone-peer-dep';

const providerWithZone = new WebTracerProvider();
providerWithZone.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
providerWithZone.register({
  contextManager: new ZoneContextManager()
});

// Example how the ZoneContextManager keeps the reference to the correct context during async operations
const webTracerWithZone = providerWithZone.getTracer('default');
const span1 = webTracerWithZone.startSpan('foo1');
context.with(trace.setSpan(context.active(), span1, () => {
  console.log('Current span is span1', trace.getSpan(context.active()) === span1);
  setTimeout(() => {
    const span2 = webTracerWithZone.startSpan('foo2');
    console.log('Current span is span1', trace.getSpan(context.active()) === span1);
    context.with(trace.setSpan(context.active(), span2, () => {
      console.log('Current span is span2', trace.getSpan(context.active()) === span2);
      setTimeout(() => {
        console.log('Current span is span2', trace.getSpan(context.active()) === span2);
      }, 500);
    });
    // there is a timeout which still keeps span2 active
    console.log('Current span is span2', trace.getSpan(context.active()) === span2);
  }, 500);
  console.log('Current span is span1', trace.getSpan(context.active()) === span1);
});

License

Apache 2.0 - See LICENSE for more information.

Keywords

FAQs

Last updated on 29 Feb 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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc