From edcf4a8d08b990249dd849ebb64cb73df008d531 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 15:03:27 +0000 Subject: [PATCH 1/4] Initial plan From cb2d86204d9d24d2ac6258ec8a7d39ff004d63a8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 15:22:29 +0000 Subject: [PATCH 2/4] Update test files to use new OpenTelemetryConstants names - Rename GenAiEventContent to GenAiToolCallResultKey - Rename GenAiChannelNameKey to ChannelNameKey - Rename GenAiChannelLinkKey to ChannelLinkKey - Rename GenAiCallerIdKey to CallerIdKey - Rename GenAiCallerUpnKey to CallerUpnKey - Rename GenAiCallerNameKey to CallerNameKey - Rename GenAiCallerClientIpKey to CallerClientIpKey - Rename GenAiCallerAgentIdKey to CallerAgentIdKey - Rename GenAiCallerAgentNameKey to CallerAgentNameKey - Rename GenAiCallerAgentApplicationIdKey to CallerAgentBlueprintIdKey - Rename GenAiCallerAgentAUIDKey to CallerAgentAUIDKey - Rename GenAiCallerAgentUPNKey to CallerAgentUPNKey - Rename GenAiCallerAgentPlatformIdKey to CallerAgentPlatformIdKey - Remove GenAiResponseIdKey assertions (removed constant) - Remove GenAiCallerTenantIdKey assertions (removed constant) - Remove GenAiCallerAgentTenantKey assertions (removed constant) - Remove GenAiExecutionTypeKey assertions (removed constant) - Remove HiringManagerIdKey assertions (removed constant) - Remove hiringManagerId parameter from Build methods - Remove RecordResponseId() calls from E2E tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../SemanticKernelSpanProcessorHelperTests.cs | 4 +- .../Middleware/BaggageTurnMiddlewareTests.cs | 4 +- .../Agent365ExporterAsyncE2ETests.cs | 3 - .../Agent365ExporterE2ETests.cs | 3 - .../DTOs/Builders/BaseDataBuilderTests.cs | 25 ++++---- .../ExecuteInferenceDataBuilderTests.cs | 19 ++---- .../Builders/ExecuteToolDataBuilderTests.cs | 22 +++---- .../Builders/InvokeAgentDataBuilderTests.cs | 59 ++++++++----------- .../DTOs/Builders/OutputDataBuilderTests.cs | 19 +++--- 9 files changed, 65 insertions(+), 93 deletions(-) diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Extension.Tests/SemanticKernelSpanProcessorHelperTests.cs b/src/Tests/Microsoft.Agents.A365.Observability.Extension.Tests/SemanticKernelSpanProcessorHelperTests.cs index 5fb530f3..4369696d 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Extension.Tests/SemanticKernelSpanProcessorHelperTests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Extension.Tests/SemanticKernelSpanProcessorHelperTests.cs @@ -136,11 +136,11 @@ public void GetGenAiUserAndChoiceMessageContent_ExtractsUserAndChoiceMessages() activity.AddEvent(new ActivityEvent(OpenTelemetryConstants.GenAiUserMessageEventName, tags: new ActivityTagsCollection { - { OpenTelemetryConstants.GenAiEventContent, JsonSerializer.Serialize(userMsg) } + { OpenTelemetryConstants.GenAiToolCallResultKey, JsonSerializer.Serialize(userMsg) } })); activity.AddEvent(new ActivityEvent(OpenTelemetryConstants.GenAiChoiceEventName, tags: new ActivityTagsCollection { - { OpenTelemetryConstants.GenAiEventContent, JsonSerializer.Serialize(choiceMsg) } + { OpenTelemetryConstants.GenAiToolCallResultKey, JsonSerializer.Serialize(choiceMsg) } })); var result = SemanticKernelSpanProcessorHelper.GetGenAiUserAndChoiceMessageContent(activity); diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Hosting.Tests/Middleware/BaggageTurnMiddlewareTests.cs b/src/Tests/Microsoft.Agents.A365.Observability.Hosting.Tests/Middleware/BaggageTurnMiddlewareTests.cs index 538ea909..d3e3a4e9 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Hosting.Tests/Middleware/BaggageTurnMiddlewareTests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Hosting.Tests/Middleware/BaggageTurnMiddlewareTests.cs @@ -27,7 +27,7 @@ public async Task OnTurnAsync_SetsOpenTelemetryBaggage() NextDelegate next = (ct) => { capturedTenantId = Baggage.Current.GetBaggage(OpenTelemetryConstants.TenantIdKey); - capturedCallerId = Baggage.Current.GetBaggage(OpenTelemetryConstants.GenAiCallerIdKey); + capturedCallerId = Baggage.Current.GetBaggage(OpenTelemetryConstants.CallerIdKey); return Task.CompletedTask; }; @@ -54,7 +54,7 @@ public async Task OnTurnAsync_SkipsBaggageForContinueConversation() NextDelegate next = (ct) => { logicCalled = true; - capturedCallerId = Baggage.Current.GetBaggage(OpenTelemetryConstants.GenAiCallerIdKey); + capturedCallerId = Baggage.Current.GetBaggage(OpenTelemetryConstants.CallerIdKey); return Task.CompletedTask; }; 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 9e281815..b9e7cdc8 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterAsyncE2ETests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterAsyncE2ETests.cs @@ -212,7 +212,6 @@ public async Task AddTracing_And_InferenceScope_ExporterMakesExpectedRequest() scope.RecordOutputMessages(new[] { "Hi there!" }); scope.RecordInputTokens(42); scope.RecordOutputTokens(84); - scope.RecordResponseId("response-xyz"); scope.RecordFinishReasons(new[] { "stop", "length" }); } @@ -247,7 +246,6 @@ public async Task AddTracing_And_InferenceScope_ExporterMakesExpectedRequest() this.GetAttribute(attributes, "gen_ai.usage.input_tokens").Should().Be("42"); this.GetAttribute(attributes, "gen_ai.usage.output_tokens").Should().Be("84"); this.GetAttribute(attributes, "gen_ai.response.finish_reasons").Should().Be("stop,length"); - this.GetAttribute(attributes, "gen_ai.response.id").Should().Be("response-xyz"); this.GetAttribute(attributes, "gen_ai.input.messages").Should().Be("Hello,World"); this.GetAttribute(attributes, "gen_ai.output.messages").Should().Be("Hi there!"); this.GetAttribute(attributes, "gen_ai.agent.type").Should().Be(expectedAgentType.ToString()); @@ -321,7 +319,6 @@ public async Task AddTracing_NestedScopes_AllExporterRequestsReceived() inferenceScope.RecordOutputMessages(new[] { "Inference output" }); inferenceScope.RecordInputTokens(10); inferenceScope.RecordOutputTokens(20); - inferenceScope.RecordResponseId("response-nested"); inferenceScope.RecordFinishReasons(new[] { "stop" }); } } 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 245a6763..9f986608 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterE2ETests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterE2ETests.cs @@ -257,7 +257,6 @@ public async Task AddTracing_And_InferenceScope_ExporterMakesExpectedRequest() scope.RecordOutputMessages(new[] { "Hi there!" }); scope.RecordInputTokens(42); scope.RecordOutputTokens(84); - scope.RecordResponseId("response-xyz"); scope.RecordFinishReasons(new[] { "stop", "length" }); } @@ -292,7 +291,6 @@ public async Task AddTracing_And_InferenceScope_ExporterMakesExpectedRequest() this.GetAttribute(attributes, "gen_ai.usage.input_tokens").Should().Be("42"); this.GetAttribute(attributes, "gen_ai.usage.output_tokens").Should().Be("84"); this.GetAttribute(attributes, "gen_ai.response.finish_reasons").Should().Be("stop,length"); - this.GetAttribute(attributes, "gen_ai.response.id").Should().Be("response-xyz"); this.GetAttribute(attributes, "gen_ai.input.messages").Should().Be("Hello,World"); this.GetAttribute(attributes, "gen_ai.output.messages").Should().Be("Hi there!"); this.GetAttribute(attributes, "gen_ai.agent.type").Should().Be(expectedAgentType.ToString()); @@ -394,7 +392,6 @@ private async Task RunNestedScopes_AllExporterRequestsReceived(bool useAgentId) inferenceScope.RecordOutputMessages(new[] { "Inference output" }); inferenceScope.RecordInputTokens(10); inferenceScope.RecordOutputTokens(20); - inferenceScope.RecordResponseId("response-nested"); inferenceScope.RecordFinishReasons(new[] { "stop" }); } } diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/BaseDataBuilderTests.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/BaseDataBuilderTests.cs index 3a1788b6..63ac1f93 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/BaseDataBuilderTests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/BaseDataBuilderTests.cs @@ -79,9 +79,8 @@ public void AddRequestDetails_PopulatesRequestKeys() { var request = new Request("content", ExecutionType.HumanToAgent, "session", new SourceMetadata(id: "src-id", name: "src-name", role: Role.Human, description: "src-desc")); var dict = TestBuilder.BuildAll(request: request); - dict.Should().ContainKey(OpenTelemetryConstants.GenAiChannelLinkKey); - dict.Should().ContainKey(OpenTelemetryConstants.GenAiChannelNameKey); - dict.Should().ContainKey(OpenTelemetryConstants.GenAiExecutionTypeKey); + dict.Should().ContainKey(OpenTelemetryConstants.ChannelLinkKey); + dict.Should().ContainKey(OpenTelemetryConstants.ChannelNameKey); } [TestMethod] @@ -89,10 +88,9 @@ public void AddCallerDetails_PopulatesCallerKeys() { var caller = new CallerDetails("caller-1", "Caller Name", "caller@upn", tenantId: "tenant-y"); var dict = TestBuilder.BuildAll(caller: caller); - dict.Should().ContainKey(OpenTelemetryConstants.GenAiCallerIdKey); - dict.Should().ContainKey(OpenTelemetryConstants.GenAiCallerUpnKey); - dict.Should().ContainKey(OpenTelemetryConstants.GenAiCallerNameKey); - dict.Should().ContainKey(OpenTelemetryConstants.GenAiCallerTenantIdKey); + dict.Should().ContainKey(OpenTelemetryConstants.CallerIdKey); + dict.Should().ContainKey(OpenTelemetryConstants.CallerUpnKey); + dict.Should().ContainKey(OpenTelemetryConstants.CallerNameKey); } [TestMethod] @@ -100,13 +98,12 @@ public void AddCallerAgentDetails_PopulatesCallerAgentKeys() { var callerAgent = new AgentDetails("c-agent", "CallerAgent", agentAUID: "ca-uid", agentUPN: "ca-upn", agentBlueprintId: "ca-bp", tenantId: "ca-tenant", agentPlatformId: "ca-platform"); var dict = TestBuilder.BuildAll(callerAgent: callerAgent); - dict.Should().ContainKey(OpenTelemetryConstants.GenAiCallerAgentIdKey); - dict.Should().ContainKey(OpenTelemetryConstants.GenAiCallerAgentNameKey); - dict.Should().ContainKey(OpenTelemetryConstants.GenAiCallerAgentApplicationIdKey); - dict.Should().ContainKey(OpenTelemetryConstants.GenAiCallerAgentAUIDKey); - dict.Should().ContainKey(OpenTelemetryConstants.GenAiCallerAgentUPNKey); - dict.Should().ContainKey(OpenTelemetryConstants.GenAiCallerAgentTenantKey); - dict.Should().ContainKey(OpenTelemetryConstants.GenAiCallerAgentPlatformIdKey); + dict.Should().ContainKey(OpenTelemetryConstants.CallerAgentIdKey); + dict.Should().ContainKey(OpenTelemetryConstants.CallerAgentNameKey); + dict.Should().ContainKey(OpenTelemetryConstants.CallerAgentBlueprintIdKey); + dict.Should().ContainKey(OpenTelemetryConstants.CallerAgentAUIDKey); + dict.Should().ContainKey(OpenTelemetryConstants.CallerAgentUPNKey); + dict.Should().ContainKey(OpenTelemetryConstants.CallerAgentPlatformIdKey); } [TestMethod] diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/ExecuteInferenceDataBuilderTests.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/ExecuteInferenceDataBuilderTests.cs index 2817f5e7..18d9d333 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/ExecuteInferenceDataBuilderTests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/ExecuteInferenceDataBuilderTests.cs @@ -41,8 +41,8 @@ public void Build_WithSourceMetadata_IncludesChannelAttributes() var data = ExecuteInferenceDataBuilder.Build(details, agent, tenant, conversationId, sourceMetadata: source); // Assert - data.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiChannelNameKey).WhoseValue.Should().Be("ChannelInf"); - data.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiChannelLinkKey).WhoseValue.Should().Be("https://channel/inf"); + data.Attributes.Should().ContainKey(OpenTelemetryConstants.ChannelNameKey).WhoseValue.Should().Be("ChannelInf"); + data.Attributes.Should().ContainKey(OpenTelemetryConstants.ChannelLinkKey).WhoseValue.Should().Be("https://channel/inf"); } [TestMethod] @@ -61,7 +61,6 @@ public void Build_WithTokensAndFinishReasons_IncludesUsageAndReasons() data.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiUsageInputTokensKey).WhoseValue.Should().Be(10); data.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiUsageOutputTokensKey).WhoseValue.Should().Be(20); data.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiResponseFinishReasonsKey).WhoseValue.Should().Be("stop"); - data.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiResponseIdKey).WhoseValue.Should().Be("resp-1"); data.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiConversationIdKey).WhoseValue.Should().Be(conversationId); } @@ -117,7 +116,6 @@ public void Build_WithNullOptionalParameters_OmitsThoseAttributes() data.Attributes.Should().NotContainKey(OpenTelemetryConstants.GenAiUsageInputTokensKey); data.Attributes.Should().NotContainKey(OpenTelemetryConstants.GenAiUsageOutputTokensKey); data.Attributes.Should().NotContainKey(OpenTelemetryConstants.GenAiResponseFinishReasonsKey); - data.Attributes.Should().NotContainKey(OpenTelemetryConstants.GenAiResponseIdKey); } [TestMethod] @@ -174,7 +172,6 @@ public void Build_WithAllParameters_SetsAllExpectedAttributes() var spanId = "span-all-inf"; var parentSpanId = "parent-all-inf"; var thoughtProcess = "First, I analyzed the request. Then, I formulated a response."; - var hiringManagerId = "hiring-manager-inf-456"; var callerDetails = new CallerDetails("caller-inf-123", "Caller Inf Name", "callerinf@example.com", System.Net.IPAddress.Parse("192.168.1.100"), "caller-tenant-inf"); // Act @@ -190,7 +187,6 @@ public void Build_WithAllParameters_SetsAllExpectedAttributes() spanId: spanId, parentSpanId: parentSpanId, thoughtProcess: thoughtProcess, - hiringManagerId: hiringManagerId, callerDetails: callerDetails); // Assert @@ -198,17 +194,14 @@ public void Build_WithAllParameters_SetsAllExpectedAttributes() attrs.Should().ContainKey(OpenTelemetryConstants.GenAiUsageInputTokensKey); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiUsageOutputTokensKey); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiResponseFinishReasonsKey); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiResponseIdKey); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiConversationIdKey); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiInputMessagesKey); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiOutputMessagesKey); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiAgentThoughtProcessKey).WhoseValue.Should().Be(thoughtProcess); - attrs.Should().ContainKey(OpenTelemetryConstants.HiringManagerIdKey).WhoseValue.Should().Be("hiring-manager-inf-456"); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiCallerIdKey).WhoseValue.Should().Be("caller-inf-123"); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiCallerNameKey).WhoseValue.Should().Be("Caller Inf Name"); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiCallerUpnKey).WhoseValue.Should().Be("callerinf@example.com"); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiCallerClientIpKey).WhoseValue.Should().Be("192.168.1.100"); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiCallerTenantIdKey).WhoseValue.Should().Be("caller-tenant-inf"); + attrs.Should().ContainKey(OpenTelemetryConstants.CallerIdKey).WhoseValue.Should().Be("caller-inf-123"); + attrs.Should().ContainKey(OpenTelemetryConstants.CallerNameKey).WhoseValue.Should().Be("Caller Inf Name"); + attrs.Should().ContainKey(OpenTelemetryConstants.CallerUpnKey).WhoseValue.Should().Be("callerinf@example.com"); + attrs.Should().ContainKey(OpenTelemetryConstants.CallerClientIpKey).WhoseValue.Should().Be("192.168.1.100"); data.StartTime.Should().Be(start); data.EndTime.Should().Be(end); data.Duration.Should().BeCloseTo(end - start, TimeSpan.FromMilliseconds(100)); diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/ExecuteToolDataBuilderTests.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/ExecuteToolDataBuilderTests.cs index d1d8171a..046daf36 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/ExecuteToolDataBuilderTests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/ExecuteToolDataBuilderTests.cs @@ -42,8 +42,8 @@ public void Build_WithSourceMetadata_IncludesChannelAttributes() var data = ExecuteToolDataBuilder.Build(toolDetails, agent, tenant, conversationId, sourceMetadata: source); // Assert - data.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiChannelNameKey).WhoseValue.Should().Be("ChannelTool"); - data.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiChannelLinkKey).WhoseValue.Should().Be("https://channel/tool"); + data.Attributes.Should().ContainKey(OpenTelemetryConstants.ChannelNameKey).WhoseValue.Should().Be("ChannelTool"); + data.Attributes.Should().ContainKey(OpenTelemetryConstants.ChannelLinkKey).WhoseValue.Should().Be("https://channel/tool"); } [TestMethod] @@ -119,7 +119,7 @@ public void Build_WithResponseContent_IncludesEventContent() var data = ExecuteToolDataBuilder.Build(toolDetails, agent, tenant, conversationId, responseContent: "result-value"); // Assert - data.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiEventContent).WhoseValue.Should().Be("result-value"); + data.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiToolCallResultKey).WhoseValue.Should().Be("result-value"); } [TestMethod] @@ -156,7 +156,7 @@ public void Build_WithNullOptionalParameters_OmitsThoseAttributes() data.Attributes.Should().NotContainKey(OpenTelemetryConstants.GenAiToolTypeKey); data.Attributes.Should().NotContainKey(OpenTelemetryConstants.GenAiToolServerNameKey); data.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiConversationIdKey).WhoseValue.Should().Be(conversationId); - data.Attributes.Should().NotContainKey(OpenTelemetryConstants.GenAiEventContent); + data.Attributes.Should().NotContainKey(OpenTelemetryConstants.GenAiToolCallResultKey); } [TestMethod] @@ -212,7 +212,6 @@ public void Build_WithAllParameters_SetsAllExpectedAttributes() var spanId = "span-all"; var parentSpanId = "parent-all"; var responseContent = "tool-response"; - var hiringManagerId = "hiring-manager-tool-123"; var callerDetails = new CallerDetails("caller-tool-123", "Caller Tool Name", "callertool@example.com", System.Net.IPAddress.Parse("10.0.0.50"), "caller-tenant-tool"); // Act @@ -226,7 +225,6 @@ public void Build_WithAllParameters_SetsAllExpectedAttributes() endTime: end, spanId: spanId, parentSpanId: parentSpanId, - hiringManagerId: hiringManagerId, callerDetails: callerDetails); // Assert @@ -236,13 +234,11 @@ public void Build_WithAllParameters_SetsAllExpectedAttributes() attrs.Should().ContainKey(OpenTelemetryConstants.GenAiToolTypeKey); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiToolServerNameKey).WhoseValue.Should().Be("full-tool-server"); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiConversationIdKey); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiEventContent); - attrs.Should().ContainKey(OpenTelemetryConstants.HiringManagerIdKey).WhoseValue.Should().Be("hiring-manager-tool-123"); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiCallerIdKey).WhoseValue.Should().Be("caller-tool-123"); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiCallerNameKey).WhoseValue.Should().Be("Caller Tool Name"); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiCallerUpnKey).WhoseValue.Should().Be("callertool@example.com"); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiCallerClientIpKey).WhoseValue.Should().Be("10.0.0.50"); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiCallerTenantIdKey).WhoseValue.Should().Be("caller-tenant-tool"); + attrs.Should().ContainKey(OpenTelemetryConstants.GenAiToolCallResultKey); + attrs.Should().ContainKey(OpenTelemetryConstants.CallerIdKey).WhoseValue.Should().Be("caller-tool-123"); + attrs.Should().ContainKey(OpenTelemetryConstants.CallerNameKey).WhoseValue.Should().Be("Caller Tool Name"); + attrs.Should().ContainKey(OpenTelemetryConstants.CallerUpnKey).WhoseValue.Should().Be("callertool@example.com"); + attrs.Should().ContainKey(OpenTelemetryConstants.CallerClientIpKey).WhoseValue.Should().Be("10.0.0.50"); data.StartTime.Should().Be(start); data.EndTime.Should().Be(end); data.Duration.Should().BeCloseTo(end - start, TimeSpan.FromMilliseconds(100)); diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/InvokeAgentDataBuilderTests.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/InvokeAgentDataBuilderTests.cs index 5db47695..b1b72268 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/InvokeAgentDataBuilderTests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/InvokeAgentDataBuilderTests.cs @@ -31,12 +31,10 @@ public void Build_IncludesRequestDetails_WhenRequestProvided() request: request); // Assert - telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiChannelNameKey); - telemetry.Attributes[OpenTelemetryConstants.GenAiChannelNameKey].Should().Be("source-name"); - telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiChannelLinkKey); - telemetry.Attributes[OpenTelemetryConstants.GenAiChannelLinkKey].Should().Be("source-description"); - telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiExecutionTypeKey); - telemetry.Attributes[OpenTelemetryConstants.GenAiExecutionTypeKey].Should().Be("HumanToAgent"); + telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.ChannelNameKey); + telemetry.Attributes[OpenTelemetryConstants.ChannelNameKey].Should().Be("source-name"); + telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.ChannelLinkKey); + telemetry.Attributes[OpenTelemetryConstants.ChannelLinkKey].Should().Be("source-description"); } [TestMethod] @@ -79,10 +77,10 @@ public void Build_IncludesCallerDetails_WhenProvided() callerDetails: callerDetails); // Assert - telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiCallerIdKey); - telemetry.Attributes[OpenTelemetryConstants.GenAiCallerIdKey].Should().Be("caller-123"); - telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiCallerNameKey); - telemetry.Attributes[OpenTelemetryConstants.GenAiCallerNameKey].Should().Be("Caller Name"); + telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.CallerIdKey); + telemetry.Attributes[OpenTelemetryConstants.CallerIdKey].Should().Be("caller-123"); + telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.CallerNameKey); + telemetry.Attributes[OpenTelemetryConstants.CallerNameKey].Should().Be("Caller Name"); } [TestMethod] @@ -104,10 +102,10 @@ public void Build_IncludesCallerAgentDetails_WhenProvided() callerAgentDetails: callerAgentDetails); // Assert - telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiCallerAgentIdKey); - telemetry.Attributes[OpenTelemetryConstants.GenAiCallerAgentIdKey].Should().Be("caller-agent-789"); - telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiCallerAgentNameKey); - telemetry.Attributes[OpenTelemetryConstants.GenAiCallerAgentNameKey].Should().Be("CallerAgent"); + telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.CallerAgentIdKey); + telemetry.Attributes[OpenTelemetryConstants.CallerAgentIdKey].Should().Be("caller-agent-789"); + telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.CallerAgentNameKey); + telemetry.Attributes[OpenTelemetryConstants.CallerAgentNameKey].Should().Be("CallerAgent"); } [TestMethod] @@ -309,7 +307,6 @@ public void Build_WithAllParameters_SetsAllExpectedAttributes() var endTime = DateTimeOffset.UtcNow; var spanId = "span123"; var parentSpanId = "parent456"; - var hiringManagerId = "hiring-manager-789"; // Act var telemetry = InvokeAgentDataBuilder.Build( @@ -324,16 +321,14 @@ public void Build_WithAllParameters_SetsAllExpectedAttributes() startTime, endTime, spanId, - parentSpanId, - hiringManagerId); + parentSpanId); // Assert - telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiChannelNameKey); - telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiCallerIdKey); - telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiCallerAgentIdKey); + telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.ChannelNameKey); + telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.CallerIdKey); + telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.CallerAgentIdKey); telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiInputMessagesKey); telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiOutputMessagesKey); - telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.HiringManagerIdKey).WhoseValue.Should().Be("hiring-manager-789"); telemetry.StartTime.Should().Be(startTime); telemetry.EndTime.Should().Be(endTime); telemetry.Duration.Should().BeCloseTo(TimeSpan.FromMinutes(1), TimeSpan.FromMilliseconds(100)); @@ -488,18 +483,16 @@ public void Build_WithAgentPlatformId_SetsExpectedAttributes() telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiConversationIdKey); telemetry.Attributes[OpenTelemetryConstants.GenAiConversationIdKey].Should().Be("conv-999"); telemetry.StartTime.Should().Be(startTime); - telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiChannelNameKey); - telemetry.Attributes[OpenTelemetryConstants.GenAiChannelNameKey].Should().Be("source-name"); - telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiChannelLinkKey); - telemetry.Attributes[OpenTelemetryConstants.GenAiChannelLinkKey].Should().Be("source-description"); - telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiExecutionTypeKey); - telemetry.Attributes[OpenTelemetryConstants.GenAiExecutionTypeKey].Should().Be("HumanToAgent"); - telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiCallerIdKey); - telemetry.Attributes[OpenTelemetryConstants.GenAiCallerIdKey].Should().Be("caller-123"); - telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiCallerNameKey); - telemetry.Attributes[OpenTelemetryConstants.GenAiCallerNameKey].Should().Be("Caller Name"); - telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiCallerUpnKey); - telemetry.Attributes[OpenTelemetryConstants.GenAiCallerUpnKey].Should().Be("caller@example.com"); + telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.ChannelNameKey); + telemetry.Attributes[OpenTelemetryConstants.ChannelNameKey].Should().Be("source-name"); + telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.ChannelLinkKey); + telemetry.Attributes[OpenTelemetryConstants.ChannelLinkKey].Should().Be("source-description"); + telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.CallerIdKey); + telemetry.Attributes[OpenTelemetryConstants.CallerIdKey].Should().Be("caller-123"); + telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.CallerNameKey); + telemetry.Attributes[OpenTelemetryConstants.CallerNameKey].Should().Be("Caller Name"); + telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.CallerUpnKey); + telemetry.Attributes[OpenTelemetryConstants.CallerUpnKey].Should().Be("caller@example.com"); telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.TenantIdKey); telemetry.Attributes[OpenTelemetryConstants.TenantIdKey].Should().Be(tenantDetails.TenantId); telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiInputMessagesKey); diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/OutputDataBuilderTests.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/OutputDataBuilderTests.cs index 902a335a..51c71f58 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/OutputDataBuilderTests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/OutputDataBuilderTests.cs @@ -28,9 +28,9 @@ public void Build_WithMinimalParameters_SetsBasicAttributes() // Null optional parameters should be omitted data.Attributes.Should().NotContainKey(OpenTelemetryConstants.GenAiConversationIdKey); - data.Attributes.Should().NotContainKey(OpenTelemetryConstants.GenAiChannelNameKey); - data.Attributes.Should().NotContainKey(OpenTelemetryConstants.GenAiChannelLinkKey); - data.Attributes.Should().NotContainKey(OpenTelemetryConstants.GenAiCallerIdKey); + data.Attributes.Should().NotContainKey(OpenTelemetryConstants.ChannelNameKey); + data.Attributes.Should().NotContainKey(OpenTelemetryConstants.ChannelLinkKey); + data.Attributes.Should().NotContainKey(OpenTelemetryConstants.CallerIdKey); } [TestMethod] @@ -154,13 +154,12 @@ public void Build_WithAllParameters_SetsAllExpectedAttributes() // Assert var attrs = data.Attributes; attrs.Should().ContainKey(OpenTelemetryConstants.GenAiConversationIdKey).WhoseValue.Should().Be("conv-output-all"); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiChannelNameKey).WhoseValue.Should().Be("ChannelOutput"); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiChannelLinkKey).WhoseValue.Should().Be("https://channel/output"); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiCallerIdKey).WhoseValue.Should().Be("caller-output-123"); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiCallerNameKey).WhoseValue.Should().Be("Output Caller Name"); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiCallerUpnKey).WhoseValue.Should().Be("calleroutput@example.com"); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiCallerClientIpKey).WhoseValue.Should().Be("192.168.1.50"); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiCallerTenantIdKey).WhoseValue.Should().Be("caller-tenant-output"); + attrs.Should().ContainKey(OpenTelemetryConstants.ChannelNameKey).WhoseValue.Should().Be("ChannelOutput"); + attrs.Should().ContainKey(OpenTelemetryConstants.ChannelLinkKey).WhoseValue.Should().Be("https://channel/output"); + attrs.Should().ContainKey(OpenTelemetryConstants.CallerIdKey).WhoseValue.Should().Be("caller-output-123"); + attrs.Should().ContainKey(OpenTelemetryConstants.CallerNameKey).WhoseValue.Should().Be("Output Caller Name"); + attrs.Should().ContainKey(OpenTelemetryConstants.CallerUpnKey).WhoseValue.Should().Be("calleroutput@example.com"); + attrs.Should().ContainKey(OpenTelemetryConstants.CallerClientIpKey).WhoseValue.Should().Be("192.168.1.50"); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiOutputMessagesKey).WhoseValue.Should().Be("Hello,World"); data.StartTime.Should().Be(start); data.EndTime.Should().Be(end); From 2442fb42aa50f79c84991be7f6645441f832166a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 15:38:38 +0000 Subject: [PATCH 3/4] Update integration tests with new telemetry attribute names Update attribute name string literals in Agent365ExporterAsyncE2ETests.cs and Agent365ExporterE2ETests.cs to match the new OpenTelemetry constants: Renamed attributes: - gen_ai.channel.name -> microsoft.channel.name - gen_ai.channel.link -> microsoft.channel.link - gen_ai.agent.userid -> microsoft.agent.user.id - gen_ai.agent.upn -> microsoft.agent.user.upn - gen_ai.agent.applicationid -> microsoft.a365.agent.blueprint.id - gen_ai.caller.id -> microsoft.caller.id - gen_ai.caller.name -> microsoft.caller.name - gen_ai.caller.upn -> microsoft.caller.upn - gen_ai.caller.client.ip -> client.address - tenant.id -> microsoft.tenant.id - gen_ai.event.content -> gen_ai.tool.call.result Removed assertions for deprecated attributes: - gen_ai.agent.type - gen_ai.execution.type - gen_ai.caller.tenantid Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../FunctionInvocationFilter.cs | 2 +- .../SemanticKernelSpanProcessorHelper.cs | 2 +- .../Extensions/BaggageBuilderExtensions.cs | 13 --- .../Extensions/InvokeAgentScopeExtensions.cs | 10 --- .../Extensions/TurnContextExtensions.cs | 25 +----- .../Middleware/OutputLoggingMiddleware.cs | 22 +---- .../Runtime/Common/BaggageBuilder.cs | 56 ++---------- .../Runtime/Common/ExportFormatter.cs | 2 +- .../Runtime/DTOs/Builders/BaseDataBuilder.cs | 62 ++++++-------- .../Builders/ExecuteInferenceDataBuilder.cs | 12 +-- .../DTOs/Builders/ExecuteToolDataBuilder.cs | 12 +-- .../DTOs/Builders/InvokeAgentDataBuilder.cs | 8 -- .../Tracing/Processors/ActivityProcessor.cs | 26 +++--- .../Tracing/Scopes/ExecuteToolScope.cs | 4 +- .../Runtime/Tracing/Scopes/InferenceScope.cs | 24 ++---- .../Tracing/Scopes/InvokeAgentScope.cs | 20 ++--- .../Tracing/Scopes/OpenTelemetryConstants.cs | 85 +++++++++---------- .../Tracing/Scopes/OpenTelemetryScope.cs | 14 ++- .../Agent365ExporterAsyncE2ETests.cs | 49 +++++------ .../Agent365ExporterE2ETests.cs | 69 ++++++--------- 20 files changed, 167 insertions(+), 350 deletions(-) diff --git a/src/Observability/Extensions/SemanticKernel/FunctionInvocationFilter.cs b/src/Observability/Extensions/SemanticKernel/FunctionInvocationFilter.cs index dd3e06ab..f438e64b 100644 --- a/src/Observability/Extensions/SemanticKernel/FunctionInvocationFilter.cs +++ b/src/Observability/Extensions/SemanticKernel/FunctionInvocationFilter.cs @@ -30,7 +30,7 @@ public async Task OnFunctionInvocationAsync(FunctionInvocationContext context, F Activity.Current.AddTag(OpenTelemetryConstants.GenAiToolArgumentsKey, arguments); Activity.Current.AddTag(OpenTelemetryConstants.GenAiToolTypeKey, ToolType.Function); await InvokeWithErrorHandlingAsync(next, context); - Activity.Current.AddTag(OpenTelemetryConstants.GenAiEventContent, GetResult(context)); + Activity.Current.AddTag(OpenTelemetryConstants.GenAiToolCallResultKey, GetResult(context)); Activity.Current.AddTag(OpenTelemetryConstants.GenAiToolCallIdKey, context.Function.PluginName); return; } diff --git a/src/Observability/Extensions/SemanticKernel/Utils/SemanticKernelSpanProcessorHelper.cs b/src/Observability/Extensions/SemanticKernel/Utils/SemanticKernelSpanProcessorHelper.cs index fe7c66b5..f0e1a883 100644 --- a/src/Observability/Extensions/SemanticKernel/Utils/SemanticKernelSpanProcessorHelper.cs +++ b/src/Observability/Extensions/SemanticKernel/Utils/SemanticKernelSpanProcessorHelper.cs @@ -300,7 +300,7 @@ public static Dictionary> GetGenAiUserAndChoiceMessageConte private static string? GetEventContentTag(ActivityEvent activityEvent) { return activityEvent.Tags? - .FirstOrDefault(tag => tag.Key == OpenTelemetryConstants.GenAiEventContent).Value as string; + .FirstOrDefault(tag => tag.Key == OpenTelemetryConstants.GenAiToolCallResultKey).Value as string; } /// diff --git a/src/Observability/Hosting/Extensions/BaggageBuilderExtensions.cs b/src/Observability/Hosting/Extensions/BaggageBuilderExtensions.cs index 87dd9774..d3140f11 100644 --- a/src/Observability/Hosting/Extensions/BaggageBuilderExtensions.cs +++ b/src/Observability/Hosting/Extensions/BaggageBuilderExtensions.cs @@ -23,7 +23,6 @@ public static BaggageBuilder FromTurnContext(this BaggageBuilder baggageBuilder, baggageBuilder .SetCallerBaggage(turnContext) - .SetExecutionTypeBaggage(turnContext) .SetTargetAgentBaggage(turnContext) .SetTenantIdBaggage(turnContext) .SetSourceMetadataBaggage(turnContext) @@ -44,18 +43,6 @@ public static BaggageBuilder SetCallerBaggage(this BaggageBuilder baggageBuilder return baggageBuilder; } - /// - /// Sets the execution type baggage value based on caller and recipient agentic status. - /// - /// The BaggageBuilder instance. - /// The turn context containing activity information. - /// The updated BaggageBuilder instance. - public static BaggageBuilder SetExecutionTypeBaggage(this BaggageBuilder baggageBuilder, ITurnContext turnContext) - { - baggageBuilder.SetRange(turnContext.GetExecutionTypePair()); - return baggageBuilder; - } - /// /// Sets the target agent-related baggage values from the TurnContext. /// diff --git a/src/Observability/Hosting/Extensions/InvokeAgentScopeExtensions.cs b/src/Observability/Hosting/Extensions/InvokeAgentScopeExtensions.cs index b0abfdf5..6b580f58 100644 --- a/src/Observability/Hosting/Extensions/InvokeAgentScopeExtensions.cs +++ b/src/Observability/Hosting/Extensions/InvokeAgentScopeExtensions.cs @@ -24,7 +24,6 @@ public static InvokeAgentScope FromTurnContext(this InvokeAgentScope invokeAgent invokeAgentScope .SetCallerTags(turnContext) - .SetExecutionTypeTags(turnContext) .SetTargetAgentTags(turnContext) .SetTenantIdTags(turnContext) .SetSourceMetadataTags(turnContext) @@ -45,15 +44,6 @@ public static InvokeAgentScope SetCallerTags(this InvokeAgentScope invokeAgentSc return invokeAgentScope; } - /// - /// Sets the execution type tag based on caller and recipient agentic status. - /// - public static InvokeAgentScope SetExecutionTypeTags(this InvokeAgentScope invokeAgentScope, ITurnContext turnContext) - { - invokeAgentScope.RecordAttributes(turnContext.GetExecutionTypePair()); - return invokeAgentScope; - } - /// /// Sets the target agent-related tags from the TurnContext. /// diff --git a/src/Observability/Hosting/Extensions/TurnContextExtensions.cs b/src/Observability/Hosting/Extensions/TurnContextExtensions.cs index 61b2fc74..d15a2f1e 100644 --- a/src/Observability/Hosting/Extensions/TurnContextExtensions.cs +++ b/src/Observability/Hosting/Extensions/TurnContextExtensions.cs @@ -1,9 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System; using System.Collections.Generic; -using Microsoft.Agents.A365.Observability.Runtime.Tracing.Contracts; using Microsoft.Agents.A365.Observability.Runtime.Tracing.Scopes; using Microsoft.Agents.Builder; @@ -14,7 +12,6 @@ namespace Microsoft.Agents.A365.Observability.Hosting.Extensions /// public static class TurnContextExtensions { - private const string AgentRole = "agenticUser"; private const string O11ySpanIdKey = "O11ySpanId"; private const string O11yTraceIdKey = "O11yTraceId"; @@ -23,22 +20,8 @@ public static class TurnContextExtensions /// public static IEnumerable> GetCallerBaggagePairs(this ITurnContext turnContext) { - yield return new KeyValuePair(OpenTelemetryConstants.GenAiCallerIdKey, turnContext.Activity?.From?.Id); - yield return new KeyValuePair(OpenTelemetryConstants.GenAiCallerNameKey, turnContext.Activity?.From?.Name); - yield return new KeyValuePair(OpenTelemetryConstants.GenAiCallerTenantIdKey, turnContext.Activity?.From?.TenantId); - } - - /// - /// Extracts the execution type baggage key-value pair based on caller and recipient agentic status. - /// - public static IEnumerable> GetExecutionTypePair(this ITurnContext turnContext) - { - var isAgenticCaller = turnContext.Activity?.From?.AgenticUserId != null - || (turnContext.Activity?.From?.Role != null && turnContext.Activity.From.Role.Equals(AgentRole, StringComparison.OrdinalIgnoreCase)); - var isAgenticRecipient = turnContext.Activity?.Recipient?.AgenticUserId != null - || (turnContext.Activity?.Recipient?.Role != null && turnContext.Activity.Recipient.Role.Equals(AgentRole, StringComparison.OrdinalIgnoreCase)); - var executionType = isAgenticRecipient && isAgenticCaller ? ExecutionType.Agent2Agent.ToString() : ExecutionType.HumanToAgent.ToString(); - yield return new KeyValuePair(OpenTelemetryConstants.GenAiExecutionTypeKey, executionType); + yield return new KeyValuePair(OpenTelemetryConstants.CallerIdKey, turnContext.Activity?.From?.Id); + yield return new KeyValuePair(OpenTelemetryConstants.CallerNameKey, turnContext.Activity?.From?.Name); } /// @@ -86,8 +69,8 @@ public static class TurnContextExtensions /// public static IEnumerable> GetSourceMetadataBaggagePairs(this ITurnContext turnContext) { - yield return new KeyValuePair(OpenTelemetryConstants.GenAiChannelNameKey, turnContext.Activity?.ChannelId?.Channel); - yield return new KeyValuePair(OpenTelemetryConstants.GenAiChannelLinkKey, turnContext.Activity?.ChannelId?.SubChannel); + yield return new KeyValuePair(OpenTelemetryConstants.ChannelNameKey, turnContext.Activity?.ChannelId?.Channel); + yield return new KeyValuePair(OpenTelemetryConstants.ChannelLinkKey, turnContext.Activity?.ChannelId?.SubChannel); } /// diff --git a/src/Observability/Hosting/Middleware/OutputLoggingMiddleware.cs b/src/Observability/Hosting/Middleware/OutputLoggingMiddleware.cs index f60756d3..ceff6f12 100644 --- a/src/Observability/Hosting/Middleware/OutputLoggingMiddleware.cs +++ b/src/Observability/Hosting/Middleware/OutputLoggingMiddleware.cs @@ -53,7 +53,6 @@ public async Task OnTurnAsync(ITurnContext turnContext, NextDelegate next, Cance var callerDetails = DeriveCallerDetails(turnContext); var conversationId = turnContext.Activity?.Conversation?.Id; var sourceMetadata = DeriveSourceMetadata(turnContext); - var executionType = DeriveExecutionType(turnContext); turnContext.OnSendActivities(CreateSendHandler( turnContext, @@ -61,8 +60,7 @@ public async Task OnTurnAsync(ITurnContext turnContext, NextDelegate next, Cance tenantDetails, callerDetails, conversationId, - sourceMetadata, - executionType)); + sourceMetadata)); await next(cancellationToken).ConfigureAwait(false); } @@ -130,28 +128,13 @@ public async Task OnTurnAsync(ITurnContext turnContext, NextDelegate next, Cance description: channelId.SubChannel); } - private static string? DeriveExecutionType(ITurnContext turnContext) - { - var pairs = turnContext.GetExecutionTypePair(); - foreach (var pair in pairs) - { - if (pair.Key == OpenTelemetryConstants.GenAiExecutionTypeKey) - { - return pair.Value?.ToString(); - } - } - - return null; - } - private static SendActivitiesHandler CreateSendHandler( ITurnContext turnContext, AgentDetails agentDetails, TenantDetails tenantDetails, CallerDetails? callerDetails, string? conversationId, - SourceMetadata? sourceMetadata, - string? executionType) + SourceMetadata? sourceMetadata) { return async (ctx, activities, nextSend) => { @@ -188,7 +171,6 @@ private static SendActivitiesHandler CreateSendHandler( try { - outputScope.SetTagMaybe(OpenTelemetryConstants.GenAiExecutionTypeKey, executionType); return await nextSend().ConfigureAwait(false); } catch (Exception ex) diff --git a/src/Observability/Runtime/Common/BaggageBuilder.cs b/src/Observability/Runtime/Common/BaggageBuilder.cs index a45cee3c..d5668b2c 100644 --- a/src/Observability/Runtime/Common/BaggageBuilder.cs +++ b/src/Observability/Runtime/Common/BaggageBuilder.cs @@ -1,6 +1,5 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using Microsoft.Agents.A365.Observability.Runtime.Tracing.Contracts; using Microsoft.Agents.A365.Observability.Runtime.Tracing.Scopes; using OpenTelemetry; using System; @@ -19,7 +18,6 @@ namespace Microsoft.Agents.A365.Observability.Runtime.Common /// /// Certification Requirements: To ensure the agent passes certification, the following properties must be set using their respective methods: /// - /// /// /// /// @@ -60,18 +58,6 @@ public void Dispose() private readonly Dictionary _pairs = new Dictionary(); - /// - /// Sets the operation source baggage value. - /// - /// - /// This property must be set for the agent to pass certification requirements. - /// - public BaggageBuilder OperationSource(OperationSource source) - { - Set(OpenTelemetryConstants.OperationSourceKey, source.ToString()); - return this; - } - /// /// Sets the tenant ID baggage value. /// @@ -156,15 +142,6 @@ public BaggageBuilder AgentBlueprintId(string? v) return this; } - /// - /// Sets the agent type baggage value. - /// - public BaggageBuilder AgentType(AgentType? v) - { - Set(OpenTelemetryConstants.GenAiAgentTypeKey, v?.ToString()); - return this; - } - /// /// Sets the agent platform ID baggage value. /// @@ -174,15 +151,6 @@ public BaggageBuilder AgentPlatformId(string? v) return this; } - /// - /// Sets the correlation ID baggage value. - /// - public BaggageBuilder CorrelationId(string? v) - { - Set(OpenTelemetryConstants.CorrelationIdKey, v); - return this; - } - /// /// Sets the caller ID baggage value. /// @@ -191,7 +159,7 @@ public BaggageBuilder CorrelationId(string? v) /// public BaggageBuilder CallerId(string? v) { - Set(OpenTelemetryConstants.GenAiCallerIdKey, v); + Set(OpenTelemetryConstants.CallerIdKey, v); return this; } @@ -203,7 +171,7 @@ public BaggageBuilder CallerId(string? v) /// public BaggageBuilder CallerUpn(string? v) { - Set(OpenTelemetryConstants.GenAiCallerUpnKey, v); + Set(OpenTelemetryConstants.CallerUpnKey, v); return this; } @@ -215,7 +183,7 @@ public BaggageBuilder CallerUpn(string? v) /// public BaggageBuilder CallerName(string? v) { - Set(OpenTelemetryConstants.GenAiCallerNameKey, v); + Set(OpenTelemetryConstants.CallerNameKey, v); return this; } @@ -224,7 +192,7 @@ public BaggageBuilder CallerName(string? v) /// public BaggageBuilder CallerClientIp(IPAddress v) { - Set(OpenTelemetryConstants.GenAiCallerClientIpKey, v.ToString()); + Set(OpenTelemetryConstants.CallerClientIpKey, v.ToString()); return this; } @@ -257,7 +225,7 @@ public BaggageBuilder ConversationItemLink(string? v) /// public BaggageBuilder ChannelName(string? v) { - Set(OpenTelemetryConstants.GenAiChannelNameKey, v); + Set(OpenTelemetryConstants.ChannelNameKey, v); return this; } @@ -266,7 +234,7 @@ public BaggageBuilder ChannelName(string? v) /// public BaggageBuilder ChannelLink(string? v) { - Set(OpenTelemetryConstants.GenAiChannelLinkKey, v); + Set(OpenTelemetryConstants.ChannelLinkKey, v); return this; } @@ -288,15 +256,6 @@ public BaggageBuilder SessionDescription(string? v) return this; } - /// - /// Sets the hiring manager ID baggage value. - /// - public BaggageBuilder HiringManagerId(string? v) - { - Set(OpenTelemetryConstants.HiringManagerIdKey, v); - return this; - } - /// /// Applies the collected baggage to the current context. /// @@ -317,11 +276,10 @@ public IDisposable Build() /// /// Convenience: begin a request baggage scope with common fields. /// - public static IDisposable SetRequestContext(string? tenantId, string? agentId, string? correlationId = null) + public static IDisposable SetRequestContext(string? tenantId, string? agentId) => new BaggageBuilder() .TenantId(tenantId) .AgentId(agentId) - .CorrelationId(correlationId) .Build(); /// diff --git a/src/Observability/Runtime/Common/ExportFormatter.cs b/src/Observability/Runtime/Common/ExportFormatter.cs index 60ac4830..6c2e1c50 100644 --- a/src/Observability/Runtime/Common/ExportFormatter.cs +++ b/src/Observability/Runtime/Common/ExportFormatter.cs @@ -24,7 +24,7 @@ public class ExportFormatter private static readonly string[] LargePayloadAttributeKeys = new[] { OpenTelemetryConstants.GenAiToolArgumentsKey, - OpenTelemetryConstants.GenAiEventContent, + OpenTelemetryConstants.GenAiToolCallResultKey, OpenTelemetryConstants.GenAiInputMessagesKey, OpenTelemetryConstants.GenAiOutputMessagesKey, AutoInstrumentationConstants.GenAiInvocationInputKey, diff --git a/src/Observability/Runtime/DTOs/Builders/BaseDataBuilder.cs b/src/Observability/Runtime/DTOs/Builders/BaseDataBuilder.cs index c68d4abb..890ecab9 100644 --- a/src/Observability/Runtime/DTOs/Builders/BaseDataBuilder.cs +++ b/src/Observability/Runtime/DTOs/Builders/BaseDataBuilder.cs @@ -27,20 +27,17 @@ public abstract class BaseDataBuilder where T : BaseData OpenTelemetryConstants.TenantIdKey, OpenTelemetryConstants.ServerAddressKey, OpenTelemetryConstants.ServerPortKey, - OpenTelemetryConstants.GenAiChannelNameKey, - OpenTelemetryConstants.GenAiChannelLinkKey, - OpenTelemetryConstants.GenAiExecutionTypeKey, - OpenTelemetryConstants.GenAiCallerIdKey, - OpenTelemetryConstants.GenAiCallerUpnKey, - OpenTelemetryConstants.GenAiCallerNameKey, - OpenTelemetryConstants.GenAiCallerTenantIdKey, - OpenTelemetryConstants.GenAiCallerAgentNameKey, - OpenTelemetryConstants.GenAiCallerAgentIdKey, - OpenTelemetryConstants.GenAiCallerAgentApplicationIdKey, - OpenTelemetryConstants.GenAiCallerAgentAUIDKey, - OpenTelemetryConstants.GenAiCallerAgentUPNKey, - OpenTelemetryConstants.GenAiCallerAgentTenantKey, - OpenTelemetryConstants.GenAiCallerClientIpKey, + OpenTelemetryConstants.ChannelNameKey, + OpenTelemetryConstants.ChannelLinkKey, + OpenTelemetryConstants.CallerIdKey, + OpenTelemetryConstants.CallerUpnKey, + OpenTelemetryConstants.CallerNameKey, + OpenTelemetryConstants.CallerAgentNameKey, + OpenTelemetryConstants.CallerAgentIdKey, + OpenTelemetryConstants.CallerAgentBlueprintIdKey, + OpenTelemetryConstants.CallerAgentAUIDKey, + OpenTelemetryConstants.CallerAgentUPNKey, + OpenTelemetryConstants.CallerClientIpKey, OpenTelemetryConstants.GenAiConversationIdKey, OpenTelemetryConstants.SessionIdKey, OpenTelemetryConstants.GenAiToolNameKey, @@ -48,16 +45,14 @@ public abstract class BaseDataBuilder where T : BaseData OpenTelemetryConstants.GenAiToolCallIdKey, OpenTelemetryConstants.GenAiToolDescriptionKey, OpenTelemetryConstants.GenAiToolTypeKey, - OpenTelemetryConstants.GenAiEventContent, + OpenTelemetryConstants.GenAiToolCallResultKey, OpenTelemetryConstants.GenAiOperationNameKey, OpenTelemetryConstants.GenAiRequestModelKey, OpenTelemetryConstants.GenAiProviderNameKey, OpenTelemetryConstants.GenAiUsageInputTokensKey, OpenTelemetryConstants.GenAiUsageOutputTokensKey, OpenTelemetryConstants.GenAiResponseFinishReasonsKey, - OpenTelemetryConstants.GenAiResponseIdKey, - OpenTelemetryConstants.GenAiAgentThoughtProcessKey, - OpenTelemetryConstants.HiringManagerIdKey + OpenTelemetryConstants.GenAiAgentThoughtProcessKey }; /// @@ -96,7 +91,6 @@ protected static void AddAgentDetails(IDictionary attributes, A AddIfNotNull(attributes, OpenTelemetryConstants.GenAiAgentUPNKey, agentDetails.AgentUPN); AddIfNotNull(attributes, OpenTelemetryConstants.GenAiAgentBlueprintIdKey, agentDetails.AgentBlueprintId); AddIfNotNull(attributes, OpenTelemetryConstants.GenAiAgentPlatformIdKey, agentDetails.AgentPlatformId); - AddIfNotNull(attributes, OpenTelemetryConstants.GenAiAgentTypeKey, agentDetails.AgentType?.ToString()); } /// @@ -121,7 +115,7 @@ protected static void AddEndpointDetails(IDictionary attributes // Only record port if it is different from 443 if (endpoint.Port != 443) { - AddIfNotNull(attributes, OpenTelemetryConstants.ServerPortKey, endpoint.Port); + AddIfNotNull(attributes, OpenTelemetryConstants.ServerPortKey, endpoint.Port.ToString()); } } @@ -133,7 +127,6 @@ protected static void AddRequestDetails(IDictionary attributes, if (request == null) return; AddSourceMetadataAttributes(attributes, request.SourceMetadata); - AddIfNotNull(attributes, OpenTelemetryConstants.GenAiExecutionTypeKey, request.ExecutionType?.ToString()); } /// @@ -143,11 +136,10 @@ protected static void AddCallerDetails(IDictionary attributes, { if (callerDetails == null) return; - AddIfNotNull(attributes, OpenTelemetryConstants.GenAiCallerIdKey, callerDetails.CallerId); - AddIfNotNull(attributes, OpenTelemetryConstants.GenAiCallerUpnKey, callerDetails.CallerUpn); - AddIfNotNull(attributes, OpenTelemetryConstants.GenAiCallerNameKey, callerDetails.CallerName); - AddIfNotNull(attributes, OpenTelemetryConstants.GenAiCallerClientIpKey, callerDetails.CallerClientIP?.ToString()); - AddIfNotNull(attributes, OpenTelemetryConstants.GenAiCallerTenantIdKey, callerDetails.TenantId); + AddIfNotNull(attributes, OpenTelemetryConstants.CallerIdKey, callerDetails.CallerId); + AddIfNotNull(attributes, OpenTelemetryConstants.CallerUpnKey, callerDetails.CallerUpn); + AddIfNotNull(attributes, OpenTelemetryConstants.CallerNameKey, callerDetails.CallerName); + AddIfNotNull(attributes, OpenTelemetryConstants.CallerClientIpKey, callerDetails.CallerClientIP?.ToString()); } /// @@ -157,14 +149,12 @@ protected static void AddCallerAgentDetails(IDictionary attribu { if (callerAgentDetails == null) return; - AddIfNotNull(attributes, OpenTelemetryConstants.GenAiCallerAgentNameKey, callerAgentDetails.AgentName); - AddIfNotNull(attributes, OpenTelemetryConstants.GenAiCallerAgentIdKey, callerAgentDetails.AgentId); - AddIfNotNull(attributes, OpenTelemetryConstants.GenAiCallerAgentApplicationIdKey, callerAgentDetails.AgentBlueprintId); - AddIfNotNull(attributes, OpenTelemetryConstants.GenAiCallerAgentAUIDKey, callerAgentDetails.AgentAUID); - AddIfNotNull(attributes, OpenTelemetryConstants.GenAiCallerAgentUPNKey, callerAgentDetails.AgentUPN); - AddIfNotNull(attributes, OpenTelemetryConstants.GenAiCallerAgentTenantKey, callerAgentDetails.TenantId); - AddIfNotNull(attributes, OpenTelemetryConstants.GenAiCallerAgentPlatformIdKey, callerAgentDetails.AgentPlatformId); - AddIfNotNull(attributes, OpenTelemetryConstants.GenAiCallerAgentTypeKey, callerAgentDetails.AgentType?.ToString()); + AddIfNotNull(attributes, OpenTelemetryConstants.CallerAgentNameKey, callerAgentDetails.AgentName); + AddIfNotNull(attributes, OpenTelemetryConstants.CallerAgentIdKey, callerAgentDetails.AgentId); + AddIfNotNull(attributes, OpenTelemetryConstants.CallerAgentBlueprintIdKey, callerAgentDetails.AgentBlueprintId); + AddIfNotNull(attributes, OpenTelemetryConstants.CallerAgentAUIDKey, callerAgentDetails.AgentAUID); + AddIfNotNull(attributes, OpenTelemetryConstants.CallerAgentUPNKey, callerAgentDetails.AgentUPN); + AddIfNotNull(attributes, OpenTelemetryConstants.CallerAgentPlatformIdKey, callerAgentDetails.AgentPlatformId); } /// @@ -174,8 +164,8 @@ protected static void AddSourceMetadataAttributes(IDictionary a { if (sourceMetadata == null) return; - AddIfNotNull(attributes, OpenTelemetryConstants.GenAiChannelNameKey, sourceMetadata.Name); - AddIfNotNull(attributes, OpenTelemetryConstants.GenAiChannelLinkKey, sourceMetadata.Description); + AddIfNotNull(attributes, OpenTelemetryConstants.ChannelNameKey, sourceMetadata.Name); + AddIfNotNull(attributes, OpenTelemetryConstants.ChannelLinkKey, sourceMetadata.Description); } /// diff --git a/src/Observability/Runtime/DTOs/Builders/ExecuteInferenceDataBuilder.cs b/src/Observability/Runtime/DTOs/Builders/ExecuteInferenceDataBuilder.cs index 4549a2b6..09508d74 100644 --- a/src/Observability/Runtime/DTOs/Builders/ExecuteInferenceDataBuilder.cs +++ b/src/Observability/Runtime/DTOs/Builders/ExecuteInferenceDataBuilder.cs @@ -28,7 +28,6 @@ public class ExecuteInferenceDataBuilder : BaseDataBuilder /// Optional parent span ID for distributed tracing. /// Optional source metadata for the inference call. /// Optional agent thought process for the inference. - /// Optional hiring manager ID. /// Optional details about the non-agentic caller. /// Optional dictionary of extra attributes. /// An ExecuteInferenceData object containing all telemetry data. @@ -45,7 +44,6 @@ public static ExecuteInferenceData Build( string? parentSpanId = null, SourceMetadata? sourceMetadata = null, string? thoughtProcess = null, - string? hiringManagerId = null, CallerDetails? callerDetails = null, IDictionary? extraAttributes = null) { @@ -58,7 +56,6 @@ public static ExecuteInferenceData Build( outputMessages, sourceMetadata, thoughtProcess, - hiringManagerId, callerDetails, extraAttributes); @@ -74,7 +71,6 @@ public static ExecuteInferenceData Build( string[]? outputMessages, SourceMetadata? sourceMetadata, string? thoughtProcess, - string? hiringManagerId, CallerDetails? callerDetails, IDictionary? extraAttributes = null) { @@ -100,9 +96,6 @@ public static ExecuteInferenceData Build( // Source metadata AddSourceMetadataAttributes(attributes, sourceMetadata); - // Add hiring manager ID - AddIfNotNull(attributes, HiringManagerIdKey, hiringManagerId); - // Add caller details AddCallerDetails(attributes, callerDetails); @@ -116,14 +109,13 @@ private static void AddInferenceCallDetails( IDictionary attributes, InferenceCallDetails inferenceCallDetails) { - var (operationName, model, providerName, inputTokens, outputTokens, finishReasons, responseId) = inferenceCallDetails; + var (operationName, model, providerName, inputTokens, outputTokens, finishReasons, _) = inferenceCallDetails; AddIfNotNull(attributes, GenAiOperationNameKey, operationName.ToString().ToLowerInvariant()); AddIfNotNull(attributes, GenAiRequestModelKey, model); AddIfNotNull(attributes, GenAiProviderNameKey, providerName); AddIfNotNull(attributes, GenAiUsageInputTokensKey, inputTokens); AddIfNotNull(attributes, GenAiUsageOutputTokensKey, outputTokens); - AddIfNotNull(attributes, GenAiResponseFinishReasonsKey, finishReasons != null ? string.Join(",", finishReasons) : null); - AddIfNotNull(attributes, GenAiResponseIdKey, responseId); + AddIfNotNull(attributes, GenAiResponseFinishReasonsKey, finishReasons); } } } diff --git a/src/Observability/Runtime/DTOs/Builders/ExecuteToolDataBuilder.cs b/src/Observability/Runtime/DTOs/Builders/ExecuteToolDataBuilder.cs index 38bc4ef5..533a2027 100644 --- a/src/Observability/Runtime/DTOs/Builders/ExecuteToolDataBuilder.cs +++ b/src/Observability/Runtime/DTOs/Builders/ExecuteToolDataBuilder.cs @@ -29,7 +29,6 @@ public class ExecuteToolDataBuilder : BaseDataBuilder /// Optional span ID for the operation. /// Optional parent span ID for distributed tracing. /// Optional source metadata for the operation. - /// Optional hiring manager ID. /// Optional details about the non-agentic caller. /// Optional dictionary of extra attributes. /// An ExecuteToolData object containing all telemetry data. @@ -44,11 +43,10 @@ public static ExecuteToolData Build( string? spanId = null, string? parentSpanId = null, SourceMetadata? sourceMetadata = null, - string? hiringManagerId = null, CallerDetails? callerDetails = null, IDictionary? extraAttributes = null) { - var attributes = BuildAttributes(toolCallDetails, agentDetails, tenantDetails, conversationId, responseContent, sourceMetadata, hiringManagerId, callerDetails, extraAttributes); + var attributes = BuildAttributes(toolCallDetails, agentDetails, tenantDetails, conversationId, responseContent, sourceMetadata, callerDetails, extraAttributes); return new ExecuteToolData(attributes, startTime, endTime, spanId, parentSpanId); } @@ -60,7 +58,6 @@ public static ExecuteToolData Build( string conversationId, string? responseContent, SourceMetadata? sourceMetadata, - string? hiringManagerId, CallerDetails? callerDetails, IDictionary? extraAttributes = null) { @@ -80,14 +77,11 @@ public static ExecuteToolData Build( AddIfNotNull(attributes, OpenTelemetryConstants.GenAiConversationIdKey, conversationId); // Response content if supplied - AddIfNotNull(attributes, OpenTelemetryConstants.GenAiEventContent, responseContent); + AddIfNotNull(attributes, OpenTelemetryConstants.GenAiToolCallResultKey, responseContent); // Source metadata AddSourceMetadataAttributes(attributes, sourceMetadata); - // Add hiring manager ID - AddIfNotNull(attributes, OpenTelemetryConstants.HiringManagerIdKey, hiringManagerId); - // Add caller details AddCallerDetails(attributes, callerDetails); @@ -113,7 +107,7 @@ private static void AddToolDetails( AddIfNotNull(attributes, OpenTelemetryConstants.ServerAddressKey, endpoint.Host); if (endpoint.Port != 443) { - AddIfNotNull(attributes, OpenTelemetryConstants.ServerPortKey, endpoint.Port); + AddIfNotNull(attributes, OpenTelemetryConstants.ServerPortKey, endpoint.Port.ToString()); } } } diff --git a/src/Observability/Runtime/DTOs/Builders/InvokeAgentDataBuilder.cs b/src/Observability/Runtime/DTOs/Builders/InvokeAgentDataBuilder.cs index 7f974098..7ea5dc23 100644 --- a/src/Observability/Runtime/DTOs/Builders/InvokeAgentDataBuilder.cs +++ b/src/Observability/Runtime/DTOs/Builders/InvokeAgentDataBuilder.cs @@ -30,7 +30,6 @@ public class InvokeAgentDataBuilder : BaseDataBuilder /// Optional custom end time for the operation. /// Optional span ID for the operation. /// Optional parent span ID for distributed tracing. - /// Optional hiring manager ID. /// Optional dictionary of extra attributes. /// An InvokeAgentData object containing all telemetry data. public static InvokeAgentData Build( @@ -46,7 +45,6 @@ public static InvokeAgentData Build( DateTimeOffset? endTime = null, string? spanId = null, string? parentSpanId = null, - string? hiringManagerId = null, IDictionary? extraAttributes = null) { var attributes = BuildAttributes( @@ -58,7 +56,6 @@ public static InvokeAgentData Build( callerDetails, inputMessages, outputMessages, - hiringManagerId, extraAttributes); return new InvokeAgentData( @@ -80,7 +77,6 @@ public static InvokeAgentData Build( /// The details of the non-agentic caller. /// Optional input messages to include in the attributes. /// Optional output messages to include in the attributes. - /// Optional hiring manager ID. /// Optional dictionary of extra attributes. /// A dictionary of attribute key-value pairs. private static Dictionary BuildAttributes( @@ -92,7 +88,6 @@ public static InvokeAgentData Build( CallerDetails? callerDetails = null, string[]? inputMessages = null, string[]? outputMessages = null, - string? hiringManagerId = null, IDictionary? extraAttributes = null) { var attributes = new Dictionary(); @@ -130,9 +125,6 @@ public static InvokeAgentData Build( // Add output messages AddOutputMessagesAttributes(attributes, outputMessages); - // Add hiring manager ID - AddIfNotNull(attributes, OpenTelemetryConstants.HiringManagerIdKey, hiringManagerId); - // Add any extra attributes AddExtraAttributes(attributes, extraAttributes); diff --git a/src/Observability/Runtime/Tracing/Processors/ActivityProcessor.cs b/src/Observability/Runtime/Tracing/Processors/ActivityProcessor.cs index 2fc2c296..2d1a7829 100644 --- a/src/Observability/Runtime/Tracing/Processors/ActivityProcessor.cs +++ b/src/Observability/Runtime/Tracing/Processors/ActivityProcessor.cs @@ -3,7 +3,6 @@ namespace Microsoft.Agents.A365.Observability.Runtime.Tracing.Processors { using Microsoft.Agents.A365.Observability.Runtime.Common; - using Microsoft.Agents.A365.Observability.Runtime.Tracing.Contracts; using Microsoft.Agents.A365.Observability.Runtime.Tracing.Scopes; using OpenTelemetry; using System.Diagnostics; @@ -21,38 +20,31 @@ public sealed class ActivityProcessor : BaseProcessor OpenTelemetryConstants.GenAiAgentUPNKey, OpenTelemetryConstants.GenAiAgentBlueprintIdKey, OpenTelemetryConstants.GenAiAgentAUIDKey, - OpenTelemetryConstants.GenAiAgentTypeKey, OpenTelemetryConstants.GenAiAgentPlatformIdKey, OpenTelemetryConstants.TenantIdKey, OpenTelemetryConstants.GenAiConversationIdKey, OpenTelemetryConstants.GenAiConversationItemLinkKey, - OpenTelemetryConstants.CorrelationIdKey, - OpenTelemetryConstants.OperationSourceKey, OpenTelemetryConstants.GenAiInputMessagesKey, OpenTelemetryConstants.GenAiOutputMessagesKey, - OpenTelemetryConstants.GenAiEventContent, + OpenTelemetryConstants.GenAiToolCallResultKey, OpenTelemetryConstants.GenAiToolNameKey, OpenTelemetryConstants.GenAiToolCallIdKey, OpenTelemetryConstants.GenAiToolDescriptionKey, OpenTelemetryConstants.GenAiToolArgumentsKey, OpenTelemetryConstants.GenAiToolTypeKey, OpenTelemetryConstants.GenAiProviderNameKey, - OpenTelemetryConstants.GenAiSystemKey, OpenTelemetryConstants.SessionIdKey, OpenTelemetryConstants.SessionDescriptionKey, - OpenTelemetryConstants.GenAiChannelNameKey, - OpenTelemetryConstants.GenAiChannelLinkKey, - OpenTelemetryConstants.HiringManagerIdKey, + OpenTelemetryConstants.ChannelNameKey, + OpenTelemetryConstants.ChannelLinkKey, }; private static readonly string[] InvokeAgentAttributeKeys = new[] { - OpenTelemetryConstants.GenAiCallerIdKey, - OpenTelemetryConstants.GenAiCallerNameKey, - OpenTelemetryConstants.GenAiCallerUpnKey, - OpenTelemetryConstants.GenAiCallerClientIpKey, - OpenTelemetryConstants.GenAiCallerTenantIdKey, - OpenTelemetryConstants.GenAiExecutionTypeKey, + OpenTelemetryConstants.CallerIdKey, + OpenTelemetryConstants.CallerNameKey, + OpenTelemetryConstants.CallerUpnKey, + OpenTelemetryConstants.CallerClientIpKey, }; /// @@ -61,7 +53,9 @@ public sealed class ActivityProcessor : BaseProcessor /// The activity that is starting. public override void OnStart(Activity activity) { - activity.CoalesceTag(OpenTelemetryConstants.OperationSourceKey, Baggage.Current.GetBaggage(OpenTelemetryConstants.OperationSourceKey), OperationSource.SDK.ToString()); + // Set telemetry SDK attributes + activity.CoalesceTag(OpenTelemetryConstants.TelemetrySdkNameKey, OpenTelemetryConstants.TelemetrySdkNameValue); + activity.CoalesceTag(OpenTelemetryConstants.TelemetrySdkLanguageKey, OpenTelemetryConstants.TelemetrySdkLanguageValue); foreach (var key in AttributeKeys) { diff --git a/src/Observability/Runtime/Tracing/Scopes/ExecuteToolScope.cs b/src/Observability/Runtime/Tracing/Scopes/ExecuteToolScope.cs index 91f5bb0e..25855523 100644 --- a/src/Observability/Runtime/Tracing/Scopes/ExecuteToolScope.cs +++ b/src/Observability/Runtime/Tracing/Scopes/ExecuteToolScope.cs @@ -77,7 +77,7 @@ private ExecuteToolScope(ToolCallDetails details, AgentDetails agentDetails, Ten SetTagMaybe(OpenTelemetryConstants.ServerAddressKey, endpoint.Host); if (endpoint.Port != 443) { - SetTagMaybe(OpenTelemetryConstants.ServerPortKey, endpoint.Port); + SetTagMaybe(OpenTelemetryConstants.ServerPortKey, endpoint.Port.ToString()); } } } @@ -87,7 +87,7 @@ private ExecuteToolScope(ToolCallDetails details, AgentDetails agentDetails, Ten /// public void RecordResponse(string response) { - SetTagMaybe(OpenTelemetryConstants.GenAiEventContent, response); + SetTagMaybe(OpenTelemetryConstants.GenAiToolCallResultKey, response); } /// diff --git a/src/Observability/Runtime/Tracing/Scopes/InferenceScope.cs b/src/Observability/Runtime/Tracing/Scopes/InferenceScope.cs index eb440ac4..c05693fa 100644 --- a/src/Observability/Runtime/Tracing/Scopes/InferenceScope.cs +++ b/src/Observability/Runtime/Tracing/Scopes/InferenceScope.cs @@ -61,10 +61,9 @@ private InferenceScope(InferenceCallDetails details, AgentDetails agentDetails, SetTagMaybe(GenAiOperationNameKey, details.OperationName.ToString()); SetTagMaybe(GenAiRequestModelKey, details.Model); SetTagMaybe(GenAiProviderNameKey, details.ProviderName); - SetTagMaybe(GenAiUsageInputTokensKey, details.InputTokens?.ToString()); - SetTagMaybe(GenAiUsageOutputTokensKey, details.OutputTokens?.ToString()); - SetTagMaybe(GenAiResponseFinishReasonsKey, details.FinishReasons != null ? string.Join(",", details.FinishReasons) : null); - SetTagMaybe(GenAiResponseIdKey, details.ResponseId); + SetTagMaybe(GenAiUsageInputTokensKey, details.InputTokens); + SetTagMaybe(GenAiUsageOutputTokensKey, details.OutputTokens); + SetTagMaybe(GenAiResponseFinishReasonsKey, details.FinishReasons); } /// @@ -88,7 +87,7 @@ public void RecordOutputMessages(string[] messages) /// public void RecordInputTokens(int inputTokens) { - SetTagMaybe(GenAiUsageInputTokensKey, inputTokens.ToString()); + SetTagMaybe(GenAiUsageInputTokensKey, inputTokens); } /// @@ -96,18 +95,7 @@ public void RecordInputTokens(int inputTokens) /// public void RecordOutputTokens(int outputTokens) { - SetTagMaybe(GenAiUsageOutputTokensKey, outputTokens.ToString()); - } - - /// - /// Records the response id for telemetry tracking. - /// - public void RecordResponseId(string responseId) - { - if (!string.IsNullOrEmpty(responseId)) - { - SetTagMaybe(GenAiResponseIdKey, responseId); - } + SetTagMaybe(GenAiUsageOutputTokensKey, outputTokens); } /// @@ -117,7 +105,7 @@ public void RecordFinishReasons(string[] finishReasons) { if (finishReasons != null) { - SetTagMaybe(GenAiResponseFinishReasonsKey, string.Join(",", finishReasons)); + SetTagMaybe(GenAiResponseFinishReasonsKey, finishReasons); } } diff --git a/src/Observability/Runtime/Tracing/Scopes/InvokeAgentScope.cs b/src/Observability/Runtime/Tracing/Scopes/InvokeAgentScope.cs index bc7b7d10..84ae8855 100644 --- a/src/Observability/Runtime/Tracing/Scopes/InvokeAgentScope.cs +++ b/src/Observability/Runtime/Tracing/Scopes/InvokeAgentScope.cs @@ -76,27 +76,23 @@ private InvokeAgentScope(InvokeAgentDetails invokeAgentDetails, TenantDetails te SetTagMaybe(OpenTelemetryConstants.SessionIdKey, sessionId); SetTagMaybe(OpenTelemetryConstants.ServerAddressKey, endpoint?.Host); - SetTagMaybe(OpenTelemetryConstants.GenAiExecutionTypeKey, request?.ExecutionType.ToString()); SetTagMaybe(OpenTelemetryConstants.ThreatDiagnosticsSummaryKey, threatDiagnosticsSummary?.ToJson()); // Only record port if it is different from 443 - if (endpoint?.Port != 443) + if (endpoint != null && endpoint.Port != 443) { - SetTagMaybe(OpenTelemetryConstants.ServerPortKey, endpoint?.Port); + SetTagMaybe(OpenTelemetryConstants.ServerPortKey, endpoint.Port.ToString()); } // Set caller agent details tags if (callerAgentDetails != null) { - SetTagMaybe(OpenTelemetryConstants.GenAiCallerAgentNameKey, callerAgentDetails.AgentName); - SetTagMaybe(OpenTelemetryConstants.GenAiCallerAgentIdKey, callerAgentDetails.AgentId); - SetTagMaybe(OpenTelemetryConstants.GenAiCallerAgentApplicationIdKey, callerAgentDetails.AgentBlueprintId); - SetTagMaybe(OpenTelemetryConstants.GenAiCallerAgentAUIDKey, callerAgentDetails.AgentAUID); - SetTagMaybe(OpenTelemetryConstants.GenAiCallerAgentUPNKey, callerAgentDetails.AgentUPN); - SetTagMaybe(OpenTelemetryConstants.GenAiCallerAgentTenantKey, callerAgentDetails.TenantId); - SetTagMaybe(OpenTelemetryConstants.GenAiCallerAgentTypeKey, callerAgentDetails.AgentType?.ToString()); - SetTagMaybe(OpenTelemetryConstants.GenAiCallerAgentClientIpKey, callerAgentDetails.AgentClientIP?.ToString()); - SetTagMaybe(OpenTelemetryConstants.GenAiCallerAgentPlatformIdKey, callerAgentDetails.AgentPlatformId); + SetTagMaybe(OpenTelemetryConstants.CallerAgentNameKey, callerAgentDetails.AgentName); + SetTagMaybe(OpenTelemetryConstants.CallerAgentIdKey, callerAgentDetails.AgentId); + SetTagMaybe(OpenTelemetryConstants.CallerAgentBlueprintIdKey, callerAgentDetails.AgentBlueprintId); + SetTagMaybe(OpenTelemetryConstants.CallerAgentAUIDKey, callerAgentDetails.AgentAUID); + SetTagMaybe(OpenTelemetryConstants.CallerAgentUPNKey, callerAgentDetails.AgentUPN); + SetTagMaybe(OpenTelemetryConstants.CallerAgentPlatformIdKey, callerAgentDetails.AgentPlatformId); } // Set input messages diff --git a/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryConstants.cs b/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryConstants.cs index 87d26af4..c506b015 100644 --- a/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryConstants.cs +++ b/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryConstants.cs @@ -16,20 +16,16 @@ public static class OpenTelemetryConstants public const string ServerAddressKey = "server.address"; public const string ServerPortKey = "server.port"; - public const string SessionIdKey = "session.id"; - public const string SessionDescriptionKey = "session.description"; - public const string TenantIdKey = "tenant.id"; - public const string OperationSourceKey = "operation.source"; - public const string CorrelationIdKey = "correlation.id"; + public const string SessionIdKey = "microsoft.session.id"; + public const string SessionDescriptionKey = "microsoft.session.description"; + public const string TenantIdKey = "microsoft.tenant.id"; public const string GenAiClientOperationDurationMetricName = "gen_ai.client.operation.duration"; public const string GenAiRequestModelKey = "gen_ai.request.model"; - public const string GenAiResponseIdKey = "gen_ai.response.id"; public const string GenAiResponseFinishReasonsKey = "gen_ai.response.finish_reasons"; - public const string GenAiSystemKey = "gen_ai.system"; public const string GenAiConversationIdKey = "gen_ai.conversation.id"; - public const string GenAiConversationItemLinkKey = "gen_ai.conversation.itemLink"; + public const string GenAiConversationItemLinkKey = "microsoft.conversation.item.link"; public const string GenAiUsageInputTokensKey = "gen_ai.usage.input_tokens"; public const string GenAiUsageOutputTokensKey = "gen_ai.usage.output_tokens"; public const string GenAiProviderNameKey = "gen_ai.provider.name"; @@ -56,52 +52,48 @@ public enum OperationNames OutputMessages } - // AI invocation context dimensions - public const string GenAiExecutionTypeKey = "gen_ai.execution.type"; - - // AI channel metadata dimensions - public const string GenAiChannelNameKey = "gen_ai.channel.name"; - public const string GenAiChannelLinkKey = "gen_ai.channel.link"; + // Channel dimensions (renamed from gen_ai.channel.* to microsoft.channel.*) + public const string ChannelNameKey = "microsoft.channel.name"; + public const string ChannelLinkKey = "microsoft.channel.link"; // Target agent dimensions public const string GenAiAgentIdKey = "gen_ai.agent.id"; public const string GenAiAgentNameKey = "gen_ai.agent.name"; public const string GenAiAgentDescriptionKey = "gen_ai.agent.description"; - public const string GenAiAgentAUIDKey = "gen_ai.agent.userid"; - public const string GenAiAgentUPNKey = "gen_ai.agent.upn"; - public const string GenAiAgentBlueprintIdKey = "gen_ai.agent.applicationid"; - public const string GenAiAgentTypeKey = "gen_ai.agent.type"; - public const string GenAiAgentPlatformIdKey = "gen_ai.agent.platformid"; - - // Caller dimensions - public const string GenAiCallerIdKey = "gen_ai.caller.id"; - public const string GenAiCallerUpnKey = "gen_ai.caller.upn"; - public const string GenAiCallerNameKey = "gen_ai.caller.name"; - public const string GenAiCallerClientIpKey = "gen_ai.caller.client.ip"; - public const string GenAiCallerTenantIdKey = "gen_ai.caller.tenantid"; - public const string HiringManagerIdKey = "hiring.manager.id"; - - // Caller agent dimensions - public const string GenAiCallerAgentNameKey = "gen_ai.caller.agent.name"; - public const string GenAiCallerAgentIdKey = "gen_ai.caller.agent.id"; - public const string GenAiCallerAgentApplicationIdKey = "gen_ai.caller.agent.applicationid"; - public const string GenAiCallerAgentAUIDKey = "gen_ai.caller.agent.userid"; - public const string GenAiCallerAgentUPNKey = "gen_ai.caller.agent.upn"; - public const string GenAiCallerAgentTenantKey = "gen_ai.caller.agent.tenantid"; - public const string GenAiCallerAgentTypeKey = "gen_ai.caller.agent.type"; - public const string GenAiCallerAgentClientIpKey = "gen_ai.caller.agent.user.client.ip"; - public const string GenAiCallerAgentPlatformIdKey = "gen_ai.caller.agent.platformid"; + public const string GenAiAgentAUIDKey = "microsoft.agent.user.id"; + public const string GenAiAgentUPNKey = "microsoft.agent.user.upn"; + public const string GenAiAgentBlueprintIdKey = "microsoft.a365.agent.blueprint.id"; + public const string GenAiAgentPlatformIdKey = "microsoft.a365.agent.platform.id"; + + // Caller dimensions (renamed from gen_ai.caller.* to microsoft.caller.*) + public const string CallerIdKey = "microsoft.caller.id"; + public const string CallerUpnKey = "microsoft.caller.upn"; + public const string CallerNameKey = "microsoft.caller.name"; + public const string CallerClientIpKey = "client.address"; + + // Caller agent dimensions (renamed from gen_ai.caller.agent.* to microsoft.a365.caller.agent.*) + public const string CallerAgentNameKey = "microsoft.a365.caller.agent.name"; + public const string CallerAgentIdKey = "microsoft.a365.caller.agent.id"; + public const string CallerAgentBlueprintIdKey = "microsoft.a365.caller.agent.blueprint.id"; + public const string CallerAgentAUIDKey = "microsoft.a365.caller.agent.user.id"; + public const string CallerAgentUPNKey = "microsoft.a365.caller.agent.user.upn"; + public const string CallerAgentPlatformIdKey = "microsoft.a365.caller.agent.platform.id"; + + // Service attributes + public const string ServiceNameKey = "service.name"; + + // Telemetry SDK attributes + public const string TelemetrySdkNameKey = "telemetry.sdk.name"; + public const string TelemetrySdkLanguageKey = "telemetry.sdk.language"; + public const string TelemetrySdkVersionKey = "telemetry.sdk.version"; + public const string TelemetrySdkNameValue = "A365ObservabilitySDK"; + public const string TelemetrySdkLanguageValue = "dotnet"; #region Public Constants /// /// The GenAI operation name key. /// public const string GenAiOperationNameKey = "gen_ai.operation.name"; - - /// - /// The GenAI event content key. - /// - public const string GenAiEventContent = "gen_ai.event.content"; /// /// The error message key. @@ -143,6 +135,11 @@ public enum OperationNames /// The GenAI tool server name key. /// public const string GenAiToolServerNameKey = "gen_ai.tool.server.name"; + + /// + /// The GenAI tool call result key. + /// + public const string GenAiToolCallResultKey = "gen_ai.tool.call.result"; #endregion /// @@ -153,7 +150,7 @@ public enum OperationNames /// /// The GenAI agent thought process key. /// - public const string GenAiAgentThoughtProcessKey = "gen_ai.agent.thought.process"; + public const string GenAiAgentThoughtProcessKey = "microsoft.a365.agent.thought.process"; #endregion } diff --git a/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryScope.cs b/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryScope.cs index c3db1c04..1da08ae4 100644 --- a/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryScope.cs +++ b/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryScope.cs @@ -81,7 +81,6 @@ protected OpenTelemetryScope(ActivityKind kind, AgentDetails agentDetails, Tenan SetTagMaybe(GenAiAgentAUIDKey, agentDetails.AgentAUID); SetTagMaybe(GenAiAgentUPNKey, agentDetails.AgentUPN); SetTagMaybe(GenAiAgentBlueprintIdKey, agentDetails.AgentBlueprintId); - SetTagMaybe(GenAiAgentTypeKey, agentDetails.AgentType?.ToString()); SetTagMaybe(GenAiAgentPlatformIdKey, agentDetails.AgentPlatformId); } @@ -103,17 +102,16 @@ protected OpenTelemetryScope(ActivityKind kind, AgentDetails agentDetails, Tenan if (sourceMetadata != null) { - SetTagMaybe(OpenTelemetryConstants.GenAiChannelNameKey, sourceMetadata.Name); - SetTagMaybe(OpenTelemetryConstants.GenAiChannelLinkKey, sourceMetadata.Description); + SetTagMaybe(OpenTelemetryConstants.ChannelNameKey, sourceMetadata.Name); + SetTagMaybe(OpenTelemetryConstants.ChannelLinkKey, sourceMetadata.Description); } if (callerDetails != null) { - SetTagMaybe(OpenTelemetryConstants.GenAiCallerIdKey, callerDetails.CallerId); - SetTagMaybe(OpenTelemetryConstants.GenAiCallerUpnKey, callerDetails.CallerUpn); - SetTagMaybe(OpenTelemetryConstants.GenAiCallerNameKey, callerDetails.CallerName); - SetTagMaybe(OpenTelemetryConstants.GenAiCallerClientIpKey, callerDetails.CallerClientIP?.ToString()); - SetTagMaybe(OpenTelemetryConstants.GenAiCallerTenantIdKey, callerDetails.TenantId); + SetTagMaybe(OpenTelemetryConstants.CallerIdKey, callerDetails.CallerId); + SetTagMaybe(OpenTelemetryConstants.CallerUpnKey, callerDetails.CallerUpn); + SetTagMaybe(OpenTelemetryConstants.CallerNameKey, callerDetails.CallerName); + SetTagMaybe(OpenTelemetryConstants.CallerClientIpKey, callerDetails.CallerClientIP?.ToString()); } activity?.Start(); 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 b9e7cdc8..44b8dc70 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterAsyncE2ETests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterAsyncE2ETests.cs @@ -85,25 +85,22 @@ public async Task AddTracing_And_InvokeAgentScope_ExporterMakesExpectedRequest() .GetProperty("spans")[0] .GetProperty("attributes"); this.GetAttribute(attributes, "server.address").Should().Be(invokeAgentDetails.Endpoint?.Host); - this.GetAttribute(attributes, "gen_ai.channel.name").Should().Be(expectedRequest.SourceMetadata?.Name); - this.GetAttribute(attributes, "gen_ai.channel.link").Should().Be(expectedRequest.SourceMetadata?.Description); - this.GetAttribute(attributes, "gen_ai.execution.type").Should().Be(expectedRequest.ExecutionType.ToString()); - this.GetAttribute(attributes, "tenant.id").Should().Be(tenantDetails.TenantId.ToString()); - this.GetAttribute(attributes, "gen_ai.caller.id").Should().Be(expectedCallerDetails.CallerId); - this.GetAttribute(attributes, "gen_ai.caller.upn").Should().Be(expectedCallerDetails.CallerUpn); - this.GetAttribute(attributes, "gen_ai.caller.name").Should().Be(expectedCallerDetails.CallerName); - this.GetAttribute(attributes, "gen_ai.caller.tenantid").Should().Be(expectedCallerDetails.TenantId); + this.GetAttribute(attributes, "microsoft.channel.name").Should().Be(expectedRequest.SourceMetadata?.Name); + this.GetAttribute(attributes, "microsoft.channel.link").Should().Be(expectedRequest.SourceMetadata?.Description); + this.GetAttribute(attributes, "microsoft.tenant.id").Should().Be(tenantDetails.TenantId.ToString()); + this.GetAttribute(attributes, "microsoft.caller.id").Should().Be(expectedCallerDetails.CallerId); + this.GetAttribute(attributes, "microsoft.caller.upn").Should().Be(expectedCallerDetails.CallerUpn); + this.GetAttribute(attributes, "microsoft.caller.name").Should().Be(expectedCallerDetails.CallerName); this.GetAttribute(attributes, "gen_ai.input.messages").Should().Be("Input message 1,Input message 2"); this.GetAttribute(attributes, "gen_ai.output.messages").Should().Be("Output message 1"); this.GetAttribute(attributes, "gen_ai.agent.id").Should().Be(expectedAgentDetails.AgentId); this.GetAttribute(attributes, "gen_ai.agent.name").Should().Be(expectedAgentDetails.AgentName); this.GetAttribute(attributes, "gen_ai.agent.description").Should().Be(expectedAgentDetails.AgentDescription); - this.GetAttribute(attributes, "gen_ai.agent.userid").Should().Be(expectedAgentDetails.AgentAUID); - this.GetAttribute(attributes, "gen_ai.agent.upn").Should().Be(expectedAgentDetails.AgentUPN); - this.GetAttribute(attributes, "gen_ai.agent.applicationid").Should().Be(expectedAgentDetails.AgentBlueprintId); - this.GetAttribute(attributes, "tenant.id").Should().Be(tenantDetails.TenantId.ToString()); + this.GetAttribute(attributes, "microsoft.agent.user.id").Should().Be(expectedAgentDetails.AgentAUID); + this.GetAttribute(attributes, "microsoft.agent.user.upn").Should().Be(expectedAgentDetails.AgentUPN); + this.GetAttribute(attributes, "microsoft.a365.agent.blueprint.id").Should().Be(expectedAgentDetails.AgentBlueprintId); + this.GetAttribute(attributes, "microsoft.tenant.id").Should().Be(tenantDetails.TenantId.ToString()); this.GetAttribute(attributes, "gen_ai.operation.name").Should().Be("invoke_agent"); - this.GetAttribute(attributes, "gen_ai.agent.type").Should().Be(expectedAgentType.ToString()); } [TestMethod] @@ -162,10 +159,10 @@ public async Task AddTracing_And_ExecuteToolScope_ExporterMakesExpectedRequest() this.GetAttribute(attributes, "gen_ai.agent.id").Should().Be(expectedAgentDetails.AgentId); this.GetAttribute(attributes, "gen_ai.agent.name").Should().Be(expectedAgentDetails.AgentName); this.GetAttribute(attributes, "gen_ai.agent.description").Should().Be(expectedAgentDetails.AgentDescription); - this.GetAttribute(attributes, "gen_ai.agent.userid").Should().Be(expectedAgentDetails.AgentAUID); - this.GetAttribute(attributes, "gen_ai.agent.upn").Should().Be(expectedAgentDetails.AgentUPN); - this.GetAttribute(attributes, "gen_ai.agent.applicationid").Should().Be(expectedAgentDetails.AgentBlueprintId); - this.GetAttribute(attributes, "tenant.id").Should().Be(tenantDetails.TenantId.ToString()); + this.GetAttribute(attributes, "microsoft.agent.user.id").Should().Be(expectedAgentDetails.AgentAUID); + this.GetAttribute(attributes, "microsoft.agent.user.upn").Should().Be(expectedAgentDetails.AgentUPN); + this.GetAttribute(attributes, "microsoft.a365.agent.blueprint.id").Should().Be(expectedAgentDetails.AgentBlueprintId); + this.GetAttribute(attributes, "microsoft.tenant.id").Should().Be(tenantDetails.TenantId.ToString()); 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.id").Should().Be(toolCallDetails.ToolCallId); @@ -173,8 +170,7 @@ public async Task AddTracing_And_ExecuteToolScope_ExporterMakesExpectedRequest() this.GetAttribute(attributes, "gen_ai.tool.type").Should().Be(toolCallDetails.ToolType); this.GetAttribute(attributes, "server.address").Should().Be(endpoint.Host); this.GetAttribute(attributes, "server.port").Should().Be(endpoint.Port.ToString()); - this.GetAttribute(attributes, "gen_ai.event.content").Should().Be("Tool response content"); - this.GetAttribute(attributes, "gen_ai.agent.type").Should().Be(expectedAgentType.ToString()); + this.GetAttribute(attributes, "gen_ai.tool.call.result").Should().Be("Tool response content"); } [TestMethod] @@ -237,10 +233,10 @@ public async Task AddTracing_And_InferenceScope_ExporterMakesExpectedRequest() this.GetAttribute(attributes, "gen_ai.agent.id").Should().Be(expectedAgentDetails.AgentId); this.GetAttribute(attributes, "gen_ai.agent.name").Should().Be(expectedAgentDetails.AgentName); this.GetAttribute(attributes, "gen_ai.agent.description").Should().Be(expectedAgentDetails.AgentDescription); - this.GetAttribute(attributes, "gen_ai.agent.userid").Should().Be(expectedAgentDetails.AgentAUID); - this.GetAttribute(attributes, "gen_ai.agent.upn").Should().Be(expectedAgentDetails.AgentUPN); - this.GetAttribute(attributes, "gen_ai.agent.applicationid").Should().Be(expectedAgentDetails.AgentBlueprintId); - this.GetAttribute(attributes, "tenant.id").Should().Be(tenantDetails.TenantId.ToString()); + this.GetAttribute(attributes, "microsoft.agent.user.id").Should().Be(expectedAgentDetails.AgentAUID); + this.GetAttribute(attributes, "microsoft.agent.user.upn").Should().Be(expectedAgentDetails.AgentUPN); + this.GetAttribute(attributes, "microsoft.a365.agent.blueprint.id").Should().Be(expectedAgentDetails.AgentBlueprintId); + this.GetAttribute(attributes, "microsoft.tenant.id").Should().Be(tenantDetails.TenantId.ToString()); this.GetAttribute(attributes, "gen_ai.request.model").Should().Be(inferenceDetails.Model); this.GetAttribute(attributes, "gen_ai.provider.name").Should().Be(inferenceDetails.ProviderName); this.GetAttribute(attributes, "gen_ai.usage.input_tokens").Should().Be("42"); @@ -248,7 +244,6 @@ public async Task AddTracing_And_InferenceScope_ExporterMakesExpectedRequest() this.GetAttribute(attributes, "gen_ai.response.finish_reasons").Should().Be("stop,length"); this.GetAttribute(attributes, "gen_ai.input.messages").Should().Be("Hello,World"); this.GetAttribute(attributes, "gen_ai.output.messages").Should().Be("Hi there!"); - this.GetAttribute(attributes, "gen_ai.agent.type").Should().Be(expectedAgentType.ToString()); } [TestMethod] @@ -329,7 +324,6 @@ public async Task AddTracing_NestedScopes_AllExporterRequestsReceived() // Assert var allOperationNames = new List(); - var allAgentTypes = new List(); foreach (var content in receivedContents) { using var doc = JsonDocument.Parse(content); @@ -345,14 +339,9 @@ public async Task AddTracing_NestedScopes_AllExporterRequestsReceived() var opName = this.GetAttribute(span.GetProperty("attributes"), "gen_ai.operation.name"); if (opName != null) allOperationNames.Add(opName); - - var agentTypeTag = this.GetAttribute(span.GetProperty("attributes"), "gen_ai.agent.type"); - if (agentTypeTag != null) - allAgentTypes.Add(agentTypeTag); } } allOperationNames.Should().Contain(new[] { "invoke_agent", "execute_tool", InferenceOperationType.Chat.ToString() }, "All three nested scopes should be exported, even if batched in fewer requests."); - allAgentTypes.Should().OnlyContain(t => t == agentType.ToString()); } private class TestHttpMessageHandler : HttpMessageHandler 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 9f986608..e2d55314 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterE2ETests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterE2ETests.cs @@ -91,26 +91,23 @@ public async Task AddTracing_And_InvokeAgentScope_ExporterMakesExpectedRequest() .GetProperty("spans")[0] .GetProperty("attributes"); this.GetAttribute(attributes, "server.address").Should().Be(invokeAgentDetails.Endpoint?.Host); - this.GetAttribute(attributes, "gen_ai.channel.name").Should().Be(expectedRequest.SourceMetadata?.Name); - this.GetAttribute(attributes, "gen_ai.channel.link").Should().Be(expectedRequest.SourceMetadata?.Description); - this.GetAttribute(attributes, "gen_ai.execution.type").Should().Be(expectedRequest.ExecutionType.ToString()); - this.GetAttribute(attributes, "tenant.id").Should().Be(tenantDetails.TenantId.ToString()); - this.GetAttribute(attributes, "gen_ai.caller.id").Should().Be(expectedCallerDetails.CallerId); - this.GetAttribute(attributes, "gen_ai.caller.upn").Should().Be(expectedCallerDetails.CallerUpn); - this.GetAttribute(attributes, "gen_ai.caller.name").Should().Be(expectedCallerDetails.CallerName); - this.GetAttribute(attributes, "gen_ai.caller.client.ip").Should().Be(expectedCallerDetails.CallerClientIP?.ToString()); - this.GetAttribute(attributes, "gen_ai.caller.tenantid").Should().Be(expectedCallerDetails.TenantId); + this.GetAttribute(attributes, "microsoft.channel.name").Should().Be(expectedRequest.SourceMetadata?.Name); + this.GetAttribute(attributes, "microsoft.channel.link").Should().Be(expectedRequest.SourceMetadata?.Description); + this.GetAttribute(attributes, "microsoft.tenant.id").Should().Be(tenantDetails.TenantId.ToString()); + this.GetAttribute(attributes, "microsoft.caller.id").Should().Be(expectedCallerDetails.CallerId); + this.GetAttribute(attributes, "microsoft.caller.upn").Should().Be(expectedCallerDetails.CallerUpn); + this.GetAttribute(attributes, "microsoft.caller.name").Should().Be(expectedCallerDetails.CallerName); + this.GetAttribute(attributes, "client.address").Should().Be(expectedCallerDetails.CallerClientIP?.ToString()); this.GetAttribute(attributes, "gen_ai.input.messages").Should().Be("Input message 1,Input message 2"); this.GetAttribute(attributes, "gen_ai.output.messages").Should().Be("Output message 1"); this.GetAttribute(attributes, "gen_ai.agent.id").Should().Be(expectedAgentDetails.AgentId); this.GetAttribute(attributes, "gen_ai.agent.name").Should().Be(expectedAgentDetails.AgentName); this.GetAttribute(attributes, "gen_ai.agent.description").Should().Be(expectedAgentDetails.AgentDescription); - this.GetAttribute(attributes, "gen_ai.agent.userid").Should().Be(expectedAgentDetails.AgentAUID); - this.GetAttribute(attributes, "gen_ai.agent.upn").Should().Be(expectedAgentDetails.AgentUPN); - this.GetAttribute(attributes, "gen_ai.agent.applicationid").Should().Be(expectedAgentDetails.AgentBlueprintId); - this.GetAttribute(attributes, "tenant.id").Should().Be(tenantDetails.TenantId.ToString()); + this.GetAttribute(attributes, "microsoft.agent.user.id").Should().Be(expectedAgentDetails.AgentAUID); + this.GetAttribute(attributes, "microsoft.agent.user.upn").Should().Be(expectedAgentDetails.AgentUPN); + this.GetAttribute(attributes, "microsoft.a365.agent.blueprint.id").Should().Be(expectedAgentDetails.AgentBlueprintId); + this.GetAttribute(attributes, "microsoft.tenant.id").Should().Be(tenantDetails.TenantId.ToString()); this.GetAttribute(attributes, "gen_ai.operation.name").Should().Be("invoke_agent"); - this.GetAttribute(attributes, "gen_ai.agent.type").Should().Be(expectedAgentType.ToString()); var threatSummaryJson = this.GetAttribute(attributes, "threat.diagnostics.summary"); threatSummaryJson.Should().Contain("\"blockAction\":true"); threatSummaryJson.Should().Contain("\"reasonCode\":112"); @@ -189,10 +186,10 @@ public async Task AddTracing_And_ExecuteToolScope_ExporterMakesExpectedRequest() this.GetAttribute(attributes, "gen_ai.agent.id").Should().Be(expectedAgentDetails.AgentId); this.GetAttribute(attributes, "gen_ai.agent.name").Should().Be(expectedAgentDetails.AgentName); this.GetAttribute(attributes, "gen_ai.agent.description").Should().Be(expectedAgentDetails.AgentDescription); - this.GetAttribute(attributes, "gen_ai.agent.userid").Should().Be(expectedAgentDetails.AgentAUID); - this.GetAttribute(attributes, "gen_ai.agent.upn").Should().Be(expectedAgentDetails.AgentUPN); - this.GetAttribute(attributes, "gen_ai.agent.applicationid").Should().Be(expectedAgentDetails.AgentBlueprintId); - this.GetAttribute(attributes, "tenant.id").Should().Be(tenantDetails.TenantId.ToString()); + this.GetAttribute(attributes, "microsoft.agent.user.id").Should().Be(expectedAgentDetails.AgentAUID); + this.GetAttribute(attributes, "microsoft.agent.user.upn").Should().Be(expectedAgentDetails.AgentUPN); + this.GetAttribute(attributes, "microsoft.a365.agent.blueprint.id").Should().Be(expectedAgentDetails.AgentBlueprintId); + this.GetAttribute(attributes, "microsoft.tenant.id").Should().Be(tenantDetails.TenantId.ToString()); 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.id").Should().Be(toolCallDetails.ToolCallId); @@ -201,13 +198,11 @@ public async Task AddTracing_And_ExecuteToolScope_ExporterMakesExpectedRequest() this.GetAttribute(attributes, "gen_ai.tool.server.name").Should().Be(toolCallDetails.ToolServerName); this.GetAttribute(attributes, "server.address").Should().Be(endpoint.Host); this.GetAttribute(attributes, "server.port").Should().Be(endpoint.Port.ToString()); - this.GetAttribute(attributes, "gen_ai.event.content").Should().Be("Tool response content"); - this.GetAttribute(attributes, "gen_ai.agent.type").Should().Be(expectedAgentType.ToString()); - this.GetAttribute(attributes, "gen_ai.caller.id").Should().Be(expectedToolCallerDetails.CallerId); - this.GetAttribute(attributes, "gen_ai.caller.upn").Should().Be(expectedToolCallerDetails.CallerUpn); - this.GetAttribute(attributes, "gen_ai.caller.name").Should().Be(expectedToolCallerDetails.CallerName); - this.GetAttribute(attributes, "gen_ai.caller.client.ip").Should().Be(expectedToolCallerDetails.CallerClientIP?.ToString()); - this.GetAttribute(attributes, "gen_ai.caller.tenantid").Should().Be(expectedToolCallerDetails.TenantId); + this.GetAttribute(attributes, "gen_ai.tool.call.result").Should().Be("Tool response content"); + this.GetAttribute(attributes, "microsoft.caller.id").Should().Be(expectedToolCallerDetails.CallerId); + this.GetAttribute(attributes, "microsoft.caller.upn").Should().Be(expectedToolCallerDetails.CallerUpn); + this.GetAttribute(attributes, "microsoft.caller.name").Should().Be(expectedToolCallerDetails.CallerName); + this.GetAttribute(attributes, "client.address").Should().Be(expectedToolCallerDetails.CallerClientIP?.ToString()); var toolThreatSummaryJson = this.GetAttribute(attributes, "threat.diagnostics.summary"); toolThreatSummaryJson.Should().Contain("\"blockAction\":false"); toolThreatSummaryJson.Should().Contain("\"reasonCode\":200"); @@ -282,10 +277,10 @@ public async Task AddTracing_And_InferenceScope_ExporterMakesExpectedRequest() this.GetAttribute(attributes, "gen_ai.agent.id").Should().Be(expectedAgentDetails.AgentId); this.GetAttribute(attributes, "gen_ai.agent.name").Should().Be(expectedAgentDetails.AgentName); this.GetAttribute(attributes, "gen_ai.agent.description").Should().Be(expectedAgentDetails.AgentDescription); - this.GetAttribute(attributes, "gen_ai.agent.userid").Should().Be(expectedAgentDetails.AgentAUID); - this.GetAttribute(attributes, "gen_ai.agent.upn").Should().Be(expectedAgentDetails.AgentUPN); - this.GetAttribute(attributes, "gen_ai.agent.applicationid").Should().Be(expectedAgentDetails.AgentBlueprintId); - this.GetAttribute(attributes, "tenant.id").Should().Be(tenantDetails.TenantId.ToString()); + this.GetAttribute(attributes, "microsoft.agent.user.id").Should().Be(expectedAgentDetails.AgentAUID); + this.GetAttribute(attributes, "microsoft.agent.user.upn").Should().Be(expectedAgentDetails.AgentUPN); + this.GetAttribute(attributes, "microsoft.a365.agent.blueprint.id").Should().Be(expectedAgentDetails.AgentBlueprintId); + this.GetAttribute(attributes, "microsoft.tenant.id").Should().Be(tenantDetails.TenantId.ToString()); this.GetAttribute(attributes, "gen_ai.request.model").Should().Be(inferenceDetails.Model); this.GetAttribute(attributes, "gen_ai.provider.name").Should().Be(inferenceDetails.ProviderName); this.GetAttribute(attributes, "gen_ai.usage.input_tokens").Should().Be("42"); @@ -293,12 +288,10 @@ public async Task AddTracing_And_InferenceScope_ExporterMakesExpectedRequest() this.GetAttribute(attributes, "gen_ai.response.finish_reasons").Should().Be("stop,length"); this.GetAttribute(attributes, "gen_ai.input.messages").Should().Be("Hello,World"); this.GetAttribute(attributes, "gen_ai.output.messages").Should().Be("Hi there!"); - this.GetAttribute(attributes, "gen_ai.agent.type").Should().Be(expectedAgentType.ToString()); - this.GetAttribute(attributes, "gen_ai.caller.id").Should().Be(expectedInferenceCallerDetails.CallerId); - this.GetAttribute(attributes, "gen_ai.caller.upn").Should().Be(expectedInferenceCallerDetails.CallerUpn); - this.GetAttribute(attributes, "gen_ai.caller.name").Should().Be(expectedInferenceCallerDetails.CallerName); - this.GetAttribute(attributes, "gen_ai.caller.client.ip").Should().Be(expectedInferenceCallerDetails.CallerClientIP?.ToString()); - this.GetAttribute(attributes, "gen_ai.caller.tenantid").Should().Be(expectedInferenceCallerDetails.TenantId); + this.GetAttribute(attributes, "microsoft.caller.id").Should().Be(expectedInferenceCallerDetails.CallerId); + this.GetAttribute(attributes, "microsoft.caller.upn").Should().Be(expectedInferenceCallerDetails.CallerUpn); + this.GetAttribute(attributes, "microsoft.caller.name").Should().Be(expectedInferenceCallerDetails.CallerName); + this.GetAttribute(attributes, "client.address").Should().Be(expectedInferenceCallerDetails.CallerClientIP?.ToString()); } [TestMethod] @@ -402,7 +395,6 @@ private async Task RunNestedScopes_AllExporterRequestsReceived(bool useAgentId) // Assert var allOperationNames = new List(); - var allAgentTypes = new List(); foreach (var content in receivedContents) { using var doc = JsonDocument.Parse(content); @@ -418,14 +410,9 @@ private async Task RunNestedScopes_AllExporterRequestsReceived(bool useAgentId) var opName = this.GetAttribute(span.GetProperty("attributes"), "gen_ai.operation.name"); if (opName != null) allOperationNames.Add(opName); - - var agentTypeTag = this.GetAttribute(span.GetProperty("attributes"), "gen_ai.agent.type"); - if (agentTypeTag != null) - allAgentTypes.Add(agentTypeTag); } } allOperationNames.Should().Contain(new[] { "invoke_agent", "execute_tool", InferenceOperationType.Chat.ToString() }, "All three nested scopes should be exported, even if batched in fewer requests."); - allAgentTypes.Should().OnlyContain(t => t == agentType.ToString()); } [TestMethod] From 2c09507b02c69463d5a5c06233e372599035c562 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 15:48:47 +0000 Subject: [PATCH 4/4] Update telemetry constants to new schema from nodejs PR #207 Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com> --- .../Builders/ExecuteInferenceDataBuilder.cs | 6 +- .../Runtime/Tracing/Scopes/InferenceScope.cs | 12 +-- .../Common/ExportFormatterTests.cs | 8 +- .../ExecuteInferenceDataBuilderTests.cs | 4 +- .../Builders/ExecuteToolDataBuilderTests.cs | 4 +- .../DTOs/Builders/OutputDataBuilderTests.cs | 2 +- .../Etw/EtwLoggingBuilderTests.cs | 36 ++++---- .../Etw/EtwTracingBuilderTests.cs | 4 +- .../Middleware/BaggageBuilderTests.cs | 37 ++------- .../Tracing/Scopes/ExecuteToolScopeTest.cs | 38 ++------- .../Tracing/Scopes/InferenceScopeTest.cs | 57 ++----------- .../Tracing/Scopes/InvokeAgentScopeTest.cs | 83 +------------------ .../Tracing/Scopes/OutputScopeTest.cs | 14 ++-- 13 files changed, 62 insertions(+), 243 deletions(-) diff --git a/src/Observability/Runtime/DTOs/Builders/ExecuteInferenceDataBuilder.cs b/src/Observability/Runtime/DTOs/Builders/ExecuteInferenceDataBuilder.cs index 09508d74..125a990c 100644 --- a/src/Observability/Runtime/DTOs/Builders/ExecuteInferenceDataBuilder.cs +++ b/src/Observability/Runtime/DTOs/Builders/ExecuteInferenceDataBuilder.cs @@ -113,9 +113,9 @@ private static void AddInferenceCallDetails( AddIfNotNull(attributes, GenAiOperationNameKey, operationName.ToString().ToLowerInvariant()); AddIfNotNull(attributes, GenAiRequestModelKey, model); AddIfNotNull(attributes, GenAiProviderNameKey, providerName); - AddIfNotNull(attributes, GenAiUsageInputTokensKey, inputTokens); - AddIfNotNull(attributes, GenAiUsageOutputTokensKey, outputTokens); - AddIfNotNull(attributes, GenAiResponseFinishReasonsKey, finishReasons); + AddIfNotNull(attributes, GenAiUsageInputTokensKey, inputTokens?.ToString()); + AddIfNotNull(attributes, GenAiUsageOutputTokensKey, outputTokens?.ToString()); + AddIfNotNull(attributes, GenAiResponseFinishReasonsKey, finishReasons != null ? string.Join(",", finishReasons) : null); } } } diff --git a/src/Observability/Runtime/Tracing/Scopes/InferenceScope.cs b/src/Observability/Runtime/Tracing/Scopes/InferenceScope.cs index c05693fa..36173d22 100644 --- a/src/Observability/Runtime/Tracing/Scopes/InferenceScope.cs +++ b/src/Observability/Runtime/Tracing/Scopes/InferenceScope.cs @@ -61,9 +61,9 @@ private InferenceScope(InferenceCallDetails details, AgentDetails agentDetails, SetTagMaybe(GenAiOperationNameKey, details.OperationName.ToString()); SetTagMaybe(GenAiRequestModelKey, details.Model); SetTagMaybe(GenAiProviderNameKey, details.ProviderName); - SetTagMaybe(GenAiUsageInputTokensKey, details.InputTokens); - SetTagMaybe(GenAiUsageOutputTokensKey, details.OutputTokens); - SetTagMaybe(GenAiResponseFinishReasonsKey, details.FinishReasons); + SetTagMaybe(GenAiUsageInputTokensKey, details.InputTokens?.ToString()); + SetTagMaybe(GenAiUsageOutputTokensKey, details.OutputTokens?.ToString()); + SetTagMaybe(GenAiResponseFinishReasonsKey, details.FinishReasons != null ? string.Join(",", details.FinishReasons) : null); } /// @@ -87,7 +87,7 @@ public void RecordOutputMessages(string[] messages) /// public void RecordInputTokens(int inputTokens) { - SetTagMaybe(GenAiUsageInputTokensKey, inputTokens); + SetTagMaybe(GenAiUsageInputTokensKey, inputTokens.ToString()); } /// @@ -95,7 +95,7 @@ public void RecordInputTokens(int inputTokens) /// public void RecordOutputTokens(int outputTokens) { - SetTagMaybe(GenAiUsageOutputTokensKey, outputTokens); + SetTagMaybe(GenAiUsageOutputTokensKey, outputTokens.ToString()); } /// @@ -105,7 +105,7 @@ public void RecordFinishReasons(string[] finishReasons) { if (finishReasons != null) { - SetTagMaybe(GenAiResponseFinishReasonsKey, finishReasons); + SetTagMaybe(GenAiResponseFinishReasonsKey, string.Join(",", finishReasons)); } } 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 8279cd7e..945a56a9 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 @@ -566,7 +566,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.event.content", new string('d', 100 * 1024)); + activity.SetTag("gen_ai.tool.call.result", new string('d', 100 * 1024)); var resource = ResourceBuilder.CreateEmpty().Build(); var logs = new List(); var formatter = new ExportFormatter(new ListLogger(logs)); @@ -583,7 +583,7 @@ public void FormatMany_TruncatesMultipleKeys_LargestFirst() 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 = ")); - logs.Should().Contain(l => l.Contains("Key 'gen_ai.event.content' size = ")); + logs.Should().Contain(l => l.Contains("Key 'gen_ai.tool.call.result' size = ")); } [TestMethod] @@ -592,7 +592,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.event.content", new string('y', 125 * 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)); activity.SetTag("gen_ai.agent.invocation_output", new string('z', 0)); @@ -606,7 +606,7 @@ public void FormatMany_LogsAllKeySizes() // Assert logs.Should().Contain(l => l.Contains("Key 'gen_ai.tool.arguments' size = 100")); - logs.Should().Contain(l => l.Contains("Key 'gen_ai.event.content' size = 125")); + 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")); logs.Should().Contain(l => l.Contains("Key 'gen_ai.agent.invocation_output' size = 0")); diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/ExecuteInferenceDataBuilderTests.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/ExecuteInferenceDataBuilderTests.cs index 18d9d333..699313ed 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/ExecuteInferenceDataBuilderTests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/ExecuteInferenceDataBuilderTests.cs @@ -58,8 +58,8 @@ public void Build_WithTokensAndFinishReasons_IncludesUsageAndReasons() var data = ExecuteInferenceDataBuilder.Build(details, agent, tenant, conversationId); // Assert - data.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiUsageInputTokensKey).WhoseValue.Should().Be(10); - data.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiUsageOutputTokensKey).WhoseValue.Should().Be(20); + data.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiUsageInputTokensKey).WhoseValue.Should().Be("10"); + data.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiUsageOutputTokensKey).WhoseValue.Should().Be("20"); data.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiResponseFinishReasonsKey).WhoseValue.Should().Be("stop"); data.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiConversationIdKey).WhoseValue.Should().Be(conversationId); } diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/ExecuteToolDataBuilderTests.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/ExecuteToolDataBuilderTests.cs index 046daf36..f7d3809c 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/ExecuteToolDataBuilderTests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/ExecuteToolDataBuilderTests.cs @@ -66,7 +66,7 @@ public void Build_WithFullToolDetails_IncludesAllToolAttributes() attrs.Should().ContainKey(OpenTelemetryConstants.GenAiToolTypeKey).WhoseValue.Should().Be("function"); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiToolServerNameKey).WhoseValue.Should().Be("my-tool-server"); attrs.Should().ContainKey(OpenTelemetryConstants.ServerAddressKey).WhoseValue.Should().Be("example.com"); - attrs.Should().ContainKey(OpenTelemetryConstants.ServerPortKey).WhoseValue.Should().Be(7071); + attrs.Should().ContainKey(OpenTelemetryConstants.ServerPortKey).WhoseValue.Should().Be("7071"); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiAgentAUIDKey).WhoseValue.Should().Be("auid"); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiAgentUPNKey).WhoseValue.Should().Be("upn@example.com"); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiAgentBlueprintIdKey).WhoseValue.Should().Be("bp-1"); @@ -86,7 +86,7 @@ public void Build_WithNonStandardPort_IncludesPort() var data = ExecuteToolDataBuilder.Build(toolDetails, agent, tenant, conversationId); // Assert - data.Attributes.Should().ContainKey(OpenTelemetryConstants.ServerPortKey).WhoseValue.Should().Be(8081); + data.Attributes.Should().ContainKey(OpenTelemetryConstants.ServerPortKey).WhoseValue.Should().Be("8081"); } [TestMethod] diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/OutputDataBuilderTests.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/OutputDataBuilderTests.cs index 51c71f58..cee5504a 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/OutputDataBuilderTests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/DTOs/Builders/OutputDataBuilderTests.cs @@ -70,7 +70,7 @@ public void Build_WithFullAgentDetails_IncludesAllAgentAttributes() attrs.Should().ContainKey(OpenTelemetryConstants.GenAiAgentUPNKey).WhoseValue.Should().Be("upn@example.com"); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiAgentBlueprintIdKey).WhoseValue.Should().Be("bp-1"); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiAgentPlatformIdKey).WhoseValue.Should().Be("platform-1"); - attrs.Should().ContainKey(OpenTelemetryConstants.GenAiAgentTypeKey).WhoseValue.Should().Be("MicrosoftCopilot"); + } [TestMethod] diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Etw/EtwLoggingBuilderTests.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Etw/EtwLoggingBuilderTests.cs index 3e85dd68..3f1705e0 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Etw/EtwLoggingBuilderTests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Etw/EtwLoggingBuilderTests.cs @@ -63,15 +63,13 @@ public void Build_AddsEtwLogProcessor_AndWritesExpectedAttributes_FromInvokeAgen Assert.AreEqual("session-1", attrsElement.GetProperty(OpenTelemetryConstants.SessionIdKey).GetString()); Assert.AreEqual(conversationId, attrsElement.GetProperty(OpenTelemetryConstants.GenAiConversationIdKey).GetString()); Assert.AreEqual("invoke_agent", attrsElement.GetProperty(OpenTelemetryConstants.GenAiOperationNameKey).GetString()); - Assert.AreEqual("MicrosoftCopilot", attrsElement.GetProperty(OpenTelemetryConstants.GenAiAgentTypeKey).GetString()); var tenantIdString = attrsElement.GetProperty(OpenTelemetryConstants.TenantIdKey).GetString(); Assert.IsTrue(Guid.TryParse(tenantIdString, out var parsedTenant)); Assert.AreEqual(tenantDetails.TenantId, parsedTenant); - Assert.AreEqual("caller-id-1", attrsElement.GetProperty(OpenTelemetryConstants.GenAiCallerIdKey).GetString()); - Assert.AreEqual("Caller Name", attrsElement.GetProperty(OpenTelemetryConstants.GenAiCallerNameKey).GetString()); - Assert.AreEqual("caller@example.com", attrsElement.GetProperty(OpenTelemetryConstants.GenAiCallerUpnKey).GetString()); - Assert.AreEqual("192.168.1.100", attrsElement.GetProperty(OpenTelemetryConstants.GenAiCallerClientIpKey).GetString()); - Assert.AreEqual("caller-tenant-id", attrsElement.GetProperty(OpenTelemetryConstants.GenAiCallerTenantIdKey).GetString()); + Assert.AreEqual("caller-id-1", attrsElement.GetProperty(OpenTelemetryConstants.CallerIdKey).GetString()); + Assert.AreEqual("Caller Name", attrsElement.GetProperty(OpenTelemetryConstants.CallerNameKey).GetString()); + Assert.AreEqual("caller@example.com", attrsElement.GetProperty(OpenTelemetryConstants.CallerUpnKey).GetString()); + Assert.AreEqual("192.168.1.100", attrsElement.GetProperty(OpenTelemetryConstants.CallerClientIpKey).GetString()); } [TestMethod] @@ -113,15 +111,15 @@ public void Build_AddsEtwLogProcessor_AndWritesExpectedAttributes_FromInferenceC Assert.AreEqual("provider-y", attrsElement.GetProperty(OpenTelemetryConstants.GenAiProviderNameKey).GetString()); Assert.AreEqual("hello", attrsElement.GetProperty(OpenTelemetryConstants.GenAiInputMessagesKey).GetString()); Assert.AreEqual("world", attrsElement.GetProperty(OpenTelemetryConstants.GenAiOutputMessagesKey).GetString()); - Assert.AreEqual("ChannelInf", attrsElement.GetProperty(OpenTelemetryConstants.GenAiChannelNameKey).GetString()); - Assert.AreEqual("https://channel/inf", attrsElement.GetProperty(OpenTelemetryConstants.GenAiChannelLinkKey).GetString()); + Assert.AreEqual("ChannelInf", attrsElement.GetProperty(OpenTelemetryConstants.ChannelNameKey).GetString()); + Assert.AreEqual("https://channel/inf", attrsElement.GetProperty(OpenTelemetryConstants.ChannelLinkKey).GetString()); var tenantIdString = attrsElement.GetProperty(OpenTelemetryConstants.TenantIdKey).GetString(); Assert.IsTrue(Guid.TryParse(tenantIdString, out var parsedTenant)); Assert.AreEqual(tenantDetails.TenantId, parsedTenant); - Assert.AreEqual("inf-caller-id", attrsElement.GetProperty(OpenTelemetryConstants.GenAiCallerIdKey).GetString()); - Assert.AreEqual("Inference Caller", attrsElement.GetProperty(OpenTelemetryConstants.GenAiCallerNameKey).GetString()); - Assert.AreEqual("infcaller@example.com", attrsElement.GetProperty(OpenTelemetryConstants.GenAiCallerUpnKey).GetString()); - Assert.AreEqual("10.0.0.50", attrsElement.GetProperty(OpenTelemetryConstants.GenAiCallerClientIpKey).GetString()); + Assert.AreEqual("inf-caller-id", attrsElement.GetProperty(OpenTelemetryConstants.CallerIdKey).GetString()); + Assert.AreEqual("Inference Caller", attrsElement.GetProperty(OpenTelemetryConstants.CallerNameKey).GetString()); + Assert.AreEqual("infcaller@example.com", attrsElement.GetProperty(OpenTelemetryConstants.CallerUpnKey).GetString()); + Assert.AreEqual("10.0.0.50", attrsElement.GetProperty(OpenTelemetryConstants.CallerClientIpKey).GetString()); } [TestMethod] @@ -164,17 +162,16 @@ public void Build_AddsEtwLogProcessor_AndWritesExpectedAttributes_FromToolCall() Assert.AreEqual("tool-call-1", attrsElement.GetProperty(OpenTelemetryConstants.GenAiToolCallIdKey).GetString()); Assert.AreEqual("desc", attrsElement.GetProperty(OpenTelemetryConstants.GenAiToolDescriptionKey).GetString()); Assert.AreEqual("function", attrsElement.GetProperty(OpenTelemetryConstants.GenAiToolTypeKey).GetString()); - Assert.AreEqual(responseContent, attrsElement.GetProperty(OpenTelemetryConstants.GenAiEventContent).GetString()); + Assert.AreEqual(responseContent, attrsElement.GetProperty(OpenTelemetryConstants.GenAiToolCallResultKey).GetString()); Assert.AreEqual("execute_tool", attrsElement.GetProperty(OpenTelemetryConstants.GenAiOperationNameKey).GetString()); - Assert.AreEqual("ChannelInf", attrsElement.GetProperty(OpenTelemetryConstants.GenAiChannelNameKey).GetString()); - Assert.AreEqual("https://channel/inf", attrsElement.GetProperty(OpenTelemetryConstants.GenAiChannelLinkKey).GetString()); + Assert.AreEqual("ChannelInf", attrsElement.GetProperty(OpenTelemetryConstants.ChannelNameKey).GetString()); + Assert.AreEqual("https://channel/inf", attrsElement.GetProperty(OpenTelemetryConstants.ChannelLinkKey).GetString()); var tenantIdString = attrsElement.GetProperty(OpenTelemetryConstants.TenantIdKey).GetString(); Assert.IsTrue(Guid.TryParse(tenantIdString, out var parsedTenant)); Assert.AreEqual(tenantDetails.TenantId, parsedTenant); - Assert.AreEqual("tool-caller-id", attrsElement.GetProperty(OpenTelemetryConstants.GenAiCallerIdKey).GetString()); - Assert.AreEqual("Tool Caller", attrsElement.GetProperty(OpenTelemetryConstants.GenAiCallerNameKey).GetString()); - Assert.AreEqual("toolcaller@example.com", attrsElement.GetProperty(OpenTelemetryConstants.GenAiCallerUpnKey).GetString()); - Assert.AreEqual("tool-caller-tenant", attrsElement.GetProperty(OpenTelemetryConstants.GenAiCallerTenantIdKey).GetString()); + Assert.AreEqual("tool-caller-id", attrsElement.GetProperty(OpenTelemetryConstants.CallerIdKey).GetString()); + Assert.AreEqual("Tool Caller", attrsElement.GetProperty(OpenTelemetryConstants.CallerNameKey).GetString()); + Assert.AreEqual("toolcaller@example.com", attrsElement.GetProperty(OpenTelemetryConstants.CallerUpnKey).GetString()); } [TestMethod] @@ -208,7 +205,6 @@ public void Build_AddsEtwLogProcessor_AndWritesExpectedAttributes_FromOutputMess Assert.AreEqual("agent-id", attrsElement.GetProperty(OpenTelemetryConstants.GenAiAgentIdKey).GetString()); Assert.AreEqual("agent-name", attrsElement.GetProperty(OpenTelemetryConstants.GenAiAgentNameKey).GetString()); Assert.AreEqual("output_messages", attrsElement.GetProperty(OpenTelemetryConstants.GenAiOperationNameKey).GetString()); - Assert.AreEqual("MicrosoftCopilot", attrsElement.GetProperty(OpenTelemetryConstants.GenAiAgentTypeKey).GetString()); Assert.AreEqual("Hello,World", attrsElement.GetProperty(OpenTelemetryConstants.GenAiOutputMessagesKey).GetString()); var tenantIdString = attrsElement.GetProperty(OpenTelemetryConstants.TenantIdKey).GetString(); Assert.IsTrue(Guid.TryParse(tenantIdString, out var parsedTenant)); diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Etw/EtwTracingBuilderTests.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Etw/EtwTracingBuilderTests.cs index a29900bb..e7cdb528 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Etw/EtwTracingBuilderTests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Etw/EtwTracingBuilderTests.cs @@ -140,7 +140,7 @@ public void Build_AddsEtwScopeEventProcessor_AndWritesExpectedAttributes_ForTool activity?.SetTag(OpenTelemetryConstants.GenAiToolCallIdKey, "tool-call-1"); activity?.SetTag(OpenTelemetryConstants.GenAiToolDescriptionKey, "desc"); activity?.SetTag(OpenTelemetryConstants.GenAiToolTypeKey, "function"); - activity?.SetTag(OpenTelemetryConstants.GenAiEventContent, "{ \"value\": \"result\" }"); + activity?.SetTag(OpenTelemetryConstants.GenAiToolCallResultKey, "{ \"value\": \"result\" }"); // Act activity?.Stop(); @@ -166,7 +166,7 @@ public void Build_AddsEtwScopeEventProcessor_AndWritesExpectedAttributes_ForTool Assert.AreEqual("tool-call-1", attrsElement.GetProperty(OpenTelemetryConstants.GenAiToolCallIdKey).GetString()); Assert.AreEqual("desc", attrsElement.GetProperty(OpenTelemetryConstants.GenAiToolDescriptionKey).GetString()); Assert.AreEqual("function", attrsElement.GetProperty(OpenTelemetryConstants.GenAiToolTypeKey).GetString()); - Assert.AreEqual("{ \"value\": \"result\" }", attrsElement.GetProperty(OpenTelemetryConstants.GenAiEventContent).GetString()); + Assert.AreEqual("{ \"value\": \"result\" }", attrsElement.GetProperty(OpenTelemetryConstants.GenAiToolCallResultKey).GetString()); Assert.AreEqual("execute_tool", attrsElement.GetProperty(OpenTelemetryConstants.GenAiOperationNameKey).GetString()); } } diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Middleware/BaggageBuilderTests.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Middleware/BaggageBuilderTests.cs index 6e45f1a1..ff5f1e9c 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Middleware/BaggageBuilderTests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Middleware/BaggageBuilderTests.cs @@ -1,9 +1,11 @@ -namespace Microsoft.Agents.A365.Observability.Tests.Middleware; +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +namespace Microsoft.Agents.A365.Observability.Tests.Middleware; using System.Net; using FluentAssertions; using Microsoft.Agents.A365.Observability.Runtime.Common; -using Microsoft.Agents.A365.Observability.Runtime.Tracing.Contracts; using Microsoft.VisualStudio.TestTools.UnitTesting; using OpenTelemetry; @@ -25,7 +27,6 @@ public void Apply_SetsAndRestores_BaggageValues() Baggage.Current = default; // clear prior test pollution var tenant = "tenant-1"; var agent = "agent-1"; - var corr = "corr-1"; var session = "session-1"; var sessionDescription = "Test Session"; var callerClientIp = IPAddress.Parse("203.0.113.42"); @@ -35,10 +36,8 @@ public void Apply_SetsAndRestores_BaggageValues() using (new BaggageBuilder() .TenantId(tenant) .AgentId(agent) - .CorrelationId(corr) .SessionId(session) .SessionDescription(sessionDescription) - .AgentType(AgentType.EntraEmbodied) .CallerClientIp(callerClientIp) .AgentPlatformId(platformId) .Build()) @@ -46,42 +45,18 @@ public void Apply_SetsAndRestores_BaggageValues() // Assert inside scope Baggage.Current.GetBaggage(TenantIdKey).Should().Be(tenant); Baggage.Current.GetBaggage(GenAiAgentIdKey).Should().Be(agent); - Baggage.Current.GetBaggage(CorrelationIdKey).Should().Be(corr); Baggage.Current.GetBaggage(SessionIdKey).Should().Be(session); Baggage.Current.GetBaggage(SessionDescriptionKey).Should().Be(sessionDescription); - Baggage.Current.GetBaggage(GenAiAgentTypeKey).Should().Be(AgentType.EntraEmbodied.ToString()); - Baggage.Current.GetBaggage(GenAiCallerClientIpKey).Should().Be(callerClientIp.ToString()); + Baggage.Current.GetBaggage(CallerClientIpKey).Should().Be(callerClientIp.ToString()); Baggage.Current.GetBaggage(GenAiAgentPlatformIdKey).Should().Be(platformId); } // Assert after dispose (restored -> no values) Baggage.Current.GetBaggage(TenantIdKey).Should().BeNull(); Baggage.Current.GetBaggage(GenAiAgentIdKey).Should().BeNull(); - Baggage.Current.GetBaggage(CorrelationIdKey).Should().BeNull(); Baggage.Current.GetBaggage(SessionIdKey).Should().BeNull(); Baggage.Current.GetBaggage(SessionDescriptionKey).Should().BeNull(); - Baggage.Current.GetBaggage(GenAiAgentTypeKey).Should().BeNull(); - Baggage.Current.GetBaggage(GenAiCallerClientIpKey).Should().BeNull(); + Baggage.Current.GetBaggage(CallerClientIpKey).Should().BeNull(); Baggage.Current.GetBaggage(GenAiAgentPlatformIdKey).Should().BeNull(); } - - [TestMethod] - public void Apply_SetsAndRestores_HiringManagerId() - { - // Arrange - Baggage.Current = default; - var hiringManagerId = "hiring-mgr-123"; - - // Act - using (new BaggageBuilder() - .HiringManagerId(hiringManagerId) - .Build()) - { - // Assert inside scope - Baggage.Current.GetBaggage(HiringManagerIdKey).Should().Be(hiringManagerId); - } - - // Assert after dispose (restored -> no value) - Baggage.Current.GetBaggage(HiringManagerIdKey).Should().BeNull(); - } } \ No newline at end of file diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/ExecuteToolScopeTest.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/ExecuteToolScopeTest.cs index 89830cfa..25fc44e9 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/ExecuteToolScopeTest.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/ExecuteToolScopeTest.cs @@ -30,7 +30,7 @@ public void RecordResponse_Response_Set() scope.RecordResponse(expected); }); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiEventContent, expected); + activity.ShouldHaveTag(OpenTelemetryConstants.GenAiToolCallResultKey, expected); } [TestMethod] @@ -64,29 +64,6 @@ public void SetStartTime_SetsActivityStartTime() startTime.Should().BeCloseTo(customStartTime, TimeSpan.FromMilliseconds(100)); } - [TestMethod] - public void AgentTypeTag_IsSetCorrectly() - { - // Arrange - var agentType = AgentType.MicrosoftCopilot; - var agentDetails = new AgentDetails( - agentId: "agent-xyz", - agentName: "ToolAgent", - agentType: agentType); - - var toolCallDetails = new ToolCallDetails("TestTool", "args"); - var tenantDetails = Util.GetTenantDetails(); - - // Act - var activity = ListenForActivity(() => - { - using var scope = ExecuteToolScope.Start(toolCallDetails, agentDetails, tenantDetails); - }); - - // Assert - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiAgentTypeKey, agentType.ToString()); - } - [TestMethod] public void Start_SetsConversationId_WhenProvided() { @@ -121,8 +98,8 @@ public void Start_SetsSourceMetadata_Tags() sourceMetadata: metadata); }); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiChannelNameKey, metadata.Name!); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiChannelLinkKey, metadata.Description!); + activity.ShouldHaveTag(OpenTelemetryConstants.ChannelNameKey, metadata.Name!); + activity.ShouldHaveTag(OpenTelemetryConstants.ChannelLinkKey, metadata.Description!); } [TestMethod] @@ -252,11 +229,10 @@ public void Start_SetsCallerDetails_WhenProvided() }); // Assert - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiCallerIdKey, callerDetails.CallerId); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiCallerNameKey, callerDetails.CallerName); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiCallerUpnKey, callerDetails.CallerUpn); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiCallerClientIpKey, callerDetails.CallerClientIP!.ToString()); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiCallerTenantIdKey, callerDetails.TenantId!); + activity.ShouldHaveTag(OpenTelemetryConstants.CallerIdKey, callerDetails.CallerId); + activity.ShouldHaveTag(OpenTelemetryConstants.CallerNameKey, callerDetails.CallerName); + activity.ShouldHaveTag(OpenTelemetryConstants.CallerUpnKey, callerDetails.CallerUpn); + activity.ShouldHaveTag(OpenTelemetryConstants.CallerClientIpKey, callerDetails.CallerClientIP!.ToString()); } [TestMethod] diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/InferenceScopeTest.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/InferenceScopeTest.cs index 634779fa..dc14cf60 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/InferenceScopeTest.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/InferenceScopeTest.cs @@ -32,7 +32,6 @@ public void Start_SetsExpectedTags() activity.ShouldHaveTag(OpenTelemetryConstants.GenAiUsageInputTokensKey, details.InputTokens!.Value.ToString()); activity.ShouldHaveTag(OpenTelemetryConstants.GenAiUsageOutputTokensKey, details.OutputTokens!.Value.ToString()); activity.ShouldHaveTag(OpenTelemetryConstants.GenAiResponseFinishReasonsKey, string.Join(",", details.FinishReasons!)); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiResponseIdKey, details.ResponseId!); } [TestMethod] @@ -67,22 +66,6 @@ public void RecordOutputTokens_SetsTag() activity.ShouldHaveTag(OpenTelemetryConstants.GenAiUsageOutputTokensKey, outputTokens.ToString()); } - [TestMethod] - public void RecordResponseId_SetsTag() - { - var responseId = "resp-456"; - var details = new InferenceCallDetails( - InferenceOperationType.Chat, - "gpt-4o", - "openai"); - var activity = ListenForActivity(() => - { - using var scope = InferenceScope.Start(details, Util.GetAgentDetails(), Util.GetTenantDetails())!; - scope.RecordResponseId(responseId); - }); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiResponseIdKey, responseId); - } - [TestMethod] public void RecordFinishReasons_SetsTag() { @@ -156,33 +139,6 @@ public void SetStartTime_SetsActivityStartTime() startTime.Should().BeCloseTo(customStartTime, TimeSpan.FromMilliseconds(100)); } - [TestMethod] - public void AgentTypeTag_IsSetCorrectly() - { - // Arrange - var agentType = AgentType.MicrosoftCopilot; - var agentDetails = new AgentDetails( - agentId: "agent-abc", - agentName: "InferenceAgent", - agentType: agentType); - - var inferenceDetails = new InferenceCallDetails( - InferenceOperationType.Chat, - "gpt-4o", - "openai"); - - var tenantDetails = Util.GetTenantDetails(); - - // Act - var activity = ListenForActivity(() => - { - using var scope = InferenceScope.Start(inferenceDetails, agentDetails, tenantDetails); - }); - - // Assert - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiAgentTypeKey, agentType.ToString()); - } - [TestMethod] public void Start_SetsConversationId_WhenProvided() { @@ -226,8 +182,8 @@ public void Start_SetsSourceMetadata_Tags() sourceMetadata: metadata); }); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiChannelNameKey, metadata.Name!); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiChannelLinkKey, metadata.Description!); + activity.ShouldHaveTag(OpenTelemetryConstants.ChannelNameKey, metadata.Name!); + activity.ShouldHaveTag(OpenTelemetryConstants.ChannelLinkKey, metadata.Description!); } [TestMethod] @@ -274,11 +230,10 @@ public void Start_SetsCallerDetails_WhenProvided() }); // Assert - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiCallerIdKey, callerDetails.CallerId); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiCallerNameKey, callerDetails.CallerName); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiCallerUpnKey, callerDetails.CallerUpn); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiCallerClientIpKey, callerDetails.CallerClientIP!.ToString()); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiCallerTenantIdKey, callerDetails.TenantId!); + activity.ShouldHaveTag(OpenTelemetryConstants.CallerIdKey, callerDetails.CallerId); + activity.ShouldHaveTag(OpenTelemetryConstants.CallerNameKey, callerDetails.CallerName); + activity.ShouldHaveTag(OpenTelemetryConstants.CallerUpnKey, callerDetails.CallerUpn); + activity.ShouldHaveTag(OpenTelemetryConstants.CallerClientIpKey, callerDetails.CallerClientIP!.ToString()); } [TestMethod] diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/InvokeAgentScopeTest.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/InvokeAgentScopeTest.cs index ac9446af..20148bda 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/InvokeAgentScopeTest.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/InvokeAgentScopeTest.cs @@ -90,41 +90,6 @@ public void RequestContent_PopulatesInputMessagesAttribute() activity.ShouldHaveTag(GenAiInputMessagesKey, requestContent); } - [TestMethod] - public void AgentTypeTags_AreSetCorrectly_ForAgentAndCallerAgent() - { - // Arrange - var agentType = AgentType.MicrosoftCopilot; - var callerAgentType = AgentType.Foundry; - - var agentDetails = new AgentDetails( - agentId: "agent-123", - agentName: "MainAgent", - agentType: agentType); - - var callerAgentDetails = new AgentDetails( - agentId: "caller-agent-456", - agentName: "CallerAgent", - agentType: callerAgentType); - - var invokeAgentDetails = new InvokeAgentDetails(agentDetails, new Uri("https://microsoft.com")); - var tenantDetails = Util.GetTenantDetails(); - - // Act - var activity = ListenForActivity(() => - { - using var scope = InvokeAgentScope.Start( - invokeAgentDetails, - tenantDetails, - request: null, - callerAgentDetails: callerAgentDetails); - }); - - // Assert - activity.ShouldHaveTag(GenAiAgentTypeKey, agentType.ToString()); - activity.ShouldHaveTag(GenAiCallerAgentTypeKey, callerAgentType.ToString()); - } - [TestMethod] public void CallerClientIpTag_IsSetCorrectly() { @@ -146,54 +111,8 @@ public void CallerClientIpTag_IsSetCorrectly() callerDetails: callerDetails); }); - activity.ShouldHaveTag(GenAiCallerClientIpKey, callerIp.ToString()); - } - - [TestMethod] - public void CallerAgentClientIpTag_IsSetCorrectly() - { - var agentClientIp = IPAddress.Parse("198.51.100.24"); - var callerAgentDetails = new AgentDetails( - agentId: "agent-002", - agentName: "CallerAgent", - agentType: AgentType.Foundry, - agentClientIP: agentClientIp); - - var activity = ListenForActivity(() => - { - using var scope = InvokeAgentScope.Start( - invokeAgentDetails: Details, - tenantDetails: Util.GetTenantDetails(), - request: null, - callerAgentDetails: callerAgentDetails); - }); - - activity.ShouldHaveTag(GenAiCallerAgentClientIpKey, agentClientIp.ToString()); - } - - [TestMethod] - public void CallerAgentPlatformIdTag_IsSetCorrectly() - { - // Arrange - var platformId = "caller-platform-123"; - var callerAgentDetails = new AgentDetails( - agentId: "agent-003", - agentName: "CallerAgentWithPlatform", - agentType: AgentType.Foundry, - agentPlatformId: platformId); - - // Act - var activity = ListenForActivity(() => - { - using var scope = InvokeAgentScope.Start( - invokeAgentDetails: Details, - tenantDetails: Util.GetTenantDetails(), - request: null, - callerAgentDetails: callerAgentDetails); - }); - // Assert - activity.ShouldHaveTag(GenAiCallerAgentPlatformIdKey, platformId); + activity.ShouldHaveTag(CallerClientIpKey, callerIp.ToString()); } [TestMethod] diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/OutputScopeTest.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/OutputScopeTest.cs index cc6aedcc..b72cf665 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/OutputScopeTest.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/OutputScopeTest.cs @@ -35,7 +35,6 @@ public void Start_SetsExpectedTags() // Assert - agent details activity.ShouldHaveTag(OpenTelemetryConstants.GenAiAgentIdKey, agentDetails.AgentId!); activity.ShouldHaveTag(OpenTelemetryConstants.GenAiAgentNameKey, agentDetails.AgentName!); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiAgentTypeKey, agentDetails.AgentType!.ToString()!); // Assert - output messages activity.ShouldHaveTag(OpenTelemetryConstants.GenAiOutputMessagesKey, string.Join(",", initialMessages)); @@ -174,15 +173,14 @@ public void Start_SetsConversationIdSourceMetadataAndCallerDetails_WhenProvided( activity.ShouldHaveTag(OpenTelemetryConstants.GenAiConversationIdKey, conversationId); // Assert - source metadata - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiChannelNameKey, metadata.Name!); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiChannelLinkKey, metadata.Description!); + activity.ShouldHaveTag(OpenTelemetryConstants.ChannelNameKey, metadata.Name!); + activity.ShouldHaveTag(OpenTelemetryConstants.ChannelLinkKey, metadata.Description!); // Assert - caller details - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiCallerIdKey, callerDetails.CallerId); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiCallerNameKey, callerDetails.CallerName); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiCallerUpnKey, callerDetails.CallerUpn); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiCallerClientIpKey, callerDetails.CallerClientIP!.ToString()); - activity.ShouldHaveTag(OpenTelemetryConstants.GenAiCallerTenantIdKey, callerDetails.TenantId!); + activity.ShouldHaveTag(OpenTelemetryConstants.CallerIdKey, callerDetails.CallerId); + activity.ShouldHaveTag(OpenTelemetryConstants.CallerNameKey, callerDetails.CallerName); + activity.ShouldHaveTag(OpenTelemetryConstants.CallerUpnKey, callerDetails.CallerUpn); + activity.ShouldHaveTag(OpenTelemetryConstants.CallerClientIpKey, callerDetails.CallerClientIP!.ToString()); } [TestMethod]