-
Notifications
You must be signed in to change notification settings - Fork 150
Changes following Manu's offline PR #2
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1cb7634
Small adjustements
bmermet 1994c88
Make ServiceName immutable after span creation
bmermet 5f31a8a
Make Span and SpanBuilder threadsafe
bmermet 3c5bb29
Harmonize tag names with Java
bmermet 8e8f9e1
No optout for in process context propagation
bmermet 32ae259
Add test exercising utf8 encoding
bmermet 823a657
Explicit implementation of ISpan Context
bmermet 07fb171
Fix in ServiceInfo initialization
bmermet 2253ebc
Address comments
bmermet b701549
Updated tests to break on custom tags change
bmermet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,20 @@ | ||
| using Moq; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Xunit; | ||
|
|
||
| namespace Datadog.Tracer.Tests | ||
| { | ||
| public class TracerTests | ||
| { | ||
| private Mock<IApi> _apiMock = new Mock<IApi>(MockBehavior.Strict); | ||
| private Mock<IApi> _apiMock = new Mock<IApi>(); | ||
|
|
||
| [Fact] | ||
| public void BuildSpan_NoParameterAutomaticContextPropagation_DefaultParameters() | ||
| public void BuildSpan_NoParameter_DefaultParameters() | ||
| { | ||
| var tracer = new Tracer(_apiMock.Object, automaticContextPropagation: true); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. exactly; that field will be part of another API when we're using a kind of |
||
| var tracer = new Tracer(_apiMock.Object); | ||
|
|
||
| var builder = tracer.BuildSpan("Op1"); | ||
| var span = (Span)builder.Start(); | ||
|
|
@@ -24,21 +24,9 @@ public void BuildSpan_NoParameterAutomaticContextPropagation_DefaultParameters() | |
| } | ||
|
|
||
| [Fact] | ||
| public void BuildSpan_NoParameterNoAutomaticContextPropagation_DefaultParameters() | ||
| public void BuildSpan_OneChild_ChildParentProperlySet() | ||
| { | ||
| var tracer = new Tracer(_apiMock.Object, automaticContextPropagation: false); | ||
|
|
||
| var builder = tracer.BuildSpan("Op1"); | ||
| var span = (Span)builder.Start(); | ||
|
|
||
| Assert.Equal(Constants.UnkownService, span.ServiceName); | ||
| Assert.Equal("Op1", span.OperationName); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void BuildSpan_OneChildAutomaticContextPropagation_ChildParentProperlySet() | ||
| { | ||
| var tracer = new Tracer(_apiMock.Object, automaticContextPropagation: true); | ||
| var tracer = new Tracer(_apiMock.Object); | ||
|
|
||
| var root = (Span)tracer | ||
| .BuildSpan("Root") | ||
|
|
@@ -48,13 +36,13 @@ public void BuildSpan_OneChildAutomaticContextPropagation_ChildParentProperlySet | |
| .Start(); | ||
|
|
||
| Assert.Equal(root.TraceContext, child.TraceContext); | ||
| Assert.Equal(root.DatadogContext.SpanId, child.DatadogContext.ParentId); | ||
| Assert.Equal(root.Context.SpanId, child.Context.ParentId); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void BuildSpan_2ChildrenOfRootAutomaticContextPropagation_ChildrenParentProperlySet() | ||
| public void BuildSpan_2ChildrenOfRoot_ChildrenParentProperlySet() | ||
| { | ||
| var tracer = new Tracer(_apiMock.Object, automaticContextPropagation: true); | ||
| var tracer = new Tracer(_apiMock.Object); | ||
|
|
||
| var root = (Span)tracer | ||
| .BuildSpan("Root") | ||
|
|
@@ -68,15 +56,15 @@ public void BuildSpan_2ChildrenOfRootAutomaticContextPropagation_ChildrenParentP | |
| .Start(); | ||
|
|
||
| Assert.Equal(root.TraceContext, child1.TraceContext); | ||
| Assert.Equal(root.DatadogContext.SpanId, child1.DatadogContext.ParentId); | ||
| Assert.Equal(root.Context.SpanId, child1.Context.ParentId); | ||
| Assert.Equal(root.TraceContext, child2.TraceContext); | ||
| Assert.Equal(root.DatadogContext.SpanId, child2.DatadogContext.ParentId); | ||
| Assert.Equal(root.Context.SpanId, child2.Context.ParentId); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void BuildSpan_2LevelChildrenAutomaticContextPropagation_ChildrenParentProperlySet() | ||
| public void BuildSpan_2LevelChildren_ChildrenParentProperlySet() | ||
| { | ||
| var tracer = new Tracer(_apiMock.Object, automaticContextPropagation: true); | ||
| var tracer = new Tracer(_apiMock.Object); | ||
|
|
||
| var root = (Span)tracer | ||
| .BuildSpan("Root") | ||
|
|
@@ -89,15 +77,15 @@ public void BuildSpan_2LevelChildrenAutomaticContextPropagation_ChildrenParentPr | |
| .Start(); | ||
|
|
||
| Assert.Equal(root.TraceContext, child1.TraceContext); | ||
| Assert.Equal(root.DatadogContext.SpanId, child1.DatadogContext.ParentId); | ||
| Assert.Equal(root.Context.SpanId, child1.Context.ParentId); | ||
| Assert.Equal(root.TraceContext, child2.TraceContext); | ||
| Assert.Equal(child1.DatadogContext.SpanId, child2.DatadogContext.ParentId); | ||
| Assert.Equal(child1.Context.SpanId, child2.Context.ParentId); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task BuildSpan_AsyncChildrenCreationAutomaticContextPropagation_ChildrenParentProperlySet() | ||
| public async Task BuildSpan_AsyncChildrenCreation_ChildrenParentProperlySet() | ||
| { | ||
| var tracer = new Tracer(_apiMock.Object, automaticContextPropagation: true); | ||
| var tracer = new Tracer(_apiMock.Object); | ||
| var tcs = new TaskCompletionSource<bool>(); | ||
|
|
||
| var root = (Span)tracer | ||
|
|
@@ -111,12 +99,12 @@ public async Task BuildSpan_AsyncChildrenCreationAutomaticContextPropagation_Chi | |
| tcs.SetResult(true); | ||
|
|
||
| Assert.Equal(root.TraceContext, syncChild.TraceContext); | ||
| Assert.Equal(root.DatadogContext.SpanId, syncChild.DatadogContext.ParentId); | ||
| Assert.Equal(root.Context.SpanId, syncChild.Context.ParentId); | ||
| foreach(var task in tasks) | ||
| { | ||
| var span = await task; | ||
| Assert.Equal(root.TraceContext, span.TraceContext); | ||
| Assert.Equal(root.DatadogContext.SpanId, span.DatadogContext.ParentId); | ||
| Assert.Equal(root.Context.SpanId, span.Context.ParentId); | ||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 thanks for testing that.