-
Couldn't load subscription status.
- Fork 123
.NET Framework SqlCommand IL rewrite for SqlClient instrumentation
#4470
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
base: main
Are you sure you want to change the base?
Conversation
src/OpenTelemetry.AutoInstrumentation.Native/environment_variables.h
Outdated
Show resolved
Hide resolved
|
@zacharycmontoya and @Kielek - Thanks for the review. I am back from vacation and will update this ASAP. |
|
@stevejgordon, do you need any help here or just more time? |
|
@Kielek I may need a bit of help. Previously I had the test running in Visual Studio and it was passing. Now it doesn't! In an isolated test application running in IIS, with the files from Would you perhaps be able to review if I've missed something in this test and/or test locally yourself to see if this is working as expected? I'll continue to dig into it on my end too and try to figure it out. |
|
@Kielek Could it be anything to do with the removal of the |
|
@stevejgordon, sorry for delay. Either @zacharycmontoya will check it today or I will try to help tommorow. |
I was able to get your integration test running on my machine and it passes ✅ However, I'd also like to add this same testing to our test case that uses the .NET Framework built-in |
|
@zacharycmontoya Thanks for checking. Ill have to try to figure out why they are failing on my machine. Feel free to duplicate this for the other scenarios and add to this PR in the mean time. |
…ramework-only TestApplication.SqlClient.System.NetFramework test that uses the built-in System.Data.SqlClient.SqlCommand class from System.Data.dll
|
@stevejgordon I've added one test case in commit 355be86, which also passed locally on my machine. If CI passes, then I think it's good-to-go |
| | `OTEL_DOTNET_EXPERIMENTAL_ASPNETCORE_DISABLE_URL_QUERY_REDACTION` | Whether the ASP.NET Core instrumentation turns off redaction of the `url.query` attribute value. | `false` | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | | ||
| | `OTEL_DOTNET_EXPERIMENTAL_HTTPCLIENT_DISABLE_URL_QUERY_REDACTION` | Whether the HTTP client instrumentation turns off redaction of the `url.full` attribute value. | `false` | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | | ||
| | `OTEL_DOTNET_EXPERIMENTAL_ASPNET_DISABLE_URL_QUERY_REDACTION` | Whether the ASP.NET instrumentation turns off redaction of the `url.query` attribute value. | `false` | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | | ||
| | `OTEL_DOTNET_AUTO_SQLCLIENT_NETFX_ILREWRITE_ENABLED` | Enables IL rewriting of `SqlCommand` on .NET Framework to ensure `CommandText` is present for `SqlClient` instrumentation, which is required for `db.query.text` and `db.query.summary` to be populated. | `true` | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | |
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 have some doubts here. As t might impact end-users, I would consider this as opt-in feature.
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 am actually leaning towards on by default because the effect is that the user gets one more attribute on their spans, so overall this improves the tracing quality automatically and makes it more appealing to use our automatic package. If there are any side-effects from turning this on, then we should promptly identify and resolve them.
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.
Unfortunately, I think that the side-effects that I'm most concerned about are outside of our control. The code that we are modifying causes the sql to get written to an EventSource. When things are written to an EventSource, that data can now be consumed by other things, including things that can result in data getting persisted outside of the process. Those things may not be sanitizing the sql, or may assume that the data was safe to begin with (just the stored procedure).
I think having it on would be fine for the majority of users, but there are probably a few that would run into problems with having this data present by default.
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, I overlooked the fact that we're writing to an EventSource and not directly updating the span. It makes sense then to have users opt-in to the feature
| bool IsAzureAppServices(); | ||
| bool IsFailFastEnabled(); | ||
| bool IsNetFxAssemblyRedirectionEnabled(); | ||
| bool IsSqlClientNetFxILRewriteEnabled(); |
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.
Ideally, it should be propagated from the managed coded. We are in the middle of introducing File based configuration and it need to be reworked in the near feature. Not a blocker for this PR IMO.
Ref: #4492
Why
Details in #4343. In short, on .NET Framework
System.Datadoesn't emit theCommandText(except for stored procedures) in its events. This prevents theSqlClientinstrumentation from enriching with the DB query text and summary.Fixes #4343
What
As discussed in the issue. This rewrites the
WriteBeginExecuteEventto ensure theCommandTextis always present. The implementation currently enables this by default, but provides configuration to disable this behaviour if required.Tests
The
SqlClientSystemTestsintegration test was updated to to the newOTEL_DOTNET_AUTO_SQLCLIENT_NETFX_ILREWRITE_ENABLEDenvironmnet variable.Checklist
CHANGELOG.mdis updated.cc @alanwest, @martincostello