@opentelemetry/core
OpenTelemetry Core provides default and no-op implementations of the OpenTelemetry types for trace and metrics
Last updated 3 years ago by dyladan .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @opentelemetry/core 
SYNC missed versions from official npm registry.

OpenTelemetry Core

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

HttpTraceContextPropagator 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 { HttpTraceContextPropagator } = require("@opentelemetry/core");

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

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());

Baggage Propagator

Provides a text-based approach to propagate baggage to remote services using the OpenTelemetry Baggage Propagation HTTP headers.

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

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

Built-in Sampler

Sampler is used to make decisions on Span sampling.

AlwaysOn Sampler

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 Sampler

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()
});

TraceIdRatioBased Sampler

Samples some percentage of traces, calculated deterministically using the trace ID. Any trace that would be sampled at a given percentage will also be sampled at any higher percentage.

The TraceIDRatioSampler may be used with the ParentBasedSampler to respect the sampled flag of an incoming trace.

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

const tracerProvider = new NodeTracerProvider({
  // See details of ParentBasedSampler below
  sampler: new ParentBasedSampler({
    // Trace ID Ratio Sampler accepts a positional argument
    // which represents the percentage of traces which should
    // be sampled.
    root: new TraceIdRatioBasedSampler(0.5)
  });
});

ParentBased Sampler

  • This is a composite sampler. ParentBased helps distinguished between the following cases:
    • No parent (root span).
    • Remote parent with sampled flag true
    • Remote parent with sampled flag false
    • Local parent with sampled flag true
    • Local parent with sampled flag false

Required parameters:

  • root(Sampler) - Sampler called for spans with no parent (root spans)

Optional parameters:

  • remoteParentSampled(Sampler) (default: AlwaysOn)
  • remoteParentNotSampled(Sampler) (default: AlwaysOff)
  • localParentSampled(Sampler) (default: AlwaysOn)
  • localParentNotSampled(Sampler) (default: AlwaysOff)
Parent parent.isRemote() parent.isSampled() Invoke sampler
absent n/a n/a root()
present true true remoteParentSampled()
present true false remoteParentNotSampled()
present false true localParentSampled()
present false false localParentNotSampled()
const { NodeTracerProvider } = require("@opentelemetry/node");
const { ParentBasedSampler, AlwaysOffSampler, TraceIdRatioBasedSampler } = require("@opentelemetry/core");

const tracerProvider = new NodeTracerProvider({
  sampler: new ParentBasedSampler({
    // By default, the ParentBasedSampler will respect the parent span's sampling
    // decision. This is configurable by providing a different sampler to use
    // based on the situation. See configuration details above.
    //
    // This will delegate the sampling decision of all root traces (no parent)
    // to the TraceIdRatioBasedSampler.
    // See details of TraceIdRatioBasedSampler above.
    root: new TraceIdRatioBasedSampler(0.5)
  })
});

Useful links

License

Apache 2.0 - See LICENSE for more information.

Current Tags

  • 0.25.1-alpha.23                                ...           canary (3 years ago)
  • 1.27.0                                ...           latest (23 days ago)
  • 1.8.0                                ...           next (2 years ago)

