BugSnag

Integrate Aspecto Distributed Tracing with BugSnag Error Monitoring

BugSnag enables you to collect application errors across your entire stack, helping you identify and address issues efficiently. In distributed applications, errors often lack context, representing only the effect rather than the cause. To gain a comprehensive understanding of the error's root cause, you need visibility into your entire system. Distributed traces provide this insight by tracing the cause-and-effect relationships across your services. By integrating your errors with traces, you achieve complete observability of your system.

Learn more about BugSnag Error Monitoring here

Investigating Errors

By integrating Aspecto with BugSnag, your BugSnag errors will be linked to the relevant distributed trace within Aspecto, allowing you to see the full context of the error.

You associate the error to the trace using the following metadata:

  • Aspecto.trace_id (required): The ID of the OpenTelemetry trace that was current when the error occurred.

  • Aspecto.workspace_id (optional): Optionally, you can include the Workspace ID, which can be found in the Aspecto platform. If not provided, the link will point to the default workspace. You can find your Workspace ID here

  • Aspecto.sampled (optional, defaults to true): Set this to true or false depending on whether the trace containing the error was sampled. If it is false, the BugSnag dashboard will indicate that the trace won't be available in Aspecto.

Code snippets

To implement this integration, use a callback within your BugSnag setup code. See the snippets below for popular languages. If you need help integrating Aspecto for an unlisted language, please contact us.

import { trace, context } from '@opentelemetry/api';
import Bugsnag from '@bugsnag/js'

Bugsnag.start({
    apiKey: 'api key goes here', //insert Bugsnag's api key
    onError: function (event: any) {
        const spanContext = trace.getSpanContext(context.active());
        const traceId = spanContext.traceId
        const sampled = spanContext.traceFlags === TraceFlags.SAMPLED;
        event.addMetadata('Aspecto', { 
            trace_id: traceId,
            workspace_id: 'optional workspace id',// Optional,
            sampled: sampled
      });
    }
})

Last updated