To integrate with Rollbar, you need to add Rollbar configuration to your instrumentation. If you are using Browser JavaScript, then you also need to add a Rollbar error handler.

Configure the Tracer for Rollbar

Add the Rollbar Configuration to your tracer Instance.

1
2
3
4
5
6
7
8
9
10
11
12
13
// Initialize LS tracer
const tracer = require('ls-trace').init({ 
	experimental: {b3: true}
});

const Rollbar = require('rollbar');
const rollbar = new Rollbar({
	accessToken: process.env.ROLLBAR_ACCESS_TOKEN,
	captureUncaught: true,
	captureUnhandledRejections: true,
	// add your tracer here
	tracer: tracer
});

Add an Error Handler (Browser JS Only)

For Node.js, where you handle errors, be sure to use the Rollbar error handler.

For use with JavaScript in the browser, you need to implement an explicit error handler for Rollbar.

The error handler should:

  • Use the OpenTelemetry or OpenTracing library to get the active span
  • Set three tags:
    • error to true
    • rollbar.error_uuid to the UUID of the Rollbar Item
    • rollbar.has_error to true
  • Set any additional tags or custom Rollbar properties that will aid in analysis
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var item = /* Rollbar error item */;
var span = this.tracer.scope().active();
if (span) {
	span.setTag('error', true);
	span.setTag('rollbar.err_uuid', item.uuid);
	span.setTag('rollbar.has_error' true);

	//add span ID & trace ID to occurrence
	var opentracingSpanId = span.context().toSpanId();
	var opentracingTraceId = span.context(). toTraceId();
	item.custom = item.custom || {};
	item.custom.opentracing_span_id = opentracingSpanId;
	item.custom.opentracing_trace_id = opentracingTraceId;
}


What Did We Learn?
The integration uses Rollbar’s SDK to capture errors at the span level. The SDK then uses the Lightstep API to capture a Snapshot of the telemetry data for display in Lightstep.