-
Notifications
You must be signed in to change notification settings - Fork 794
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ScopeManagerShim - do not store not recorded spans
- Loading branch information
Showing
2 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
test/OpenTelemetry.Shims.OpenTracing.Tests/ScopeManagerShimNotRecordedTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using OpenTelemetry.Trace; | ||
using Xunit; | ||
|
||
namespace OpenTelemetry.Shims.OpenTracing.Tests; | ||
|
||
public class ScopeManagerShimNotRecordedTests | ||
{ | ||
[Fact] | ||
public void MultipleNotRecordedSpans_ReturnNoopInstance_DoNotThrow() | ||
{ | ||
var tracer = TracerProvider.Default.GetTracer("TracerName"); | ||
var scopeManagerShim = new ScopeManagerShim(); | ||
var span1 = new SpanShim(tracer.StartSpan("Span-1")); | ||
var span2 = new SpanShim(tracer.StartSpan("Span-2")); | ||
|
||
var exception = Record.Exception(() => | ||
{ | ||
using var scope1 = scopeManagerShim.Activate(span1, true); | ||
using var scope2 = scopeManagerShim.Activate(span1, true); | ||
}); | ||
|
||
Assert.Same(TelemetrySpan.NoopInstance, span1.Span); | ||
Assert.Same(TelemetrySpan.NoopInstance, span2.Span); | ||
Assert.False(span1.Span.IsRecording); | ||
Assert.False(span2.Span.IsRecording); | ||
Assert.Null(exception); | ||
} | ||
} |