diff --git a/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md index c71a82625a..0cd67e6192 100644 --- a/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md @@ -26,7 +26,8 @@ [spans](https://github.com/open-telemetry/semantic-conventions/blob/v1.28.0/docs/database/database-spans.md). ([#2229](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2229), [#2277](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2277), - [#2262](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2262)) + [#2262](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2262), + [#2279](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2279)) * **Breaking change**: The `peer.service` and `server.socket.address` attributes are no longer emitted. Users should rely on the `server.address` attribute for the same information. Note that `server.address` is only included when diff --git a/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs index 32c9b5c493..defc740632 100644 --- a/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs @@ -112,6 +112,8 @@ public override void OnEventWritten(string name, object? payload) if (this.options.EmitNewAttributes) { + activity.SetTag(SemanticConventions.AttributeDbOperationName, "EXECUTE"); + activity.SetTag(SemanticConventions.AttributeDbCollectionName, commandText); activity.SetTag(SemanticConventions.AttributeDbQueryText, commandText); } } diff --git a/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTests.cs b/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTests.cs index d978beed88..1eb6774267 100644 --- a/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTests.cs +++ b/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTests.cs @@ -442,6 +442,8 @@ internal static void VerifyActivityData( if (emitNewAttributes) { + Assert.Equal("EXECUTE", activity.GetTagValue(SemanticConventions.AttributeDbOperationName)); + Assert.Equal(commandText, activity.GetTagValue(SemanticConventions.AttributeDbCollectionName)); Assert.Equal(commandText, activity.GetTagValue(SemanticConventions.AttributeDbQueryText)); } }