opentracing-csharp icon indicating copy to clipboard operation
opentracing-csharp copied to clipboard

Always return NoopScope / NoopSpan for ScopeManager.Active / Tracer.ActiveSpan

Open cwe1ss opened this issue 7 years ago • 2 comments
trafficstars

This brings https://github.com/opentracing/opentracing-java/pull/263 to this repository.

Description from there:

In special circumstances, code may automatically generate spans, negating the need to always check if Tracer.activeSpan() is null. Under these circumstances, the Noop Tracer and ScopeManager will cause NPEs when they return null values when their active methods are accessed via the GlobalTracer. This prevents code from running successfully when using Noop Tracers.

This minor change allows users to depend that their code will genuinely Noop under all use cases.

We have a separate NoopTests class in our repo so I had to adjust these tests. I also changed everything to AssertSame(Noop*.Instance, ...) instead of Assert.IsType<Noop*>(...) as this is a better check for our use case IMO.

As I changed these tests as well, I'll keep this PR open for a few days.

cwe1ss avatar Mar 30 '18 07:03 cwe1ss

Please file any objections until May 2nd - I'll merge afterwards if there's none.

cwe1ss avatar Apr 26 '18 09:04 cwe1ss

Found my own concerns 😄 and filed them here https://github.com/opentracing/specification/issues/116. I'll put this on hold until that issue is resolved.

cwe1ss avatar Apr 26 '18 20:04 cwe1ss