-
Notifications
You must be signed in to change notification settings - Fork 150
Stop using Tracer.Instance if we don't need to
#7744
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
Open
andrewlock
wants to merge
2
commits into
andrew/settings/6-fix-telemetry-reporting
Choose a base branch
from
andrew/settings/6a-stop-using-tracer-instance
base: andrew/settings/6-fix-telemetry-reporting
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+28
−25
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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 |
|---|---|---|
|
|
@@ -15,8 +15,9 @@ namespace Datadog.Trace.Tests.DataStreamsMonitoring | |
| { | ||
| public class DataStreamsContextPropagatorTests | ||
| { | ||
| [Fact] | ||
| public void CanRoundTripPathwayContext() | ||
| [Theory] | ||
| [CombinatorialData] | ||
|
Collaborator
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. 😃 |
||
| public void CanRoundTripPathwayContext(bool isDataStreamsLegacyHeadersEnabled) | ||
| { | ||
| var oneMs = TimeSpan.FromMilliseconds(1); | ||
| var headers = new TestHeadersCollection(); | ||
|
|
@@ -25,7 +26,7 @@ public void CanRoundTripPathwayContext() | |
| DateTimeOffset.UtcNow.AddSeconds(-5).ToUnixTimeNanoseconds(), | ||
| DateTimeOffset.UtcNow.ToUnixTimeNanoseconds()); | ||
|
|
||
| DataStreamsContextPropagator.Instance.Inject(context, headers); | ||
| DataStreamsContextPropagator.Instance.Inject(context, headers, isDataStreamsLegacyHeadersEnabled); | ||
|
|
||
| var extracted = DataStreamsContextPropagator.Instance.Extract(headers); | ||
|
|
||
|
|
@@ -86,16 +87,17 @@ public void Extract_WhenBothHeadersPresent_PrefersBase64Header() | |
| extractedContext.Value.EdgeStart.Should().NotBe(binaryContext.EdgeStart); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void InjectedHeaders_HaveCorrectFormat() | ||
| [Theory] | ||
| [CombinatorialData] | ||
| public void InjectedHeaders_HaveCorrectFormat(bool isDataStreamsLegacyHeadersEnabled) | ||
| { | ||
| var headers = new TestHeadersCollection(); | ||
| var context = new PathwayContext( | ||
| new PathwayHash(0x12345678), | ||
| 0x1122334455667788, | ||
| unchecked((long)0x99AABBCCDDEEFF00)); | ||
|
|
||
| DataStreamsContextPropagator.Instance.Inject(context, headers); | ||
| DataStreamsContextPropagator.Instance.Inject(context, headers, isDataStreamsLegacyHeadersEnabled); | ||
|
|
||
| headers.Values.Should().ContainKey(DataStreamsPropagationHeaders.PropagationKeyBase64); | ||
| var base64HeaderValueBytes = headers.Values[DataStreamsPropagationHeaders.PropagationKeyBase64]; | ||
|
|
||
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.
This one is actually kind of annoying. As it's in a static cctor, we can't pass it in anywhere, which means there's one
DbScopeFactoryTeststest which will use this and end up initializing the global tracer. Oh well.Uh oh!
There was an error while loading. Please reload this page.
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.
:sorry: pretty sure this was me
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.
Hmm. I understand that we want to minimize work but I feel like we should calculate all DbCommands regardless of config (i.e. no dependency here) and then we do the config check on the hot path, which allows this setting to be hot-reloadable or "config at runtime" ready
Uh oh!
There was an error while loading. Please reload this page.
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.
Concretely, I'm suggesting that we remove the
TryGetIntegrationDetailscall in the static constructor ofCache<TCommand>and refactor the other call inCreateDbCommandScopea bit. Perhaps in a separate PRThere 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.
I can see arguments both ways tbh.
The only downside to @zacharycmontoya's proposal would be more work to do for custom DbCommands (ones that we don't explicitly know about), which are also marked as disabled initially, and which customers have marked as disabled. The question I would have is whether that's ok - e.g. if they're disabled because we're erroring out literally running
TryGetIntegrationDetails, and that's why they disabled it, then that could be a problem. If it's just an optimization, then yes, it probably is fine.That said, this actually is technically already hot-reloadable. The
DisabledAdoNetCommandTypessetting passed in here is used to decide whether to populate the cache for custom types, but if we don't populate the cache, then we runTryGetIntegrationDetails()and checkDisabledAdoNetCommandTypesat runtime anyway. So if this changes, then the result changes, it will just never be cached in that scenario.So on that basis, I think removing the
TryGetIntegrationDetailshas a small amount of risk (if customer disabled adonet due to errors - not sure if that's really possible, but I can believe it), means a small bit more work (calculating values which will never be used), and doesn't change how hot-reloadable we are in general (though if we made it hot reloadable, we'd have to rethink how caching works). The plus side is it removes the static access to Tracer.Instance which is better for tests.So yeah, I'm torn 🤷♂️ I'd say separate PR either way, given the questions, as the current behaviour in this PR is identical to the existing. But it's worth thinking about