-
Notifications
You must be signed in to change notification settings - Fork 274
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
Update SqlClient instrumentation to follow new DB span conventions #2229
base: main
Are you sure you want to change the base?
Update SqlClient instrumentation to follow new DB span conventions #2229
Conversation
// Test cases when EmitOldAttributes = false and EmitNewAttributes = true (i.e., OTEL_SEMCONV_STABILITY_OPT_IN=database) | ||
[InlineData(SqlClientDiagnosticListener.SqlDataBeforeExecuteCommand, SqlClientDiagnosticListener.SqlDataAfterExecuteCommand, CommandType.StoredProcedure, "SP_GetOrders", true, false, true, false, true)] |
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.
These test cases are becoming a bit heinous for readability as expressed here. I have thoughts to refactor the tests, but I want to roll with the heinousness for now.
// TODO: The attributes added here are required. We need to consider | ||
// collecting these attributes by default. | ||
if (this.EnableConnectionLevelAttributes) |
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.
Will open a new issue for this.
// TODO: In the new conventions, instance name should now be captured | ||
// as a part of db.namespace, when available. | ||
if (this.EmitOldAttributes && !string.IsNullOrEmpty(connectionDetails.InstanceName)) |
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.
Will open a new issue for this.
// TODO: Need to understand what scenario (if any) database will be null here | ||
// so that we set DisplayName and db.name/db.namespace correctly. | ||
if (database != null) |
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.
Will open a new issue for this
// TODO: Should we continue to emit this if the default port (1433) is being used? | ||
sqlActivity.SetTag(SemanticConventions.AttributeServerPort, connectionDetails.Port); |
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.
Removed this TODO because the instrumentation already excludes port when it is 1433.
if (!this.EnableConnectionLevelAttributes) | ||
{ | ||
sqlActivity.SetTag(SemanticConventions.AttributePeerService, 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.
This instrumentation should not be emitting peer.service
.
But just a reminder here... when peer.service
was removed from HTTP client instrumentation it was unexpected see #1761.
Fixes #2225
This PR is the first in a series of PRs. It introduces support for the
OTEL_SEMCONV_STABILITY_OPT_IN
environment variable to gate using the old or new conventions. It does not aim to fully adopt the new database conventions. It only updates conventions for the attributes currently reported by the instrumentation.The documentation in the readme still only refers to the old attributes. I will update the readme in a different PR.