Skip to content

[feature request] Automatically detect exceptions and add Activity event #6421

@MartenM

Description

@MartenM

Package

OpenTelemetry.Api.ProviderBuilderExtensions

The suggestion

Hi there,

I am using the Opentelemetry package and thus far is has served me rather well. One thing I noticed is that we have the ability to automatically set the ActivityStatusCode using the traceProvider.SetErrorStatusOnException() method.

However this method does not attach events as described on opentelemetry/docs. This can be done manually using the method activity?.AddException(ex); however this is a bit cumbersome and might not even capture all exceptions.

My suggestion is to add an extra parameter to SetErrorStatusOnException called attachEvent that defaults to false, but when enabled will call AddException(ex). Not everyone wants to have exceptions events in their traces, but for a big portion it might be useful.

Thoughts? I am willing to create a PR for this feature if it's deemed useful.

Which alternative solutions or features have you considered?

Custom processor

Additional context

Related PR but for error messages: #1853

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions