From d81a572302059749a9c3f7d4293c16d7cc654db0 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Thu, 7 May 2026 14:29:34 -0700 Subject: [PATCH 1/2] Fix gen_ai.tool.arguments attribute name to gen_ai.tool.call.arguments Align with the OpenTelemetry GenAI semantic conventions by renaming the attribute from gen_ai.tool.arguments to gen_ai.tool.call.arguments. Also fixes gen_ai.tool.call_result to gen_ai.tool.call.result in tests. Mirrors microsoft/opentelemetry-distro-dotnet#88. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Tracing/Scopes/OpenTelemetryConstants.cs | 2 +- .../Agent365ExporterAsyncE2ETests.cs | 2 +- .../Agent365ExporterE2ETests.cs | 4 ++-- .../Common/ExportFormatterTests.cs | 24 +++++++++---------- .../Tracing/Exporters/PayloadChunkingTests.cs | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryConstants.cs b/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryConstants.cs index 85e5cae4..d0cf0fc2 100644 --- a/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryConstants.cs +++ b/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryConstants.cs @@ -132,7 +132,7 @@ public enum OperationNames /// /// The GenAI tool arguments key. /// - public const string GenAiToolArgumentsKey = "gen_ai.tool.arguments"; + public const string GenAiToolArgumentsKey = "gen_ai.tool.call.arguments"; /// /// The GenAI tool type key. diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterAsyncE2ETests.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterAsyncE2ETests.cs index 803b7de3..82067e1a 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterAsyncE2ETests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterAsyncE2ETests.cs @@ -164,7 +164,7 @@ public async Task AddTracing_And_ExecuteToolScope_ExporterMakesExpectedRequest() this.GetAttribute(attributes, "microsoft.a365.agent.blueprint.id").Should().Be(expectedAgentDetails.AgentBlueprintId); this.GetAttribute(attributes, "microsoft.tenant.id").Should().Be(expectedAgentDetails.TenantId); this.GetAttribute(attributes, "gen_ai.tool.name").Should().Be(toolCallDetails.ToolName); - this.GetAttribute(attributes, "gen_ai.tool.arguments").Should().Be(toolCallDetails.Arguments); + this.GetAttribute(attributes, "gen_ai.tool.call.arguments").Should().Be(toolCallDetails.Arguments); this.GetAttribute(attributes, "gen_ai.tool.call.id").Should().Be(toolCallDetails.ToolCallId); this.GetAttribute(attributes, "gen_ai.tool.description").Should().Be(toolCallDetails.Description); this.GetAttribute(attributes, "gen_ai.tool.type").Should().Be(toolCallDetails.ToolType); diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterE2ETests.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterE2ETests.cs index f75c421e..02a62600 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterE2ETests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterE2ETests.cs @@ -192,7 +192,7 @@ public async Task AddTracing_And_ExecuteToolScope_ExporterMakesExpectedRequest() this.GetAttribute(attributes, "microsoft.a365.agent.blueprint.id").Should().Be(expectedAgentDetails.AgentBlueprintId); this.GetAttribute(attributes, "microsoft.tenant.id").Should().Be(expectedAgentDetails.TenantId); this.GetAttribute(attributes, "gen_ai.tool.name").Should().Be(toolCallDetails.ToolName); - this.GetAttribute(attributes, "gen_ai.tool.arguments").Should().Be(toolCallDetails.Arguments); + this.GetAttribute(attributes, "gen_ai.tool.call.arguments").Should().Be(toolCallDetails.Arguments); this.GetAttribute(attributes, "gen_ai.tool.call.id").Should().Be(toolCallDetails.ToolCallId); this.GetAttribute(attributes, "gen_ai.tool.description").Should().Be(toolCallDetails.Description); this.GetAttribute(attributes, "gen_ai.tool.type").Should().Be(toolCallDetails.ToolType); @@ -502,7 +502,7 @@ public async Task Exporter_Truncates_Scope() { foundExecuteTool = true; // Should be truncated - var args = this.GetAttribute(attrs, "gen_ai.tool.arguments"); + var args = this.GetAttribute(attrs, "gen_ai.tool.call.arguments"); args.Should().Be("TRUNCATED"); } } diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Common/ExportFormatterTests.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Common/ExportFormatterTests.cs index dd1f8be3..0865575a 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Common/ExportFormatterTests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Common/ExportFormatterTests.cs @@ -525,7 +525,7 @@ public void FormatMany_DoesNothing_WhenUnderLimit() { // Arrange using var activity = CreateActivity("tenant-1", "agent-1"); - activity.SetTag("gen_ai.tool.arguments", new string('a', 1024)); // 1KB + activity.SetTag("gen_ai.tool.call.arguments", new string('a', 1024)); // 1KB var resource = ResourceBuilder.CreateEmpty().Build(); var logs = new List(); var formatter = new ExportFormatter(new ListLogger(logs)); @@ -538,7 +538,7 @@ public void FormatMany_DoesNothing_WhenUnderLimit() var resourceSpans = doc.RootElement.GetProperty("resourceSpans"); var scopeSpans = resourceSpans[0].GetProperty("scopeSpans"); var span = scopeSpans[0].GetProperty("spans")[0]; - span.GetProperty("attributes").GetProperty("gen_ai.tool.arguments").GetString().Should().NotBe("TRUNCATED"); + span.GetProperty("attributes").GetProperty("gen_ai.tool.call.arguments").GetString().Should().NotBe("TRUNCATED"); logs.Should().NotContain(l => l.Contains("Truncated")); } @@ -547,7 +547,7 @@ public void FormatMany_TruncatesSingleLargeKey() { // Arrange using var activity = CreateActivity("tenant-1", "agent-2"); - activity.SetTag("gen_ai.tool.arguments", new string('b', 300 * 1024)); // 300KB + activity.SetTag("gen_ai.tool.call.arguments", new string('b', 300 * 1024)); // 300KB var resource = ResourceBuilder.CreateEmpty().Build(); var logs = new List(); var formatter = new ExportFormatter(new ListLogger(logs)); @@ -560,9 +560,9 @@ public void FormatMany_TruncatesSingleLargeKey() var resourceSpans = doc.RootElement.GetProperty("resourceSpans"); var scopeSpans = resourceSpans[0].GetProperty("scopeSpans"); var span = scopeSpans[0].GetProperty("spans")[0]; - span.GetProperty("attributes").GetProperty("gen_ai.tool.arguments").GetString().Should().Be("TRUNCATED"); - logs.Should().Contain(l => l.Contains("Key 'gen_ai.tool.arguments' size = ")); - logs.Should().Contain(l => l.Contains("Truncated 'gen_ai.tool.arguments'")); + span.GetProperty("attributes").GetProperty("gen_ai.tool.call.arguments").GetString().Should().Be("TRUNCATED"); + logs.Should().Contain(l => l.Contains("Key 'gen_ai.tool.call.arguments' size = ")); + logs.Should().Contain(l => l.Contains("Truncated 'gen_ai.tool.call.arguments'")); } [TestMethod] @@ -570,7 +570,7 @@ public void FormatMany_TruncatesMultipleKeys_LargestFirst() { // Arrange using var activity = CreateActivity("tenant-1", "agent-1"); - activity.SetTag("gen_ai.tool.arguments", new string('c', 200 * 1024)); + activity.SetTag("gen_ai.tool.call.arguments", new string('c', 200 * 1024)); activity.SetTag("gen_ai.tool.call.result", new string('d', 100 * 1024)); var resource = ResourceBuilder.CreateEmpty().Build(); var logs = new List(); @@ -585,9 +585,9 @@ public void FormatMany_TruncatesMultipleKeys_LargestFirst() var scopeSpans = resourceSpans[0].GetProperty("scopeSpans"); var span = scopeSpans[0].GetProperty("spans")[0]; var attr = span.GetProperty("attributes"); - attr.GetProperty("gen_ai.tool.arguments").GetString().Should().Be("TRUNCATED"); - logs.Should().Contain(l => l.Contains("Truncated 'gen_ai.tool.arguments'")); - logs.Should().Contain(l => l.Contains("Key 'gen_ai.tool.arguments' size = ")); + attr.GetProperty("gen_ai.tool.call.arguments").GetString().Should().Be("TRUNCATED"); + logs.Should().Contain(l => l.Contains("Truncated 'gen_ai.tool.call.arguments'")); + logs.Should().Contain(l => l.Contains("Key 'gen_ai.tool.call.arguments' size = ")); logs.Should().Contain(l => l.Contains("Key 'gen_ai.tool.call.result' size = ")); } @@ -596,7 +596,7 @@ public void FormatMany_LogsAllKeySizes() { // Arrange using var activity = CreateActivity("tenant-1", "agent-1"); - activity.SetTag("gen_ai.tool.arguments", new string('x', 100 * 1024)); + activity.SetTag("gen_ai.tool.call.arguments", new string('x', 100 * 1024)); activity.SetTag("gen_ai.tool.call.result", new string('y', 125 * 1024)); activity.SetTag("gen_ai.input.messages", new string('z', 75 * 1024)); activity.SetTag("gen_ai.agent.invocation_input", new string('z', 0)); @@ -610,7 +610,7 @@ public void FormatMany_LogsAllKeySizes() formatter.FormatMany(new[] { activity }, resource); // Assert - logs.Should().Contain(l => l.Contains("Key 'gen_ai.tool.arguments' size = 100")); + logs.Should().Contain(l => l.Contains("Key 'gen_ai.tool.call.arguments' size = 100")); logs.Should().Contain(l => l.Contains("Key 'gen_ai.tool.call.result' size = 125")); logs.Should().Contain(l => l.Contains("Key 'gen_ai.input.messages' size = 75")); logs.Should().Contain(l => l.Contains("Key 'gen_ai.agent.invocation_input' size = 0")); diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Exporters/PayloadChunkingTests.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Exporters/PayloadChunkingTests.cs index 4fabcb61..39ed0667 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Exporters/PayloadChunkingTests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Exporters/PayloadChunkingTests.cs @@ -93,8 +93,8 @@ public void EstimateActivityBytes_OverEstimatesActualJsonSize() var attrs = new Dictionary { ["gen_ai.system"] = "openai", - ["gen_ai.tool.arguments"] = new string('x', 1000), - ["gen_ai.tool.call_result"] = new string('y', 1000), + ["gen_ai.tool.call.arguments"] = new string('x', 1000), + ["gen_ai.tool.call.result"] = new string('y', 1000), }; var activity = CreateActivity("test", attrs); From 5b0c63c3b1a8f9dacd1b0bb282dc3237b3f5dc55 Mon Sep 17 00:00:00 2001 From: PengF <126631706+fpfp100@users.noreply.github.com> Date: Thu, 7 May 2026 14:36:17 -0700 Subject: [PATCH 2/2] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../Runtime/Tracing/Scopes/OpenTelemetryConstants.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryConstants.cs b/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryConstants.cs index d0cf0fc2..1d233d82 100644 --- a/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryConstants.cs +++ b/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryConstants.cs @@ -130,7 +130,7 @@ public enum OperationNames public const string GenAiToolDescriptionKey = "gen_ai.tool.description"; /// - /// The GenAI tool arguments key. + /// The GenAI tool call arguments key. /// public const string GenAiToolArgumentsKey = "gen_ai.tool.call.arguments";