-
Notifications
You must be signed in to change notification settings - Fork 856
Added Sql connection-level attributes (from spec) as an opt-in feature. #782
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
Added Sql connection-level attributes (from spec) as an opt-in feature. #782
Conversation
Codecov Report
@@ Coverage Diff @@
## master #782 +/- ##
==========================================
+ Coverage 71.09% 71.16% +0.07%
==========================================
Files 223 223
Lines 7009 7061 +52
Branches 1180 1191 +11
==========================================
+ Hits 4983 5025 +42
- Misses 1710 1722 +12
+ Partials 316 314 -2
Continue to review full report at Codecov.
|
| { | ||
| [SpanAttributeConstants.PeerServiceKey] = 0, // peer.service primary. | ||
| ["net.peer.name"] = 1, // peer.service first alternative. | ||
| [SpanAttributeConstants.NetPeerName] = 1, // peer.service first alternative. |
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.
one first and three second alternatives =)
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.
Hah ok yes, the comments suck. It's more like tiers. I was trying to have the official named attributes called out in the spec be taken first, in case multiple matches are found on a span. Spec PR (open-telemetry/opentelemetry-specification#534) never gained much traction.
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.
Updated the comments.
| } | ||
| internal const string MicrosoftSqlServerDatabaseInstanceName = "db.mssql.instance_name"; | ||
|
|
||
| private static readonly Regex DataSourceRegex = new Regex("^(.*?)(?:[\\\\,]|$)\\s*(.*?)(?:,|$)\\s*(.*)$", 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.
it would be handy to have an example of a string in a comment
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.
Done
| /// </remarks> | ||
| public bool EnableConnectionLevelAttributes { get; set; } = false; | ||
|
|
||
| internal static SqlConnectionDetails ParseDataSource(string dataSource) |
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.
minor: I'd prefer to move this logic to common helper class and keep options class simple.
Changes
You can now set
options.EnableConnectionLevelAttributes = truewhen configuring Sql Instrumentation to send connection-level attributes. I went with the option because it does come with a slight perf hit, looking up cached values and then setting tags.Checklist
For significant contributions please make sure you have completed the following items: