Skip to content

Add error information and filtering to spans #13119

Closed
@cuchi

Description

@cuchi

Problem Statement

In the context of traces/transactions/spans:

Spans are being tagged with the internal_error status when either a global unhandledRejection or error happen. This is expected, but we don't have the error information in the faulty span.

In our case, we have some filters for errors that should be ignored (with the ignoreErrors option), but transactions that fail because of these errors are still being tagged with internal_error and triggering alerts that we created to track failure rates.

  • The error logic for spans doesn't use the ingoreErrors option
  • We can't filter the spans programmatically because the error information is missing from the span
  • We can't filter the spans in the alert queries for the same reason

In the current state, we just have a bunch of failed transactions that point to no error and just render our failure rate (%) alert useless.

Solution Brainstorm

I tried to actively use the ignoreErrors logic when capturing these errors: #13084
But the solution breaks some of the scope between integrations.

A better solution (IMHO), would be to just capture the error information inside the span object: (here)

function errorCallback(error: any): void {
  const activeSpan = getActiveSpan();
  const rootSpan = activeSpan && getRootSpan(activeSpan);
  if (rootSpan) {
    const message = 'internal_error';
    DEBUG_BUILD && logger.log(`[Tracing] Root span: ${message} -> Global error occured`);
    rootSpan.setStatus({ code: SPAN_STATUS_ERROR, message });
    rootSpan.setError(error); // Here
  }
}

...so we're able to do what we want with that info:

beforeSendSpan(span) {
  if (whatever(span.error)) {
    return null;
  }
  return span;
},

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Waiting for: Community

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions