lightstep / lightstep-tracer-javascript

Lightstep distributed tracing library for Node.js and the browser
https://lightstep.com
MIT License
77 stars 66 forks source link
opentracing

lightstep-tracer [Deprecated]

This instrumentation is no longer recommended. Please review documentation on setting up and configuring the OpenTelemetry Node.js Launcher or OpenTelemetry JS (Browser) for more information on migrating to OpenTelemetry.

npm version Circle CI MIT license

In August 2023, Lightstep became ServiceNow Cloud Observability To ease the transition, all code artifacts will continue to use the Lightstep name. You don't need to do anything to keep using this repository.

LightStep distributed tracing library for Node.js and the browser.

Installation

npm install --save lightstep-tracer opentracing

All modern browsers and Node versions >= 12 are supported. Users who need support for Node 8 and 10 can use v0.32.0 and prior.

Getting started

To use LightStep as the OpenTracing binding, initialize the global Tracer with the LightStep implementation:

var opentracing = require('opentracing');
var lightstep   = require('lightstep-tracer');

opentracing.initGlobalTracer(new lightstep.Tracer({
    access_token   : '{your_access_token}',
    component_name : '{your_service_or_app_name}',
}));

The LightStep JavaScript Tracing Cookbook is a good next stop for information on how to quickly instrument your system. If you want to try something out quickly in your browser code, see the browser quick start example.

The browser version of the code can be explicitly included using the following, which can be helpful in some browserify (or similar) setups:

var lightstep = require('lightstep-tracer/browser');

LightStep-specific API

The OpenTracing standard JavaScript API is documented here. The following describes LightStep-specific options and methods.

LightStep


new Tracer(options)

Required options

Standard options

Browser-specific initialization options

node-specific initialization options

Non-standard options

NOTE: Future API compatibility on non-standard options is not guaranteed.

An example configuration using custom propagators might look like:

const tracer = new lightstep.Tracer({
  propagators: {
    [opentracing.FORMAT_HTTP_HEADERS]: new lightstep.DDPropagator(),
    [opentracing.FORMAT_TEXT_MAP]: new lightstep.B3Propagator()
  }
})

SpanImp


generateTraceURL()

Returns an absolute URL to the LightStep application for the trace containing this span. It is safe to call this method after finish().

...
span.finish();

var url = span.generateTraceURL())
console.log('View the trace for this span at:', url);

Release process using circleCI

  1. Run command
    make release RELEASE_TYPE=patch

License

The MIT License.

Copyright (c) 2016, LightStep