JSPM

@opentelemetry/core

0.11.1-alpha.36+6eb157c6
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 23425115
  • Score
    100M100P100Q271050F
  • License Apache-2.0

OpenTelemetry Core provides default and no-op implementations of the OpenTelemetry types for trace and metrics

Package Exports

  • @opentelemetry/core
  • @opentelemetry/core/build/src/platform/browser/index.js
  • @opentelemetry/core/build/src/platform/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@opentelemetry/core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

OpenTelemetry Core

Gitter chat NPM Published Version dependencies devDependencies Apache License

This package provides default implementations of the OpenTelemetry API for trace and metrics. It's intended for use both on the server and in the browser.

Built-in Implementations

Built-in Propagators

HttpTraceContext Propagator

OpenTelemetry provides a text-based approach to propagate context to remote services using the W3C Trace Context HTTP headers.

const api = require("@opentelemetry/api");
const { HttpTraceContext } = require("@opentelemetry/core");

/* Set Global Propagator */
api.propagation.setGlobalPropagator(new HttpTraceContext());

B3 Propagator

This is propagator for the B3 HTTP header format, which sends a SpanContext on the wire in an HTTP request, allowing other services to create spans with the right context. Based on: https://github.com/openzipkin/b3-propagation

const api = require("@opentelemetry/api");
const { B3Propagator } = require("@opentelemetry/core");

/* Set Global Propagator */
api.propagation.setGlobalPropagator(new B3Propagator());

Composite Propagator

Combines multiple propagators into a single propagator.

This is used as a default Propagator

const api = require("@opentelemetry/api");
const { CompositePropagator } = require("@opentelemetry/core");

/* Set Global Propagator */
api.propagation.setGlobalPropagator(new CompositePropagator());

Correlation Context Propagator

Provides a text-based approach to propagate correlation context to remote services using the OpenTelemetry CorrelationContext Propagation HTTP headers.

const api = require("@opentelemetry/api");
const { HttpCorrelationContext } = require("@opentelemetry/core");

/* Set Global Propagator */
api.propagation.setGlobalPropagator(new HttpCorrelationContext());

Built-in Sampler

Sampler is used to make decisions on Span sampling.

AlwaysOn

Samples every trace regardless of upstream sampling decisions.

This is used as a default Sampler

const { NodeTracerProvider } = require("@opentelemetry/node");
const { AlwaysOnSampler } = require("@opentelemetry/core");

const tracerProvider = new NodeTracerProvider({
  sampler: new AlwaysOnSampler()
});

AlwaysOff

Doesn't sample any trace, regardless of upstream sampling decisions.

const { NodeTracerProvider } = require("@opentelemetry/node");
const { AlwaysOffSampler } = require("@opentelemetry/core");

const tracerProvider = new NodeTracerProvider({
  sampler: new AlwaysOffSampler()
});

Probability

Samples a configurable percentage of traces, and additionally samples any trace that was sampled upstream.

const { NodeTracerProvider } = require("@opentelemetry/node");
const { ProbabilitySampler } = require("@opentelemetry/core");

const tracerProvider = new NodeTracerProvider({
  sampler: new ProbabilitySampler(0.5)
});

ParentOrElse

A composite sampler that either respects the parent span's sampling decision or delegates to delegateSampler for root spans.

const { NodeTracerProvider } = require("@opentelemetry/node");
const { ParentOrElseSampler, AlwaysOffSampler } = require("@opentelemetry/core");

const tracerProvider = new NodeTracerProvider({
  sampler: new ParentOrElseSampler(new AlwaysOffSampler())
});

License

Apache 2.0 - See LICENSE for more information.