From cbd7e0f6d39888308a7093efed43252b30764c30 Mon Sep 17 00:00:00 2001 From: unknown <3676547+alanwest@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:44:24 -0700 Subject: [PATCH 1/2] For stored procedures add db.operation.name and db.collection.name attributes --- .../Implementation/SqlClientDiagnosticListener.cs | 2 ++ .../SqlClientTests.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs index f0739ac7ec..b8b20b72ac 100644 --- a/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs @@ -110,6 +110,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)); } } From a57225885db58cca6299a0dee8c34d1c5c9934fa Mon Sep 17 00:00:00 2001 From: unknown <3676547+alanwest@users.noreply.github.com> Date: Wed, 30 Oct 2024 18:07:09 -0700 Subject: [PATCH 2/2] Update changelog --- src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md index bfc0dc4d1e..1a3b4168e7 100644 --- a/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md @@ -25,7 +25,8 @@ semantic conventions for [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)) + [#2277](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2277), + [#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