diff --git a/src/OpenTracing/ISpanBuilder.cs b/src/OpenTracing/ISpanBuilder.cs index 563ed90..8b70133 100644 --- a/src/OpenTracing/ISpanBuilder.cs +++ b/src/OpenTracing/ISpanBuilder.cs @@ -36,6 +36,11 @@ public interface ISpanBuilder /// e.g., for a referenceType, the referencedContext is the parent. ISpanBuilder AddReference(string referenceType, ISpanContext referencedContext); + /// + /// When used, the newly created span will NOT inherit as a parent. + /// + ISpanBuilder IgnoreActiveSpan(); + /// /// Adds a tag to the span. /// diff --git a/src/OpenTracing/ITracer.cs b/src/OpenTracing/ITracer.cs index 888f796..c024c50 100644 --- a/src/OpenTracing/ITracer.cs +++ b/src/OpenTracing/ITracer.cs @@ -7,6 +7,13 @@ namespace OpenTracing /// public interface ITracer { + /// + /// Returns the currently active span. It is used for intra-process propagation and follows the async execution flow. + /// Any newly started span will inherit this span as a parent unless + /// is called before the span is started. + /// + ISpan ActiveSpan { get; } + /// /// Returns a new for a span with the given . /// diff --git a/src/OpenTracing/NullTracer/NullSpanBuilder.cs b/src/OpenTracing/NullTracer/NullSpanBuilder.cs index 971cc07..40ceae5 100644 --- a/src/OpenTracing/NullTracer/NullSpanBuilder.cs +++ b/src/OpenTracing/NullTracer/NullSpanBuilder.cs @@ -35,6 +35,11 @@ public ISpanBuilder AddReference(string referenceType, ISpanContext referencedCo return this; } + public ISpanBuilder IgnoreActiveSpan() + { + return this; + } + public ISpanBuilder WithStartTimestamp(DateTime startTimestamp) { return this; diff --git a/src/OpenTracing/NullTracer/NullTracer.cs b/src/OpenTracing/NullTracer/NullTracer.cs index 890843f..a5db6de 100644 --- a/src/OpenTracing/NullTracer/NullTracer.cs +++ b/src/OpenTracing/NullTracer/NullTracer.cs @@ -10,6 +10,8 @@ private NullTracer() { } + public ISpan ActiveSpan => NullSpan.Instance; + public ISpanBuilder BuildSpan(string operationName) { return NullSpanBuilder.Instance;