From c7b115fbb7728e8655724aeaae02a2bcc507e48a Mon Sep 17 00:00:00 2001 From: Reiley Yang Date: Fri, 5 Mar 2021 19:05:56 -0800 Subject: [PATCH] address corner case in test --- .../Trace/ExceptionProcessorTest.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/OpenTelemetry.Tests/Trace/ExceptionProcessorTest.cs b/test/OpenTelemetry.Tests/Trace/ExceptionProcessorTest.cs index d4cd9a38c9a..97e4eeaec36 100644 --- a/test/OpenTelemetry.Tests/Trace/ExceptionProcessorTest.cs +++ b/test/OpenTelemetry.Tests/Trace/ExceptionProcessorTest.cs @@ -56,15 +56,24 @@ public void ActivityStatusSetToErrorWhenExceptionProcessorEnabled() using (activity3 = activitySource.StartActivity("Activity3")) { } - - activity5 = activitySource.StartActivity("Activity5"); } finally { using (activity4 = activitySource.StartActivity("Activity4")) { } + } + try + { + throw new Exception("Oops!"); + } + catch (Exception) + { + activity5 = activitySource.StartActivity("Activity5"); + } + finally + { activity5.Dispose(); } @@ -77,7 +86,10 @@ public void ActivityStatusSetToErrorWhenExceptionProcessorEnabled() Assert.Equal(StatusCode.Unset, activity4.GetStatus().StatusCode); Assert.Null(activity4.GetTagValue("otel.exception_pointers")); Assert.Equal(StatusCode.Unset, activity5.GetStatus().StatusCode); +#if !NETFRAMEWORK + // In this rare case, the following Activity tag will not get cleaned up due to perf consideration. Assert.NotNull(activity5.GetTagValue("otel.exception_pointers")); +#endif } [Fact]