Skip to content

nvenegas/opentelemetry-js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Getting Started   •   API Documentation   •  

GitHub release (latest by date including pre-releases) Codecov Status license
Build Status Beta

Contributing   •   Development Guide   •   Benchmarks   •   Examples


About this project

This is the JavaScript version of OpenTelemetry, a framework for collecting traces and metrics from applications.

Compatibility Matrix

API Version Core version Contrib Version
0.20.x 0.20.x 0.20.x
v1.0.0-rc.3 0.19.x 0.16.x
0.18.x 0.18.x 0.14.x
0.17.x ------
0.16.x ------
0.15.x 0.13.x
0.14.x 0.12.x
0.13.x ------
0.12.x 0.11.x
0.11.x 0.10.x

Versioning

The current version for each package can be found in the respective package.json file for that module. For additional details see the versioning and stability document in the specification.

Quick start

Application Owner

To get started tracing your own application, see the Getting Started Guide. For more information about automatic instrumentation see @opentelemetry/node, which provides auto-instrumentation for Node.js applications. If the automatic instrumentation does not suit your needs, or you would like to create manual traces, see @opentelemetry/tracing

Library Author

If you are a library author looking to build OpenTelemetry into your library, please see the documentation. As a library author, it is important that you only depend on properties and methods published on the public API. If you use any properties or methods from the SDK that are not officially a part of the public API, your library may break if an Application Owner uses a different SDK implementation.

Supported Runtimes

Platform Version Supported
Node.JS v14 âś…
Node.JS v12 âś…
Node.JS v10 âś…
Node.JS v8 See Node Support below
Web Browsers âś… See Browser Support below

Node Support

Automated tests are run using the latest release of each currently active version of Node.JS. While Node.JS v8 is no longer supported by the Node.JS team, the latest version of Node.JS v8 is still included in our testing suite. Please note that versions of Node.JS v8 prior to v8.5.0 will NOT work, because OpenTelemetry Node depends on the perf_hooks module introduced in v8.5.0

Browser Support

Automated browser tests are run in the latest version of Headless Chrome. There is currently no list of officially supported browsers, but OpenTelemetry is developed using standard web technologies with wide support and should work in currently supported versions of major browsers.

Feature Status

As of v0.19.0:

Feature Status
B3 Propagation Beta
Zipkin Export Beta
Jaeger Propagation Beta
Jaeger Export Beta
OpenTracing Bridge Beta
Resources Beta
Tracing Beta
W3C Baggage Beta
W3C Trace Context Beta
Metrics API Development
Metrics SDK Development

For a more detailed breakdown of feature support see the specification compliance matrix.

Contributing

We'd love your help!. Use tags up-for-grabs and good first issue to get started with the project. For instructions to build and make changes to this project, see the CONTRIBUTING guide.

We have a weekly SIG meeting! See the community page for meeting details and notes.

Approvers (@open-telemetry/js-approvers):

Find more about the approver role in community repository.

Maintainers (@open-telemetry/js-maintainers):

Find more about the maintainer role in community repository.

Thanks to all the people who already contributed

Thanks to all previous approvers and maintainers

Packages

API

Package Description
@opentelemetry/api This package provides TypeScript interfaces, enums and no-op implementations for the OpenTelemetry core trace and metrics model. It is intended for use both on the server and in the browser.
@opentelemetry/core This package provides default and no-op implementations of the OpenTelemetry api for trace and metrics. It's intended for use both on the server and in the browser.

Implementation / SDKs

Package Description
@opentelemetry/tracing This module provides a full control over instrumentation and span creation. It doesn't load async_hooks or any instrumentation by default. It is intended for use both on the server and in the browser.
@opentelemetry/metrics This module provides instruments and meters for reporting of time series data.
@opentelemetry/node This module provides automatic tracing for Node.js applications. It is intended for use on the server only.
@opentelemetry/web This module provides automated instrumentation and tracing for Web applications. It is intended for use in the browser only.

Compatible Exporters

OpenTelemetry is vendor-agnostic and can upload data to any backend with various exporter implementations. Even though, OpenTelemetry provides support for many backends, vendors/users can also implement their own exporters for proprietary and unofficially supported backends.

See the OpenTelemetry registry for a list of exporters available.

Instrumentations

OpenTelemetry can collect tracing data automatically using instrumentations. Vendors/Users can also create and use their own. Currently, OpenTelemetry supports automatic tracing for:

Node Instrumentations

Core
Contrib

These plugins are hosted at https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node

Web Instrumentations

Core
Contrib

These instrumentations are hosted at https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/web

To request automatic tracing support for a module not on this list, please file an issue. Alternatively, you can write an instrumentation yourself.

Shims

Package Description
@opentelemetry/shim-opentracing OpenTracing shim allows existing OpenTracing instrumentation to report to OpenTelemetry

Upgrade guidelines

0.20.x to x

0.19.x to 0.20.0

  • HttpBaggage renamed to HttpBaggagePropagator

  • HttpTraceContext renamed to HttpTraceContextPropagator

  • JaegerHttpTracePropagator renamed to JaegerPropagator

  • serviceName configuration removed from Collector exporters. Use service.name Resource attribute instead.

