Socket
Socket
Sign inDemoInstall

@opentelemetry/context-zone

Package Overview
Dependencies
4
Maintainers
3
Versions
121
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @opentelemetry/context-zone

OpenTelemetry Context Zone


Version published
Weekly downloads
138K
increased by8.95%
Maintainers
3
Created
Weekly downloads
 

Changelog

Source

1.17.1

:bug: (Bug Fix)

  • fix(sdk-trace-base): BatchSpanProcessor flushes when maxExportBatchSize is reached #3958 @nordfjord
  • fix(sdk-metrics): allow instrument names to contain '/' #4155
  • fix(sdk-metrics): prevent per-reader storages from keeping unreported accumulations in memory #4163 @pichlermarc
    • fixes a memory leak which occurred when two or more MetricReader instances are registered to a MeterProvider
  • fix(sdk-metrics): do not report empty scopes and metrics #4135 @pichlermarc
    • Instruments that were created, but did not have measurements will not be exported anymore
    • Meters (Scopes) that were created, but did not have any instruments with measurements under them will not be exported anymore.
  • fix(exporter-zipkin): round duration to the nearest int in annotations to be compliant with zipkin protocol #4167 @FelipeEmerim

:books: (Refine Doc)

  • docs(contributing): added guidelines for adding benchmark tests #4169

:house: (Internal)

  • test: added a performance benchmark test for span creation #4105
  • test: added a workflow to run performance benchmark tests automatically #4144

Readme

Source

OpenTelemetry Context Zone

NPM Published Version Apache License

This module provides Zone Context Manager with bundled zone-js for Web applications. If you have your own zone-js please use @opentelemetry/context-zone-peer-dep If you use Angular it means you already have the zone-js and you should use @opentelemetry/context-zone-peer-dep

Installation

npm install --save @opentelemetry/context-zone

Usage

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

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 10 Oct 2023

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