Install the package using
npm install --save opentracing
The package contains a example using a naive
MockTracer implementation. To run the example:
The output should look something like:
Spans:parent_span - 1521mstag 'custom':'tag value'tag 'alpha':'1000'child_span - 503mstag 'alpha':'200'tag 'beta':'50'
var http = ;var opentracing = ;// NOTE: the default OpenTracing tracer does not record any tracing information.// Replace this line with the tracer implementation of your choice.var tracer = ;var span = tracer;var opts =host : 'example.com'method: 'GET'port : '80'path: '/';http;
As noted in the source snippet, the default behavior of the
opentracing package is to act as a "no op" implementation. To capture and make the tracing data actionable, the
tracer object should be initialized with the OpenTracing implementation of your choice as in the pseudo-code below:
var CustomTracer = ;var tracer = ;
The package contains two bundles built with webpack that can be included using a standard
<script> tag. The library will be exposed under the global
dist/opentracing-browser.min.js- minified, no runtime checks
dist/opentracing-browser.js- debug version with runtime checks
The library also provides a global singleton tracer for convenience. This can be set and accessed via the following:
opentracing;var tracer = opentracing;
globalTracer() returns a wrapper on the actual tracer object. This is done for convenience of use as it ensures that the function will always return a non-null object. This can be helpful in cases where it is difficult or impossible to know precisely when
initGlobalTracer is called (for example, when writing a utility library that does not control the initialization process). For more precise control, individual
Tracer objects can be used instead of the global tracer.
var opentracing = ;
opentracing/debug will include a version of the library with additional runtime checks that are useful for debugging but not desirable for production use.
There is a hosted copy of the current generated ESDoc API Documentation here.
See the OpenTracing website for general information on contributing to OpenTracing.
The project is built using a
make buildcreates the compiled, distributable code
make testruns the tests
This section is intended for developers wishing to implement their own tracers. Developers who simply wish to use OpenTracing can safely ignore this information.
Implementations can subclass
opentracing.Span, and the other API classes to build a OpenTracing tracer.
Lastly, optionally implementations may choose to subclass
opentracing.Trace, etc. and implement the underscore prefixed methods such as
_addTag to pick up a bit of common code implemented in the base classes. This is entirely optional.
mocha is being used for unit testing, the
api_compatibility.js file can be used to test the custom tracer. The file exports a single function that expects as an argument a function that will return a new instance of the tracer.
var apiCompatibilityChecks = ;;
An minimal example tracer is provided in the
src/mock_tracer directory of the source code.