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

StartSpan should not generate active span by default #994

Merged
merged 17 commits into from
Aug 5, 2020
Merged

StartSpan should not generate active span by default #994

merged 17 commits into from
Aug 5, 2020

Conversation

rajkumar-rangaraj
Copy link
Contributor

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="parentSpan">Parent for new span.</param>
/// <param name="attributes">Initial attributes for the span.</param>
/// <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
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
Contributor 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
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
Contributor 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
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

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
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
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
Contributor 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
Member

@rajkumar-rangaraj can you resolve conflict?

@cijothomas cijothomas merged commit 7030026 into open-telemetry:master Aug 5, 2020
@rajkumar-rangaraj
Copy link
Contributor 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