Skip to content

StartSpan should not generate active span by default #994

Merged
cijothomas merged 17 commits intoopen-telemetry:masterfrom
rajkumar-rangaraj:rajrang/tracer_span
Aug 5, 2020
Merged

StartSpan should not generate active span by default #994
cijothomas merged 17 commits intoopen-telemetry:masterfrom
rajkumar-rangaraj:rajrang/tracer_span

Conversation

@rajkumar-rangaraj
Copy link
Copy Markdown
Member

Fixes #989 .

Changes

Please provide a brief description of the changes here. Update the
CHANGELOG.md for non-trivial changes.

  • Added StartRootSpan and StartActiveSpan to Tracer API
  • Used a common helper, for all methods to create an activity internally
  • Modified OpenTracing Shim to use StartRootSpan and fixed TODO

For significant contributions please make sure you have completed the following items:

  • Design discussion issue #
  • Changes in public API reviewed

@rajkumar-rangaraj rajkumar-rangaraj requested a review from a team August 4, 2020 01:13
/// <param name="links"> <see cref="Link"/> for the span.</param>
/// <param name="startTime"> Start time for the span.</param>
/// <returns>Span instance.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets modify the summary to say this will not set the started span as the active one.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the spec and other languages implementation, starting a span does not make it active, should we call it out explicitly here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This is important for .NET, as the .NET Activity API's StartActivity is making it active (this is violation of spec). The equivalent SHIM api should be StartActiveSpan.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

}

/// <summary>
/// Starts an active span.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starts a span and make it the current active span.

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 4, 2020

Codecov Report

Merging #994 into master will increase coverage by 0.27%.
The diff coverage is 96.15%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #994      +/-   ##
==========================================
+ Coverage   68.56%   68.84%   +0.27%     
==========================================
  Files         220      220              
  Lines        6003     5999       -4     
  Branches      984      984              
==========================================
+ Hits         4116     4130      +14     
+ Misses       1611     1598      -13     
+ Partials      276      271       -5     
Impacted Files Coverage Δ
src/OpenTelemetry.Api/Trace/Tracer.cs 89.18% <95.45%> (+33.37%) ⬆️
...OpenTelemetry.Shims.OpenTracing/SpanBuilderShim.cs 75.51% <100.00%> (+0.51%) ⬆️
src/OpenTelemetry.Api/Trace/TelemetrySpan.cs 58.82% <0.00%> (+1.96%) ⬆️
...nTelemetry/Internal/OpenTelemetrySdkEventSource.cs 80.88% <0.00%> (+2.94%) ⬆️

/// <returns>Span instance.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TelemetrySpan StartSpan(string name, SpanKind kind = SpanKind.Internal)
public TelemetrySpan StartRootSpan(string name, SpanKind kind = SpanKind.Internal, IEnumerable<KeyValuePair<string, object>> attributes = null, IEnumerable<Link> links = null, DateTimeOffset startTime = default)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add Tracer unit tests to validate all the scenarios? RootSpan, Start, StartActive? We had tests before, but I got them removed when shifting to Activity. We can now add some tests.

[Fact]
public void Tracer_StartRootSpan_BadArgs_NullSpanName()
{
using var openTelemetry = Sdk.CreateTracerProvider(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name is required parameter. so may be we are better off throw invalidargexception?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change the implementation?

@cijothomas
Copy link
Copy Markdown
Member

@rajkumar-rangaraj can you resolve conflict?

@cijothomas cijothomas merged commit 7030026 into open-telemetry:master Aug 5, 2020
@rajkumar-rangaraj
Copy link
Copy Markdown
Member Author

@rajkumar-rangaraj can you resolve conflict?

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StartSpan should not generate active span by default

2 participants