Socket
Socket
Sign inDemoInstall

@opentelemetry/context-zone-peer-dep

Package Overview
Dependencies
Maintainers
5
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/context-zone-peer-dep

OpenTelemetry Context Zone with peer dependency for zone.js


Version published
Weekly downloads
164K
decreased by-3.5%
Maintainers
5
Weekly downloads
 
Install size
Created

Package description

What is @opentelemetry/context-zone-peer-dep?

@opentelemetry/context-zone-peer-dep is a package that provides context management capabilities using Zone.js. It is part of the OpenTelemetry project, which is a set of APIs, libraries, agents, and instrumentation to provide observability for applications.

What are @opentelemetry/context-zone-peer-dep's main functionalities?

Context Management

This feature allows you to manage context using Zone.js. The code sample demonstrates how to set the global context manager to use ZoneContextManager, create a new context, and run a function within that context.

const { context, setGlobalContextManager } = require('@opentelemetry/api');
const { ZoneContextManager } = require('@opentelemetry/context-zone-peer-dep');

// Set the global context manager to use ZoneContextManager
setGlobalContextManager(new ZoneContextManager());

// Create a new context
const ctx = context.active().setValue('key', 'value');

// Run a function within the context
context.with(ctx, () => {
  console.log(context.active().getValue('key')); // Outputs: 'value'
});

Other packages similar to @opentelemetry/context-zone-peer-dep

Changelog

Source

0.5.0

Released 2020-03-16

First official beta release

  • provides almost fully complete metrics, tracing, and context propagation functionality but makes no promises around breaking changes

:boom: Breaking Change

  • #853 Rename scope to context
  • #851 Rename formatter to propagator

:rocket: (Enhancement)

  • #828 feat: metric observer
  • #858 chore: update out-of-date dependencies
  • #856 fix: change loglevel for beta
  • #843 export resource to exporters
  • #846 SDK Resource
  • #625 feat: introduce ended property on Span
  • #837 Simplify SDK registration
  • #818 fix: change SpanContext.traceFlags to mandatory
  • #827 Add getter and setter arguments to propagation API
  • #821 feat: add composite propagator
  • #824 Faster trace id generation
  • #708 Simplify and speed up trace context parsing
  • #802 chore: adding force flush to span processors
  • #816 feat: use context-based tracing
  • #815 Resources API: package, semantic conventions, and test utils
  • #797 Add propagation API
  • #792 Add context API
  • #685 feat: add express plugin #666
  • #769 Separate context propagation (OTEP 66)
  • #653 Prevent loading plugins for incorrect module #626
  • #654 feat: warn user when a instrumented package was already required #636
  • #772 chore: add typing to propagator carrier
  • #735 feat: decode jaeger header
  • #719 feat(plugin-http): sync. specs for statuscode
  • #701 feat: add jaeger http trace format (#696)

:bug: (Bug Fix)

  • #798 Respect sampled bit in probability sampler
  • #743 fix: left pad jaeger trace ids
  • #715 fix: unref jaeger socket to prevent process running indefinitely

Readme

Source

OpenTelemetry Context Zone Peer Dependency

Gitter chat NPM Published Version dependencies devDependencies 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

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

Usage

import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/tracing';
import { WebTracer } from '@opentelemetry/web';
import { ZoneContextManager } from '@opentelemetry/context-zone-peer-dep';

const webTracerWithZone = new WebTracer({
  contextManager: new ZoneContextManager()
});
webTracerWithZone.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));

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

License

Apache 2.0 - See LICENSE for more information.

Keywords

FAQs

Package last updated on 16 Mar 2020

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc