You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Capturing exception and setting Activity status to ERROR could be a common need. It is a bit annoying to do this all over the places.
Describe the solution you'd like:
I wonder if it would be cool to have a processor that automatically detects exception when an Activity ended, and set the status to ERROR accordingly.
Describe alternatives you've considered.
usingSystem;usingSystem.Diagnostics;usingSystem.Runtime.ExceptionServices;usingSystem.Runtime.InteropServices;usingOpenTelemetry;usingOpenTelemetry.Trace;classSehDetectionProcessor:BaseProcessor<Activity>{publicoverridevoidOnEnd(Activityactivity){if(Marshal.GetExceptionPointers()!=IntPtr.Zero){activity.SetStatus(Status.Error);}}}classProgram{staticreadonlyActivitySourceDemoSource=newActivitySource("DemoSource");staticvoidMain(){AppDomain.CurrentDomain.UnhandledException+=UnhandledExceptionHandler;usingvartracerProvider=Sdk.CreateTracerProviderBuilder().AddSource("DemoSource").AddProcessor(newSehDetectionProcessor()).AddConsoleExporter().Build();using(DemoSource.StartActivity("Foo")){using(DemoSource.StartActivity("Bar")){thrownewException("Oops!");}}}staticvoidUnhandledExceptionHandler(objectsource,UnhandledExceptionEventArgsargs){varactivity=Activity.Current;while(activity!=null){activity.Dispose();// TODO: probably check if the activity is already disposed/finished by looking at the end time?activity=activity.Parent;}}}
The text was updated successfully, but these errors were encountered:
Feature Request
Is your feature request related to a problem?
Capturing exception and setting Activity status to
ERROR
could be a common need. It is a bit annoying to do this all over the places.Describe the solution you'd like:
I wonder if it would be cool to have a processor that automatically detects exception when an Activity ended, and set the status to ERROR accordingly.
Describe alternatives you've considered.
The text was updated successfully, but these errors were encountered: