Miss any of our Open RFC calls?Watch the recordings here! »

@opentelemetry/tracing

0.9.0 • Public • Published

OpenTelemetry Tracing SDK

Gitter chat NPM Published Version dependencies devDependencies Apache License

The tracing module contains the foundation for all tracing SDKs of opentelemetry-js.

Used standalone, this module provides methods for manual instrumentation of code, offering full control over span creation for client-side JavaScript (browser) and Node.js.

It does not provide automated instrumentation of known libraries, context propagation for asynchronous invocations or distributed-context out-of-the-box.

For automated instrumentation for Node.js, please see @opentelemetry/node.

Installation

npm install --save @opentelemetry/api
npm install --save @opentelemetry/tracing

Usage

const opentelemetry = require('@opentelemetry/api');
const { BasicTracerProvider } = require('@opentelemetry/tracing');
 
// To start a trace, you first need to initialize the Tracer provider.
// NOTE: The default OpenTelemetry tracer provider does not record any tracing information.
//       Registering a working tracer provider allows the API methods to record traces.
new BasicTracerProvider().register();
 
// To create a span in a trace, we used the global singleton tracer to start a new span.
const span = opentelemetry.trace.getTracer('default').startSpan('foo');
 
// Set a span attribute
span.setAttribute('key', 'value');
 
// We must end the spans so they become available for exporting.
span.end();

Example

See examples/basic-tracer-node for an end-to-end example, including exporting created spans.

Useful links

License

Apache 2.0 - See LICENSE for more information.

Install

npm i @opentelemetry/tracing

DownloadsWeekly Downloads

17,425

Version

0.9.0

License

Apache-2.0

Unpacked Size

65.2 kB

Total Files

37

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar