diff --git a/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md index 02a4849f78..fd775a52b4 100644 --- a/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +* Add the `db.operation.name` attribute when `CommandType` is + `StoredProcedure` to conform to the new semantic conventions. + This affects you if you have opted into the new conventions. + ([#2800](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2800)) + ## 1.12.0-beta.1 Released 2025-May-06 diff --git a/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlActivitySourceHelper.cs b/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlActivitySourceHelper.cs index 1e41af6196..3315733950 100644 --- a/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlActivitySourceHelper.cs +++ b/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlActivitySourceHelper.cs @@ -37,6 +37,7 @@ internal sealed class SqlActivitySourceHelper SemanticConventions.AttributeDbSystem, SemanticConventions.AttributeDbSystemName, SemanticConventions.AttributeDbNamespace, + SemanticConventions.AttributeDbOperationName, SemanticConventions.AttributeDbStoredProcedureName, SemanticConventions.AttributeDbResponseStatusCode, SemanticConventions.AttributeErrorType, diff --git a/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs index 619a0189eb..9cd362c957 100644 --- a/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs @@ -115,6 +115,7 @@ public override void OnEventWritten(string name, object? payload) if (options.EmitNewAttributes) { + activity.SetTag(SemanticConventions.AttributeDbOperationName, "EXECUTE"); activity.SetTag(SemanticConventions.AttributeDbStoredProcedureName, commandText); } diff --git a/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTestCases.json b/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTestCases.json index cf2205e377..2c4cbe3719 100644 --- a/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTestCases.json +++ b/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTestCases.json @@ -38,7 +38,7 @@ "db.collection.name": null, "db.namespace": "MSSQLLocalDB.master", "db.operation.batch.size": null, - "db.operation.name": null, + "db.operation.name": "EXECUTE", "db.query.summary": null, "db.query.text": null, "db.response.status_code": null,