-
Notifications
You must be signed in to change notification settings - Fork 141
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
Fix InvalidOperationException
in DBM propagation
#6233
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
50923a8
Fix DBM propagation for Transaction and Connection
bouwkast 625459f
Remove if branch
bouwkast 07827d6
Add note about Npgsql exception
bouwkast 53b55fe
Add sqlite snapshots and fix number of spans
bouwkast e9d2710
Update DBM mocks
bouwkast 2d9834b
Fix SystemDataSqliteTests and add snapshots
bouwkast fb097f5
Fix OracleMDA
bouwkast 7368b5f
Update mysql tests
bouwkast a0b53cd
Fix for MySql v9
bouwkast fa35ba2
Fix snapshots
bouwkast 8ee054a
Don't use transaction scope for MySql
bouwkast 0984b5d
Revert "Fix snapshots"
bouwkast e31e8f2
Revert "Fix for MySql v9"
bouwkast d4b4c44
Revert "Update mysql tests"
bouwkast 9929194
Conditionally enabled/disable Transcation in tests
bouwkast 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 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 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 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 |
---|---|---|
|
@@ -113,21 +113,37 @@ internal static string PropagateDataViaComment(DbmPropagationLevel propagationSt | |
/// Currently only working for MSSQL (uses an instruction that is specific to it) | ||
/// </summary> | ||
/// <returns>True if the traceparent information was set</returns> | ||
internal static bool PropagateDataViaContext(DbmPropagationLevel propagationLevel, IntegrationId integrationId, IDbConnection? connection, Span span) | ||
internal static bool PropagateDataViaContext(DbmPropagationLevel propagationLevel, IntegrationId integrationId, IDbCommand command, Span span) | ||
{ | ||
if (propagationLevel != DbmPropagationLevel.Full || integrationId != IntegrationId.SqlClient || connection == null) | ||
if (propagationLevel != DbmPropagationLevel.Full || integrationId != IntegrationId.SqlClient) | ||
{ | ||
return false; | ||
} | ||
|
||
// NOTE: For Npgsql command.Connection throws NotSupportedException for NpgsqlDataSourceCommand (v7.0+) | ||
// Since the feature isn't available for Npgsql we avoid this due to the integrationId check above | ||
if (command.Connection == null) | ||
{ | ||
return false; | ||
} | ||
|
||
if (command.Connection.State != ConnectionState.Open) | ||
{ | ||
Log.Debug("PropagateDataViaContext did not have an Open connection, so it could not propagate Span data for DBM. Connection state was {ConnectionState}", command.Connection.State); | ||
|
||
return false; | ||
} | ||
|
||
var stopwatch = System.Diagnostics.Stopwatch.StartNew(); | ||
|
||
const byte version = 0; // version can have a maximum value of 15 in the current format | ||
var sampled = SamplingPriorityValues.IsKeep(span.Context.TraceContext.GetOrMakeSamplingDecision()); | ||
var contextValue = BuildContextValue(version, sampled, span.SpanId, span.TraceId128); | ||
|
||
using (var injectionCommand = connection.CreateCommand()) | ||
using (var injectionCommand = command.Connection.CreateCommand()) | ||
{ | ||
// if there is a Transaction we need to copy it or our ExecuteNonQuery will throw | ||
injectionCommand.Transaction = command.Transaction; | ||
Comment on lines
+145
to
+146
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. yikes, good catch |
||
injectionCommand.CommandText = SetContextCommand; | ||
|
||
var parameter = injectionCommand.CreateParameter(); | ||
|
This file contains 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 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 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.
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.
Not part of the changes in this PR, but are we ok forcing a sampling decision here? What is the sampling decision in the injected context used for? Does it affect sampling of other data aside from the trace (i.e. DBM data)? Is it propagated to other services?
We may want to use the sampling decision if there is one already, but otherwise not force it to happen yet, since we generally want to delay it until it's required for downstream propagation or when sending the trace to the agent. Does
BuildContextValue()
supportsampled: null
?edit: not something to change in this PR, anyway
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 think the DBM context doesn't support "no sampling decision yet," so never mind, I guess.
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.
Honestly no idea, I can try to follow up with other DBM people
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.
yes it may be worth asking them, I don't think they do anything with the sampling decision so far, it's just written to do it like papa (the other propagation mechanisms)
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.
papa?
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.
I mean take example on what's here before. It's a metaphor ^^