0.0.7 • Published 5 years ago

@opencensus/web-propagation-b3 v0.0.7

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
5 years ago

OpenCensus B3 format propagation for web browsers

Gitter chat

For overview and usage info see the main OpenCensus Web readme.

OpenCensus B3 format propagation provides utilities to serialize and deserialize a trace context header in the B3 Format format.

The library is in alpha stage and the API is subject to change.

Usage

Currently the primary intended usage of OpenCensus Web is to collect spans from the resource timing waterfall of an initial page load and trace on-page user interactions with a series of features like automatic tracing for clicks and route transitions, custom spans, and browser Performance API data. See the OpenCensus Web readme for details.

This is used to propagate trace contextspans for XHRs in the user interactions, serializing a B3 headers to send along to XHR calls.

It gets passed as an option to the startTracing function as follows:

// Use @opencensus/web-instrumentation-zone-peer-dep instead in case your app
// already uses `Zone.js`.
import { startTracing } from '@opencensus/web-instrumentation-zone';
import { B3Format } from '@opencensus/web-propagation-b3';

window.ocAgent = 'https://example.com/my-opencensus-agent-endpoint';
window.ocSampleRate = 1.0; // Sample at 100% for test only. Default is 1/10000.
// Send the trace header to all hosts.
window.ocTraceHeaderHostRegex = /.*/;

// This methods starts the tracing and exports the initial page load trace.
// As the tracing has started, the coming user interactions ares also traced.
startTracing({ propagation: new B3Format() });

Useful links

License

Apache 2.0 - See LICENSE for more information.