-
Notifications
You must be signed in to change notification settings - Fork 290
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
[SqlClient] Refactor SqlConnectionDetails #2233
[SqlClient] Refactor SqlConnectionDetails #2233
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2233 +/- ##
===========================================
+ Coverage 73.91% 91.36% +17.44%
===========================================
Files 267 8 -259
Lines 9615 301 -9314
===========================================
- Hits 7107 275 -6832
+ Misses 2508 26 -2482
Flags with carried forward coverage won't be shown. Click here to find out more.
|
src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlConnectionDetails.cs
Show resolved
Hide resolved
/// <see> | ||
/// <a href="https://docs.microsoft.com/previous-versions/sql/sql-server-2016/ms189307(v=sql.130)"/> | ||
/// </see> | ||
private static readonly Regex NamedPipeRegex = new("pipe\\\\MSSQL\\$(.*?)\\\\", RegexOptions.Compiled); |
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 a RegEx source generator available now. Doesn't have to be part of this PR, but we should probably move to that on targets where it is available. Reason being is I assume it gives best perf across the board but especially when AoT is in play and compilation is not available (assuming RegEx falls back to interpreter when dynamic code isn't available).
Some reasons listed here why it should be used:
https://learn.microsoft.com/dotnet/standard/base-types/regular-expression-source-generators#when-to-use-it
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.
src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlConnectionDetails.cs
Outdated
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.
LGTM
This is a refactor that extracts
SqlConnectionDetails
from theSqlClientTraceInstrumentationOptions
class. Evaluating connection details is not specific to spans - it will also be used for DB metrics.This PR is similar to what is done in #2026. I will deal with the merge conflicts on #2026.
There's a whole bunch that I don't like about the tests for this instrumentation. A lot of copy and paste for .NET vs. .NET Framework tests and inconsistent test cases covering them. This PR does not attempt to address improving tests. I'll do this in a follow on PR before stabilization.
There's also a small bug fix where
server.port
was captured as a string instead of an int.