/// <inheritdoc/> public IScope Activate(ISpan span, bool finishSpanOnDispose) { var shim = Guard.Type <SpanShim>(span, nameof(span)); var scope = Tracer.WithSpan(shim.Span); var instrumentation = new ScopeInstrumentation( shim.Span, () => { var removed = SpanScopeTable.Remove(shim.Span); #if DEBUG if (removed) { Interlocked.Decrement(ref this.spanScopeTableCount); } #endif scope.Dispose(); }); SpanScopeTable.Add(shim.Span, instrumentation); #if DEBUG Interlocked.Increment(ref this.spanScopeTableCount); #endif return(instrumentation); }
/// <inheritdoc/> public global::OpenTracing.IScope Activate(ISpan span, bool finishSpanOnDispose) { if (!(span is SpanShim shim)) { throw new ArgumentException("span is not a valid SpanShim object"); } var scope = Tracer.WithSpan(shim.Span); var instrumentation = new ScopeInstrumentation( shim.Span, () => { var removed = SpanScopeTable.Remove(shim.Span); #if DEBUG if (removed) { Interlocked.Decrement(ref this.spanScopeTableCount); } #endif scope.Dispose(); }); SpanScopeTable.Add(shim.Span, instrumentation); #if DEBUG Interlocked.Increment(ref this.spanScopeTableCount); #endif return(instrumentation); }