Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] In-process propagation with a simple ITracer.ActiveSpan property #36

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 5 additions & 0 deletions src/OpenTracing/ISpanBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public interface ISpanBuilder
/// e.g., for a <see cref="References.ChildOf"/> referenceType, the referencedContext is the parent.</param>
ISpanBuilder AddReference(string referenceType, ISpanContext referencedContext);

/// <summary>
/// When used, the newly created span will NOT inherit <see cref="ITracer.ActiveSpan"/> as a parent.
/// </summary>
ISpanBuilder IgnoreActiveSpan();

/// <summary>
/// Adds a tag to the span.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions src/OpenTracing/ITracer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ namespace OpenTracing
/// </summary>
public interface ITracer
{
/// <summary>
/// <para>Returns the currently active span. It is used for intra-process propagation and follows the async execution flow.</para>
/// <para>Any newly started span will inherit this span as a parent unless <see cref="ISpanBuilder.IgnoreActiveSpan"/>
/// is called before the span is started.</para>
/// </summary>
ISpan ActiveSpan { get; }

/// <summary>
/// Returns a new <see cref="ISpanBuilder" /> for a span with the given <paramref name="operationName" />.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/OpenTracing/NullTracer/NullSpanBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/OpenTracing/NullTracer/NullTracer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ private NullTracer()
{
}

public ISpan ActiveSpan => NullSpan.Instance;

public ISpanBuilder BuildSpan(string operationName)
{
return NullSpanBuilder.Instance;
Expand Down