OpenCensus Object Exporter allows the user to collect and access traces with OpenCensus Node.js.

Usage no npm install needed!

<script type="module">
  import opencensusExporterObject from 'https://cdn.skypack.dev/@opencensus/exporter-object';


OpenCensus Object Exporter

Gitter chat

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.


Install OpenCensus Object Trace Exporter with:

npm install @opencensus/nodejs
npm install @opencensus/exporter-object


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});



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.


Useful links