0.18.x to 0.19.0

  • API is now a peer dependency. This means that users will need to include @opentelemetry/api as a dependency of their project in order to use the SDK. NPM version 7+ (Node 15+) should do this automatically.

  • All plugins have been removed in favor of instrumentations.

  • The @opentelemetry/propagator-b3 package previously exported three propagators: B3Propagator,B3SinglePropagator, and B3MultiPropagator, but now only exports the B3Propagator. It extracts b3 context in single and multi-header encodings, and injects context using the single-header encoding by default, but can be configured to inject context using the multi-header endcoding during construction: new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER }). If you were previously using the B3SinglePropagator or B3MultiPropagator directly, you should update your code to use the B3Propagator with the appropriate configuration. See the readme for full details and usage.

  • Sampling configuration via environment variable has changed. If you were using OTEL_SAMPLING_PROBABILITY then you should replace it with OTEL_TRACES_SAMPLER=parentbased_traceidratio and OTEL_TRACES_SAMPLER_ARG=<number> where <number> is a number in the [0..1] range, e.g. "0.25". Default is 1.0 if unset.

0.17.0 to 0.18.0

  • diag.setLogLevel is removed and LogLevel can be set by an optional second parameter to setLogger

PR-1975

  • Breaking change - The resulting resource MUST have all attributes that are on any of the two input resources. If a key exists on both the old and updating resource, the value of the updating resource MUST be picked - previously it was opposite.

0.16.0 to 0.17.0

PR-1880 feat(diag-logger): introduce a new global level api.diag for internal diagnostic logging

PR-1925 feat(diag-logger): part 2 - breaking changes - remove api.Logger, api.NoopLogger, core.LogLevel, core.ConsoleLogger

  • These PR's remove the previous Logger and LogLevel implementations and change the way you should use the replacement DiagLogger and DiagLogLevel, below are simple examples of how to change your existing usages.

Setting the global diagnostic logger

The new global api.diag provides the ability to set the global diagnostic logger setLogger() and logging level setLogLevel(), it is also a DiagLogger implementation and should be directly to log diagnostic messages.

All included logger references have been removed in preference to using the global api.diag directly, so you no longer need to pass around the logger instance via function parameters or included as part of the configuration for a component.

import { diag, DiagConsoleLogger, DiagLogLevel } from "@opentelemetry/api";
// Setting the default Global logger to use the Console
// And optionally change the logging level (Defaults to INFO)
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.ERROR)

Using the logger anywhere in the code

import { diag } from "@opentelemetry/api";

// Remove or make optional the parameter and don't use it.
export function MyFunction() {
  diag.debug("...");
  diag.info("...");
  diag.warn("...");
  diag.error("...");
  diag.verbose("..");
}

Setting the logger back to a noop

import { diag } from "@opentelemetry/api";
diag.setLogger();

PR-1855 Use instrumentation loader to load plugins and instrumentations

  • Providers do no load the plugins anymore. Also PluginLoader has been removed from providers, use registerInstrumentations instead
//Previously in node
const provider = new NodeTracerProvider({
  plugins: {
    '@grpc/grpc-js': {
      enabled: true,
      path: '@opentelemetry/plugin-grpc-js',
    },
  }
});

// Now
const provider = new NodeTracerProvider();
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
registerInstrumentations({
  instrumentations: [
    {
      plugins: {
        '@grpc/grpc-js': {
          enabled: true,
          path: '@opentelemetry/plugin-grpc-js',
        },
      }
    }
  ],
  tracerProvider: provider,
});

// or if you want to load only default instrumentations / plugins
registerInstrumentations({
  tracerProvider: provider,
});

//Previously in browser
const provider = new WebTracerProvider({
  plugins: [
    new DocumentLoad()
  ]
});
// Now
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const provider = new WebTracerProvider();
registerInstrumentations({
  instrumentations: [
    new DocumentLoad(),
  ],
});
  • registerInstrumentations supports loading old plugins and instrumentations together. It also supports setting tracer provider and meter provider on instrumentations

PR-1874 More specific API type names

Some types exported from "@opentelemetry/api" have been changed to be more specific.

  • AttributeValue renamed to SpanAttributeValue
  • Attributes renamed to SpanAttributes
  • EntryTtl renamed to BaggageEntryTtl
  • EntryValue renamed to BaggageEntryValue
  • Status renamed to SpanStatus
  • StatusCode renamed to SpanStatusCode

0.15.0 to 0.16.0

PR-1863 removed public attributes keepAlive and httpAgentOptions from nodejs CollectorTraceExporter and CollectorMetricExporter

0.14.0 to 0.15.0

PR-1764 removed some APIs from Tracer:

  • Tracer.getCurrentSpan(): use api.getSpan(api.context.active())
  • Tracer.withSpan(span): use api.context.with(api.setSpan(api.context.active(), span))
  • Tracer.bind(target): use api.context.bind(target)

PR-1797 chore!: split metrics into its own api package:

  • Any references to require("@opentelemetry/api").metrics will need to be changed to require("@opentelemetry/api-metrics").metrics

PR-1725 Use new gRPC default port

  • The default port used by @opentelemetry/exporter-collector-grpc is changed from 55680 to 4317

PR-1749 chore: improve naming of span related context APIs

  • Rename [gs]etActiveSpan() to [gs]etSpan()
  • Rename setExtractedSpanContext() to setSpanContext()
  • Rename getParentSpanContext() to getSpanContext()

Useful links

License

Apache 2.0 - See LICENSE for more information.

About

OpenTelemetry JavaScript Client

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 97.3%
  • JavaScript 2.2%
  • Other 0.5%