Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Using AsyncLocalScopeManager as a default tracer's ScopeManager #131

Merged
merged 3 commits into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/Petabridge.Tracing.Zipkin.Tests/TracerSpec.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using FluentAssertions;
using Xunit;

namespace Petabridge.Tracing.Zipkin.Tests
{
public class TracerSpec
{
[Fact]
public void Should_have_active_span_when_scope_is_used()
{
var url = "http://localhost:9411";
using (var tracer = new ZipkinTracer(new ZipkinTracerOptions(url, "ZipkinTest", debug: true)))
{
using (var scope = tracer.BuildSpan("ShouldSendSpans").StartActive(finishSpanOnDispose: true))
{
tracer.ActiveSpan.Should().NotBeNull();
}

tracer.ActiveSpan.Should().BeNull();
}
}
}
}
3 changes: 2 additions & 1 deletion src/Petabridge.Tracing.Zipkin/ZipkinTracer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System;
using OpenTracing;
using OpenTracing.Propagation;
using OpenTracing.Util;
using Petabridge.Tracing.Zipkin.Exceptions;
using Petabridge.Tracing.Zipkin.Propagation;
using Petabridge.Tracing.Zipkin.Sampling;
Expand All @@ -29,7 +30,7 @@ public ZipkinTracer(ZipkinTracerOptions options)
_reporter = options.Reporter;
LocalEndpoint = options.LocalEndpoint;
TimeProvider = options.TimeProvider ?? new DateTimeOffsetTimeProvider();
ScopeManager = options.ScopeManager ?? NoOp.ScopeManager;
ScopeManager = options.ScopeManager ?? new AsyncLocalScopeManager();
IdProvider = options.IdProvider ?? ThreadLocalRngSpanIdProvider.TraceId128BitProvider;
Sampler = options.Sampler ?? NoSampler.Instance;
Options = options;
Expand Down