All Products
Search
Document Center

Managed Service for OpenTelemetry:Record and analyze exceptions with open source tracing clients

Last Updated:Jun 08, 2026

When your application throws exceptions, Managed Service for OpenTelemetry detects them in your trace data and aggregates the results on the Exceptions page, giving you visibility into error types, stack traces, and affected traces. With automatic instrumentation (OpenTelemetry or SkyWalking agents), exceptions are captured without code changes. For manual instrumentation, this page explains how to record exceptions on spans for each supported tracing protocol.

Prerequisites

Before you begin, make sure that you have:

  • An open source tracing client configured to report trace data to Managed Service for OpenTelemetry. For setup instructions, see Connection description

How Managed Service for OpenTelemetry detects exceptions

The detection mechanism depends on the tracing protocol your application uses:

Protocol

Where exceptions are stored

Detection trigger

OpenTelemetry

Event attributes on a span

exception.type attribute present

OpenTracing (Jaeger, Zipkin, SkyWalking)

Log fields on a span

event field set to "error" and error.kind field present

Once detected, exceptions appear on the Exceptions page with full stack traces, if provided.

Record exceptions with OpenTelemetry

The OpenTelemetry semantic conventions for exceptions define how exception data attaches to spans. Managed Service for OpenTelemetry checks for the following event attributes:

Attribute

Required

Description

exception.type

Yes

Exception class name. Triggers exception detection.

exception.message

No

Exception message text.

exception.stacktrace

No

Full stack trace string. Displayed on the Exceptions page.

Use the SDK (recommended)

OpenTelemetry SDKs provide a recordException method that populates these attributes automatically from the caught exception object.

Span span = myTracer.startSpan("spanName");
try {
    // Business logic
} catch (Throwable e) {
    span.recordException(e);
    throw e;
} finally {
    span.end();
}

recordException creates a span event with exception.type, exception.message, and exception.stacktrace populated from the caught exception.

Note

The examples on this page use the OpenTelemetry SDK for Java. The recordException method is available in all OpenTelemetry SDK languages. Refer to the OpenTelemetry documentation for language-specific usage.

Use automatic instrumentation

If your application uses an OpenTelemetry agent or framework with automatic instrumentation, exceptions are captured and reported without code changes. Managed Service for OpenTelemetry detects the exception data and displays it on the Exceptions page.

Record exceptions with OpenTracing

The OpenTracing semantic conventions store exception data in span log fields. Managed Service for OpenTelemetry checks for the following log fields:

Log field

Required

Description

event

Yes

Must be set to "error". Triggers exception detection.

error.kind

Yes

Exception class name.

message

No

Exception message text.

stack

No

Full stack trace string. Displayed on the Exceptions page.

Jaeger and Zipkin: use the OpenTracing SDK

The following Java example records exceptions on spans using the OpenTracing SDK:

public static void test() {
    Tracer tracer = GlobalTracer.get();
    Span span = tracer.buildSpan("spanName").start();

    try (Scope scope = tracer.activateSpan(span)) {
        // Business logic
    } catch (Exception e) {
        onException(e, span);
    } finally {
        span.finish();
    }
}

public static void onException(Throwable throwable, Span span) {
    if (span != null) {
        Tags.ERROR.set(span, Boolean.TRUE);
        if (throwable != null) {
            span.log(errorLogs(throwable));
        }
    }
}

private static Map<String, Object> errorLogs(Throwable throwable) {
    Map<String, Object> errorLogs = new HashMap<>();
    errorLogs.put("event", Tags.ERROR.getKey());
    errorLogs.put("error.object", throwable);
    errorLogs.put("error.kind", throwable.getClass().getName());
    String message = throwable.getCause() != null
        ? throwable.getCause().getMessage()
        : throwable.getMessage();
    if (message != null) {
        errorLogs.put("message", message);
    }
    StringWriter sw = new StringWriter();
    throwable.printStackTrace(new PrintWriter(sw));
    errorLogs.put("stack", sw.toString());
    return errorLogs;
}

Key points in this example:

  • Tags.ERROR.set(span, Boolean.TRUE) marks the span as an error span.

  • The event field is set to the value of Tags.ERROR.getKey(), which resolves to "error".

  • The stack field captures the full stack trace via StringWriter and PrintWriter.

SkyWalking: automatic exception capture

SkyWalking agents use non-intrusive instrumentation to capture exceptions automatically. No code changes are needed. In most cases, the agent records exception data and reports it to Managed Service for OpenTelemetry, where it appears on the Exceptions page.

View and analyze exception data

After your application reports exceptions, Managed Service for OpenTelemetry aggregates the data on the Exceptions page. Open the console to review:

  • Exception types and occurrence counts

  • Stack traces for each exception

  • Affected spans and traces

Use this data to identify recurring errors, track exception trends, and prioritize fixes based on frequency and impact.

For detailed analysis capabilities, see Exception analysis.