-
Notifications
You must be signed in to change notification settings - Fork 354
[Instrumentation.SqlClient] Introducing context propagation to SQL Server #2709
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
[Instrumentation.SqlClient] Introducing context propagation to SQL Server #2709
Conversation
|
@sincejune, could you please rise issue under semantic convention repository? It is not something we should accept without common standard for all supported languages (including other db clients). |
@Kielek Sure, filed open-telemetry/semantic-conventions#2162 |
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Accept `context_info` with `traceparent` format in query sample collection, setting log record with correct traceId and spanId. Example use case: open-telemetry/opentelemetry-dotnet-contrib#2709 <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue n/a <!--Describe what testing was performed and which tests were added.--> #### Testing Updated <!--Describe the documentation added.--> #### Documentation Added <!--Please delete paragraphs that you did not use before submitting.--> --------- Co-authored-by: Antoine Toulme <[email protected]>
|
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
|
Closed as inactive. Feel free to reopen if this PR is still being worked on. |
|
Reopening, per request in private channel. open-telemetry/semantic-conventions#2363 is now merged |
…on to propagate trace info to SQL Server
2c304af to
215add0
Compare
src/OpenTelemetry.Instrumentation.SqlClient/.publicApi/PublicAPI.Unshipped.txt
Outdated
Show resolved
Hide resolved
…ClientDiagnosticListener.cs Co-authored-by: Zach Montoya <[email protected]>
src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs
Show resolved
Hide resolved
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.
There is some issues on .NET Framework 4.6.2 (locally executed) in integration tests
2 cases are failing on
if (commandText == GetContextInfoQuery)
{
Assert.NotEqual(commandResult, DBNull.Value); // <---- failing here
Assert.True(commandResult is byte[]);
var contextInfo = Encoding.ASCII.GetString((byte[])commandResult).TrimEnd('\0');
Assert.Equal(contextInfo, activity.Id);
}.NET 8 and 9 are passing.
Do the .NET Framework tests not run in CI (I thought they did)? That might explain why #2826 (comment) happened. |
It requires docker for linux. It is not available on the GH runners on Windows systems. So itnegration tests are not executed for such cases. |
The current implementation does not yet support .NET Framework. We may need to explore how to integrate it later. opentelemetry-dotnet-contrib/src/OpenTelemetry.Instrumentation.SqlClient/SqlClientInstrumentation.cs Lines 51 to 55 in 07105a5
The logic is currently implemented in the Would that be acceptable? If not, we can continue working on support in this PR. Otherwise, we can defer it to a follow-up PR. Thanks! |
test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientIntegrationTests.cs
Outdated
Show resolved
Hide resolved
|
@sincejune , @alanwest , @Kielek : Any concerns over using SET CONTEXT_INFO with connection pooling? Is there a risk of the TraceId that's propagated "contaminating" unrelated SQL queries? It's great that the instrumentation library provides support for TraceId propagation, but I'd like to have some confidence that if our applications use this, we can rely on the TraceIds associated with our SQL queries to be accurate. Any info you can provide would be appreciated. Thanks! |
…on to propagate trace info to SQL Server
Changes
This PR introduces a new flag,
ContextPropagationLevel, in SqlClientInstrumentation, which enables the library to propagatetraceparentinformation to the SQL Server database.The ContextPropagationLevel can be set to either
traceordisabled(the default value). When set totrace, the instrumentation library uses the SET CONTEXT_INFO command to pass atraceparentID of the current Activity to the SQL Server.Next steps:
I plan to introduce a "service" level that will pass service information via SQL commands via sqlcommenter.
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changes