173 Versions

  • 1.27.0                                ...           23 days ago
  • 1.26.0                                ...           3 months ago
  • 1.25.1                                ...           5 months ago
  • 1.25.0                                ...           5 months ago
  • 1.24.1                                ...           6 months ago
  • 1.24.0                                ...           7 months ago
  • 1.23.0                                ...           7 months ago
  • 1.22.0                                ...           9 months ago
  • 1.21.0                                ...           10 months ago
  • 1.20.0                                ...           10 months ago
  • 1.19.0                                ...           a year ago
  • 1.18.1                                ...           a year ago
  • 1.18.0                                ...           a year ago
  • 1.17.1                                ...           a year ago
  • 1.17.0                                ...           a year ago
  • 1.16.0                                ...           a year ago
  • 1.15.2                                ...           a year ago
  • 1.15.1                                ...           a year ago
  • 1.15.0                                ...           a year ago
  • 1.14.0                                ...           a year ago
  • 1.13.0                                ...           2 years ago
  • 1.12.0                                ...           2 years ago
  • 1.11.0                                ...           2 years ago
  • 1.10.1                                ...           2 years ago
  • 1.10.0                                ...           2 years ago
  • 1.9.1                                ...           2 years ago
  • 1.9.0                                ...           2 years ago
  • 1.8.0                                ...           2 years ago
  • 1.7.0                                ...           2 years ago
  • 1.6.0                                ...           2 years ago
  • 1.5.0                                ...           2 years ago
  • 1.4.0                                ...           2 years ago
  • 1.3.1                                ...           2 years ago
  • 1.3.0                                ...           2 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
  • 0.26.0                                ...           3 years ago
  • 0.25.1-alpha.23                                ...           3 years ago
  • 0.25.1-alpha.13                                ...           3 years ago
  • 0.25.1-alpha.12                                ...           3 years ago
  • 0.25.1-alpha.4                                ...           3 years ago
  • 0.25.1-alpha.2                                ...           3 years ago
  • 0.25.0                                ...           3 years ago
  • 0.25.1-alpha.21                                ...           3 years ago
  • 0.24.1-alpha.20                                ...           3 years ago
  • 0.24.1-alpha.14                                ...           3 years ago
  • 0.24.1-alpha.7                                ...           3 years ago
  • 0.24.1-alpha.5                                ...           3 years ago
  • 0.24.1-alpha.4                                ...           3 years ago
  • 0.24.1-alpha.1                                ...           3 years ago
  • 0.24.0                                ...           3 years ago
  • 0.24.1-alpha.31                                ...           3 years ago
  • 0.23.1-alpha.28                                ...           3 years ago
  • 0.23.1-alpha.24                                ...           3 years ago
  • 0.23.1-alpha.23                                ...           3 years ago
  • 0.23.1-alpha.15                                ...           3 years ago
  • 0.23.1-alpha.3                                ...           3 years ago
  • 0.23.1-alpha.18                                ...           3 years ago
  • 0.23.0                                ...           3 years ago
  • 0.23.1-alpha.17                                ...           3 years ago
  • 0.22.1-alpha.16                                ...           3 years ago
  • 0.22.1-alpha.15                                ...           3 years ago
  • 0.22.1-alpha.13                                ...           3 years ago
  • 0.22.1-alpha.3                                ...           3 years ago
  • 0.22.0                                ...           3 years ago
  • 0.22.1-alpha.5                                ...           3 years ago
  • 0.21.1-alpha.2                                ...           3 years ago
  • 0.21.1-alpha.1                                ...           3 years ago
  • 0.21.0                                ...           3 years ago
  • 0.21.1-alpha.7                                ...           3 years ago
  • 0.20.1-alpha.4                                ...           3 years ago
  • 0.20.1-alpha.3                                ...           3 years ago
  • 0.20.0                                ...           3 years ago
  • 0.20.1-alpha.49                                ...           3 years ago
  • 0.19.1-alpha.43                                ...           3 years ago
  • 0.19.1-alpha.42                                ...           3 years ago
  • 0.19.1-alpha.38                                ...           3 years ago
  • 0.19.1-alpha.33                                ...           3 years ago
  • 0.19.1-alpha.31                                ...           3 years ago
  • 0.19.1-alpha.26                                ...           4 years ago
  • 0.19.1-alpha.25                                ...           4 years ago
  • 0.19.1-alpha.21                                ...           4 years ago
  • 0.19.1-alpha.19                                ...           4 years ago
  • 0.19.1-alpha.12                                ...           4 years ago
  • 0.19.1-alpha.11                                ...           4 years ago
  • 0.19.1-alpha.9                                ...           4 years ago
  • 0.19.1-alpha.7                                ...           4 years ago
  • 0.19.1-alpha.39                                ...           4 years ago
  • 0.19.1-alpha.37                                ...           4 years ago
  • 0.19.0                                ...           4 years ago
  • 0.19.1-alpha.36                                ...           4 years ago
  • 0.18.3-alpha.31                                ...           4 years ago
  • 0.18.3-alpha.28                                ...           4 years ago
  • 0.18.3-alpha.25                                ...           4 years ago
  • 0.18.3-alpha.23                                ...           4 years ago
  • 0.18.3-alpha.20                                ...           4 years ago
  • 0.18.3-alpha.18                                ...           4 years ago
  • 0.18.3-alpha.16                                ...           4 years ago
  • 0.18.3-alpha.14                                ...           4 years ago
  • 0.18.3-alpha.11                                ...           4 years ago
  • 0.18.3-alpha.10                                ...           4 years ago
  • 0.18.3-alpha.7                                ...           4 years ago
  • 0.18.3-alpha.5                                ...           4 years ago
  • 0.18.3-alpha.4                                ...           4 years ago
  • 0.18.3-alpha.3                                ...           4 years ago
  • 0.18.3-alpha.1                                ...           4 years ago
  • 0.18.2                                ...           4 years ago
  • 0.18.3-alpha.2                                ...           4 years ago
  • 0.18.2-alpha.1                                ...           4 years ago
  • 0.18.1                                ...           4 years ago
  • 0.18.2-alpha.81                                ...           4 years ago
  • 0.18.1-alpha.26                                ...           4 years ago
  • 0.18.1-alpha.24                                ...           4 years ago
  • 0.18.1-alpha.21                                ...           4 years ago
  • 0.18.1-alpha.20                                ...           4 years ago
  • 0.18.1-alpha.3                                ...           4 years ago
  • 0.18.0                                ...           4 years ago
  • 0.18.1-alpha.12                                ...           4 years ago
  • 0.17.1-alpha.8                                ...           4 years ago
  • 0.17.1-alpha.5                                ...           4 years ago
  • 0.17.1-alpha.2                                ...           4 years ago
  • 0.17.1-alpha.21                                ...           4 years ago
  • 0.17.0                                ...           4 years ago
  • 0.16.1-alpha.20                                ...           4 years ago
  • 0.16.1-alpha.18                                ...           4 years ago
  • 0.16.1-alpha.15                                ...           4 years ago
  • 0.16.1-alpha.14                                ...           4 years ago
  • 0.16.1-alpha.11                                ...           4 years ago
  • 0.16.1-alpha.10                                ...           4 years ago
  • 0.16.0                                ...           4 years ago
  • 0.15.0                                ...           4 years ago
  • 0.14.0                                ...           4 years ago
  • 0.13.0                                ...           4 years ago
  • 0.12.1-alpha.7                                ...           4 years ago
  • 0.12.0                                ...           4 years ago
  • 0.12.1-alpha.54                                ...           4 years ago
  • 0.11.1-alpha.53                                ...           4 years ago
  • 0.11.1-alpha.44                                ...           4 years ago
  • 0.11.1-alpha.36                                ...           4 years ago
  • 0.11.1-alpha.35                                ...           4 years ago
  • 0.11.1-alpha.15                                ...           4 years ago
  • 0.11.0                                ...           4 years ago
  • 0.11.1-alpha.48                                ...           4 years ago
  • 0.10.3-alpha.41                                ...           4 years ago
  • 0.10.3-alpha.40                                ...           4 years ago
  • 0.10.3-alpha.35                                ...           4 years ago
  • 0.10.3-alpha.34                                ...           4 years ago
  • 0.10.3-canary.0                                ...           4 years ago
  • 0.10.2                                ...           4 years ago
  • 0.10.1                                ...           4 years ago
  • 0.10.0                                ...           4 years ago
  • 0.9.0                                ...           4 years ago
  • 0.8.3                                ...           4 years ago
  • 0.8.2                                ...           4 years ago
  • 0.8.1                                ...           4 years ago
  • 0.8.0                                ...           5 years ago
  • 0.7.0                                ...           5 years ago
  • 0.6.1                                ...           5 years ago
  • 0.6.0                                ...           5 years ago
  • 0.5.2                                ...           5 years ago
  • 0.5.1                                ...           5 years ago
  • 0.5.0                                ...           5 years ago
  • 0.4.0                                ...           5 years ago
  • 0.3.3                                ...           5 years ago
  • 0.3.2                                ...           5 years ago
  • 0.3.1                                ...           5 years ago
  • 0.3.0                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.1                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (23)
Dependents (56)

© 2010 - cnpmjs.org x YWFE | Home | YWFE