Skip to content

Commit d4c6e5d

Browse files
committed
Set activity status to error when an exception is recorded
Fixes #77
1 parent 3e526e6 commit d4c6e5d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/Merq.Core/Telemetry.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@ static class Telemetry
2222

2323
public static void RecordException(this Activity? activity, Exception e)
2424
{
25-
// See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/exceptions.md
26-
activity?.AddEvent(new ActivityEvent("exception", tags: new()
25+
if (activity != null)
2726
{
28-
{ "exception.message", e.Message },
29-
{ "exception.type", e.GetType().FullName },
30-
{ "exception.stacktrace", e.ToString() },
31-
}));
27+
activity.SetStatus(ActivityStatusCode.Error, e.Message);
28+
29+
// See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/exceptions.md
30+
activity.AddEvent(new ActivityEvent("exception", tags: new()
31+
{
32+
{ "exception.message", e.Message },
33+
{ "exception.type", e.GetType().FullName },
34+
{ "exception.stacktrace", e.ToString() },
35+
}));
36+
}
3237
}
3338
}

0 commit comments

Comments
 (0)