@zaplabs/opencensus-exporter-object
v0.0.14
Published
OpenCensus Object Exporter allows the user to collect and access traces with OpenCensus Node.js.
Downloads
4
Maintainers
Readme
OpenCensus Object Exporter
OpenCensus Object Trace Exporter allows the user to collect and programmatically access traces with OpenCensus Node.js. This module is useful for when you need to access collected spans programmatically, for example for testing purposes.
Installation
Install OpenCensus Object Trace Exporter with:
npm install @opencensus/nodejs
npm install @opencensus/exporter-object
Usage
For javascript:
const tracing = require('@opencensus/nodejs');
const { ObjectTraceExporter } = require('@opencensus/exporter-object');
const exporter = new ObjectTraceExporter();
Similarly for Typescript:
import * as tracing from '@opencensus/nodejs';
import { ObjectTraceExporter } from '@opencensus/exporter-object';
const exporter = new ObjectTraceExporter();
Now, register the exporter and start tracing.
tracing.start({'exporter': exporter});
or
tracing.registerExporter(exporter).start();
Viewing your traces
exporter.startedSpans.forEach((span: Span)) => {}
exporter.endedSpans.forEach((span: Span)) => {}
exporter.publishedSpans.forEach((span: Span)) => {}
Reset exporter
Empties startedSpans
, endedSpans
and publishedSpans
span stores.
exporter.reset();
Useful links
- For more information on OpenCensus, visit: https://opencensus.io/
- To checkout the OpenCensus for Node.js, visit: https://github.com/census-instrumentation/opencensus-node
- For help or feedback on this project, join us on gitter