From 41df569e0204f1ed381050f1d4f144ad0d5bdd9a Mon Sep 17 00:00:00 2001 From: "Nikhil Chitlur Navakiran (from Dev Box)" Date: Mon, 23 Mar 2026 18:21:20 +0530 Subject: [PATCH] Update schema attributes: rename SourceMetadata to Channel, update caller constants to user.* namespace 1. Rename SourceMetadata class to Channel with simplified properties (Name, Link) 2. Update caller dimension constants: - CallerIdKey (microsoft.caller.id) -> UserIdKey (user.id) - CallerUpnKey (microsoft.caller.upn) -> UserEmailKey (user.email) - CallerNameKey (microsoft.caller.name) -> UserNameKey (user.name) 3. Update agent UPN constants: - AgentUPNKey (microsoft.agent.user.upn) -> AgentEmailKey (microsoft.agent.user.email) - CallerAgentUPNKey (microsoft.a365.caller.agent.user.upn) -> CallerAgentEmailKey (microsoft.a365.caller.agent.user.email) 4. Update all consumers: scopes, data builders, BaggageBuilder, ActivityProcessor, hosting extensions, middleware, ETW logger 5. Update all tests to use new naming Port of microsoft/Agent365-python#208 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Extensions/BaggageBuilderExtensions.cs | 8 +- .../Extensions/InvokeAgentScopeExtensions.cs | 8 +- .../Extensions/TurnContextExtensions.cs | 8 +- .../Middleware/OutputLoggingMiddleware.cs | 14 ++-- .../Runtime/Common/BaggageBuilder.cs | 8 +- .../Runtime/DTOs/Builders/BaseDataBuilder.cs | 32 ++++---- .../Builders/ExecuteInferenceDataBuilder.cs | 12 +-- .../DTOs/Builders/ExecuteToolDataBuilder.cs | 12 +-- .../DTOs/Builders/OutputDataBuilder.cs | 12 +-- .../Runtime/Etw/A365EtwLogger.cs | 12 +-- .../Runtime/Etw/IA365EtwLogger.cs | 12 +-- .../Runtime/Tracing/Contracts/Request.cs | 80 +++++++------------ .../Tracing/Processors/ActivityProcessor.cs | 8 +- .../Tracing/Scopes/ExecuteToolScope.cs | 8 +- .../Runtime/Tracing/Scopes/InferenceScope.cs | 8 +- .../Tracing/Scopes/InvokeAgentScope.cs | 4 +- .../Tracing/Scopes/OpenTelemetryConstants.cs | 12 +-- .../Tracing/Scopes/OpenTelemetryScope.cs | 18 ++--- .../Runtime/Tracing/Scopes/OutputScope.cs | 10 +-- .../Middleware/BaggageTurnMiddlewareTests.cs | 4 +- .../Agent365ExporterAsyncE2ETests.cs | 24 +++--- .../Agent365ExporterE2ETests.cs | 40 +++++----- .../DTOs/Builders/BaseDataBuilderTests.cs | 12 +-- .../ExecuteInferenceDataBuilderTests.cs | 12 +-- .../Builders/ExecuteToolDataBuilderTests.cs | 14 ++-- .../Builders/InvokeAgentDataBuilderTests.cs | 30 +++---- .../DTOs/Builders/OutputDataBuilderTests.cs | 14 ++-- .../Etw/EtwLoggerTests.cs | 4 +- .../Etw/EtwLoggingBuilderTests.cs | 26 +++--- .../Tracing/Scopes/ExecuteToolScopeTest.cs | 20 ++--- .../Tracing/Scopes/InferenceScopeTest.cs | 16 ++-- .../Tracing/Scopes/OutputScopeTest.cs | 14 ++-- 32 files changed, 247 insertions(+), 269 deletions(-) diff --git a/src/Observability/Hosting/Extensions/BaggageBuilderExtensions.cs b/src/Observability/Hosting/Extensions/BaggageBuilderExtensions.cs index d3140f11..ca9c8e26 100644 --- a/src/Observability/Hosting/Extensions/BaggageBuilderExtensions.cs +++ b/src/Observability/Hosting/Extensions/BaggageBuilderExtensions.cs @@ -25,7 +25,7 @@ public static BaggageBuilder FromTurnContext(this BaggageBuilder baggageBuilder, .SetCallerBaggage(turnContext) .SetTargetAgentBaggage(turnContext) .SetTenantIdBaggage(turnContext) - .SetSourceMetadataBaggage(turnContext) + .SetChannelBaggage(turnContext) .SetConversationIdBaggage(turnContext); return baggageBuilder; @@ -68,14 +68,14 @@ public static BaggageBuilder SetTenantIdBaggage(this BaggageBuilder baggageBuild } /// - /// Sets the source metadata baggage values from the TurnContext. + /// Sets the channel baggage values from the TurnContext. /// /// The BaggageBuilder instance. /// The turn context containing activity information. /// The updated BaggageBuilder instance. - public static BaggageBuilder SetSourceMetadataBaggage(this BaggageBuilder baggageBuilder, ITurnContext turnContext) + public static BaggageBuilder SetChannelBaggage(this BaggageBuilder baggageBuilder, ITurnContext turnContext) { - baggageBuilder.SetRange(turnContext.GetSourceMetadataBaggagePairs()); + baggageBuilder.SetRange(turnContext.GetChannelBaggagePairs()); return baggageBuilder; } diff --git a/src/Observability/Hosting/Extensions/InvokeAgentScopeExtensions.cs b/src/Observability/Hosting/Extensions/InvokeAgentScopeExtensions.cs index 6b580f58..aa2b94bf 100644 --- a/src/Observability/Hosting/Extensions/InvokeAgentScopeExtensions.cs +++ b/src/Observability/Hosting/Extensions/InvokeAgentScopeExtensions.cs @@ -26,7 +26,7 @@ public static InvokeAgentScope FromTurnContext(this InvokeAgentScope invokeAgent .SetCallerTags(turnContext) .SetTargetAgentTags(turnContext) .SetTenantIdTags(turnContext) - .SetSourceMetadataTags(turnContext) + .SetChannelTags(turnContext) .SetConversationIdTags(turnContext); return invokeAgentScope; @@ -63,11 +63,11 @@ public static InvokeAgentScope SetTenantIdTags(this InvokeAgentScope invokeAgent } /// - /// Sets the source metadata tags from the TurnContext. + /// Sets the channel tags from the TurnContext. /// - public static InvokeAgentScope SetSourceMetadataTags(this InvokeAgentScope invokeAgentScope, ITurnContext turnContext) + public static InvokeAgentScope SetChannelTags(this InvokeAgentScope invokeAgentScope, ITurnContext turnContext) { - invokeAgentScope.RecordAttributes(turnContext.GetSourceMetadataBaggagePairs()); + invokeAgentScope.RecordAttributes(turnContext.GetChannelBaggagePairs()); return invokeAgentScope; } diff --git a/src/Observability/Hosting/Extensions/TurnContextExtensions.cs b/src/Observability/Hosting/Extensions/TurnContextExtensions.cs index a1e52566..ea3eca36 100644 --- a/src/Observability/Hosting/Extensions/TurnContextExtensions.cs +++ b/src/Observability/Hosting/Extensions/TurnContextExtensions.cs @@ -20,8 +20,8 @@ public static class TurnContextExtensions /// public static IEnumerable> GetCallerBaggagePairs(this ITurnContext turnContext) { - yield return new KeyValuePair(OpenTelemetryConstants.CallerIdKey, turnContext.Activity?.From?.Id); - yield return new KeyValuePair(OpenTelemetryConstants.CallerNameKey, turnContext.Activity?.From?.Name); + yield return new KeyValuePair(OpenTelemetryConstants.UserIdKey, turnContext.Activity?.From?.Id); + yield return new KeyValuePair(OpenTelemetryConstants.UserNameKey, turnContext.Activity?.From?.Name); } /// @@ -65,9 +65,9 @@ public static class TurnContextExtensions } /// - /// Extracts source metadata baggage key-value pairs from the provided turn context. + /// Extracts channel baggage key-value pairs from the provided turn context. /// - public static IEnumerable> GetSourceMetadataBaggagePairs(this ITurnContext turnContext) + public static IEnumerable> GetChannelBaggagePairs(this ITurnContext turnContext) { 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 7f366d28..f4b4c153 100644 --- a/src/Observability/Hosting/Middleware/OutputLoggingMiddleware.cs +++ b/src/Observability/Hosting/Middleware/OutputLoggingMiddleware.cs @@ -53,7 +53,7 @@ public async Task OnTurnAsync(ITurnContext turnContext, NextDelegate next, Cance var callerDetails = DeriveCallerDetails(turnContext); var conversationId = turnContext.Activity?.Conversation?.Id; - var sourceMetadata = DeriveSourceMetadata(turnContext); + var channel = DeriveChannel(turnContext); turnContext.OnSendActivities(CreateSendHandler( turnContext, @@ -61,7 +61,7 @@ public async Task OnTurnAsync(ITurnContext turnContext, NextDelegate next, Cance tenantDetails, callerDetails, conversationId, - sourceMetadata)); + channel)); await next(cancellationToken).ConfigureAwait(false); } @@ -116,7 +116,7 @@ public async Task OnTurnAsync(ITurnContext turnContext, NextDelegate next, Cance tenantId: from.TenantId); } - private static SourceMetadata? DeriveSourceMetadata(ITurnContext turnContext) + private static Channel? DeriveChannel(ITurnContext turnContext) { var channelId = turnContext.Activity?.ChannelId; if (channelId == null) @@ -124,9 +124,9 @@ public async Task OnTurnAsync(ITurnContext turnContext, NextDelegate next, Cance return null; } - return new SourceMetadata( + return new Channel( name: channelId.Channel, - description: channelId.SubChannel); + link: channelId.SubChannel); } private static SendActivitiesHandler CreateSendHandler( @@ -135,7 +135,7 @@ private static SendActivitiesHandler CreateSendHandler( TenantDetails tenantDetails, CallerDetails? callerDetails, string? conversationId, - SourceMetadata? sourceMetadata) + Channel? channel) { return async (ctx, activities, nextSend) => { @@ -171,7 +171,7 @@ private static SendActivitiesHandler CreateSendHandler( tenantDetails: tenantDetails, response: new Response(messages), conversationId: conversationId, - sourceMetadata: sourceMetadata, + channel: channel, callerDetails: callerDetails, parentContext: parentContext); diff --git a/src/Observability/Runtime/Common/BaggageBuilder.cs b/src/Observability/Runtime/Common/BaggageBuilder.cs index b84ff279..fde0d8b7 100644 --- a/src/Observability/Runtime/Common/BaggageBuilder.cs +++ b/src/Observability/Runtime/Common/BaggageBuilder.cs @@ -127,7 +127,7 @@ public BaggageBuilder AgentAuid(string? v) /// public BaggageBuilder AgentUpn(string? v) { - Set(OpenTelemetryConstants.AgentUPNKey, v); + Set(OpenTelemetryConstants.AgentEmailKey, v); return this; } @@ -160,7 +160,7 @@ public BaggageBuilder AgentPlatformId(string? v) /// public BaggageBuilder CallerId(string? v) { - Set(OpenTelemetryConstants.CallerIdKey, v); + Set(OpenTelemetryConstants.UserIdKey, v); return this; } @@ -172,7 +172,7 @@ public BaggageBuilder CallerId(string? v) /// public BaggageBuilder CallerUpn(string? v) { - Set(OpenTelemetryConstants.CallerUpnKey, v); + Set(OpenTelemetryConstants.UserEmailKey, v); return this; } @@ -184,7 +184,7 @@ public BaggageBuilder CallerUpn(string? v) /// public BaggageBuilder CallerName(string? v) { - Set(OpenTelemetryConstants.CallerNameKey, v); + Set(OpenTelemetryConstants.UserNameKey, v); return this; } diff --git a/src/Observability/Runtime/DTOs/Builders/BaseDataBuilder.cs b/src/Observability/Runtime/DTOs/Builders/BaseDataBuilder.cs index 85a92c85..f005ce5b 100644 --- a/src/Observability/Runtime/DTOs/Builders/BaseDataBuilder.cs +++ b/src/Observability/Runtime/DTOs/Builders/BaseDataBuilder.cs @@ -21,7 +21,7 @@ public abstract class BaseDataBuilder where T : BaseData OpenTelemetryConstants.GenAiAgentNameKey, OpenTelemetryConstants.GenAiAgentDescriptionKey, OpenTelemetryConstants.AgentAUIDKey, - OpenTelemetryConstants.AgentUPNKey, + OpenTelemetryConstants.AgentEmailKey, OpenTelemetryConstants.AgentBlueprintIdKey, OpenTelemetryConstants.AgentPlatformIdKey, OpenTelemetryConstants.TenantIdKey, @@ -29,14 +29,14 @@ public abstract class BaseDataBuilder where T : BaseData OpenTelemetryConstants.ServerPortKey, OpenTelemetryConstants.ChannelNameKey, OpenTelemetryConstants.ChannelLinkKey, - OpenTelemetryConstants.CallerIdKey, - OpenTelemetryConstants.CallerUpnKey, - OpenTelemetryConstants.CallerNameKey, + OpenTelemetryConstants.UserIdKey, + OpenTelemetryConstants.UserEmailKey, + OpenTelemetryConstants.UserNameKey, OpenTelemetryConstants.CallerAgentNameKey, OpenTelemetryConstants.CallerAgentIdKey, OpenTelemetryConstants.CallerAgentBlueprintIdKey, OpenTelemetryConstants.CallerAgentAUIDKey, - OpenTelemetryConstants.CallerAgentUPNKey, + OpenTelemetryConstants.CallerAgentEmailKey, OpenTelemetryConstants.CallerClientIpKey, OpenTelemetryConstants.GenAiConversationIdKey, OpenTelemetryConstants.SessionIdKey, @@ -88,7 +88,7 @@ protected static void AddAgentDetails(IDictionary attributes, A AddIfNotNull(attributes, OpenTelemetryConstants.GenAiAgentNameKey, agentDetails.AgentName); AddIfNotNull(attributes, OpenTelemetryConstants.GenAiAgentDescriptionKey, agentDetails.AgentDescription); AddIfNotNull(attributes, OpenTelemetryConstants.AgentAUIDKey, agentDetails.AgentAUID); - AddIfNotNull(attributes, OpenTelemetryConstants.AgentUPNKey, agentDetails.AgentUPN); + AddIfNotNull(attributes, OpenTelemetryConstants.AgentEmailKey, agentDetails.AgentUPN); AddIfNotNull(attributes, OpenTelemetryConstants.AgentBlueprintIdKey, agentDetails.AgentBlueprintId); AddIfNotNull(attributes, OpenTelemetryConstants.AgentPlatformIdKey, agentDetails.AgentPlatformId); } @@ -126,7 +126,7 @@ protected static void AddRequestDetails(IDictionary attributes, { if (request == null) return; - AddSourceMetadataAttributes(attributes, request.SourceMetadata); + AddChannelAttributes(attributes, request.Channel); } /// @@ -136,9 +136,9 @@ protected static void AddCallerDetails(IDictionary attributes, { if (callerDetails == null) return; - AddIfNotNull(attributes, OpenTelemetryConstants.CallerIdKey, callerDetails.CallerId); - AddIfNotNull(attributes, OpenTelemetryConstants.CallerUpnKey, callerDetails.CallerUpn); - AddIfNotNull(attributes, OpenTelemetryConstants.CallerNameKey, callerDetails.CallerName); + AddIfNotNull(attributes, OpenTelemetryConstants.UserIdKey, callerDetails.CallerId); + AddIfNotNull(attributes, OpenTelemetryConstants.UserEmailKey, callerDetails.CallerUpn); + AddIfNotNull(attributes, OpenTelemetryConstants.UserNameKey, callerDetails.CallerName); AddIfNotNull(attributes, OpenTelemetryConstants.CallerClientIpKey, callerDetails.CallerClientIP?.ToString()); } @@ -153,19 +153,19 @@ protected static void AddCallerAgentDetails(IDictionary attribu 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.CallerAgentEmailKey, callerAgentDetails.AgentUPN); AddIfNotNull(attributes, OpenTelemetryConstants.CallerAgentPlatformIdKey, callerAgentDetails.AgentPlatformId); } /// - /// Adds source metadata attributes to the attributes dictionary. + /// Adds channel attributes to the attributes dictionary. /// - protected static void AddSourceMetadataAttributes(IDictionary attributes, SourceMetadata? sourceMetadata) + protected static void AddChannelAttributes(IDictionary attributes, Channel? channel) { - if (sourceMetadata == null) return; + if (channel == null) return; - AddIfNotNull(attributes, OpenTelemetryConstants.ChannelNameKey, sourceMetadata.Name); - AddIfNotNull(attributes, OpenTelemetryConstants.ChannelLinkKey, sourceMetadata.Description); + AddIfNotNull(attributes, OpenTelemetryConstants.ChannelNameKey, channel.Name); + AddIfNotNull(attributes, OpenTelemetryConstants.ChannelLinkKey, channel.Link); } /// diff --git a/src/Observability/Runtime/DTOs/Builders/ExecuteInferenceDataBuilder.cs b/src/Observability/Runtime/DTOs/Builders/ExecuteInferenceDataBuilder.cs index 76493734..54b58b12 100644 --- a/src/Observability/Runtime/DTOs/Builders/ExecuteInferenceDataBuilder.cs +++ b/src/Observability/Runtime/DTOs/Builders/ExecuteInferenceDataBuilder.cs @@ -26,7 +26,7 @@ public class ExecuteInferenceDataBuilder : BaseDataBuilder /// Optional custom end time for the operation. /// Optional span ID for the operation. /// Optional parent span ID for distributed tracing. - /// Optional source metadata for the inference call. + /// Optional channel information for the inference call. /// Optional agent thought process for the inference. /// Optional details about the non-agentic caller. /// Optional dictionary of extra attributes. @@ -43,7 +43,7 @@ public static ExecuteInferenceData Build( DateTimeOffset? endTime = null, string? spanId = null, string? parentSpanId = null, - SourceMetadata? sourceMetadata = null, + Channel? channel = null, string? thoughtProcess = null, CallerDetails? callerDetails = null, IDictionary? extraAttributes = null, @@ -56,7 +56,7 @@ public static ExecuteInferenceData Build( conversationId, inputMessages, outputMessages, - sourceMetadata, + channel, thoughtProcess, callerDetails, extraAttributes); @@ -71,7 +71,7 @@ public static ExecuteInferenceData Build( string conversationId, string[]? inputMessages, string[]? outputMessages, - SourceMetadata? sourceMetadata, + Channel? channel, string? thoughtProcess, CallerDetails? callerDetails, IDictionary? extraAttributes = null) @@ -95,8 +95,8 @@ public static ExecuteInferenceData Build( // Thought process AddIfNotNull(attributes, GenAiAgentThoughtProcessKey, thoughtProcess); - // Source metadata - AddSourceMetadataAttributes(attributes, sourceMetadata); + // Channel + AddChannelAttributes(attributes, channel); // Add caller details AddCallerDetails(attributes, callerDetails); diff --git a/src/Observability/Runtime/DTOs/Builders/ExecuteToolDataBuilder.cs b/src/Observability/Runtime/DTOs/Builders/ExecuteToolDataBuilder.cs index a178793e..d335acaa 100644 --- a/src/Observability/Runtime/DTOs/Builders/ExecuteToolDataBuilder.cs +++ b/src/Observability/Runtime/DTOs/Builders/ExecuteToolDataBuilder.cs @@ -28,7 +28,7 @@ public class ExecuteToolDataBuilder : BaseDataBuilder /// Optional custom end time for the operation. /// Optional span ID for the operation. /// Optional parent span ID for distributed tracing. - /// Optional source metadata for the operation. + /// Optional channel information for the operation. /// Optional details about the non-agentic caller. /// Optional dictionary of extra attributes. /// Optional span kind override. Use or as appropriate. @@ -44,13 +44,13 @@ public static ExecuteToolData Build( DateTimeOffset? endTime = null, string? spanId = null, string? parentSpanId = null, - SourceMetadata? sourceMetadata = null, + Channel? channel = null, CallerDetails? callerDetails = null, IDictionary? extraAttributes = null, string? spanKind = null, string? traceId = null) { - var attributes = BuildAttributes(toolCallDetails, agentDetails, tenantDetails, conversationId, responseContent, sourceMetadata, callerDetails, extraAttributes); + var attributes = BuildAttributes(toolCallDetails, agentDetails, tenantDetails, conversationId, responseContent, channel, callerDetails, extraAttributes); return new ExecuteToolData(attributes, startTime, endTime, spanId, parentSpanId, spanKind, traceId); } @@ -61,7 +61,7 @@ public static ExecuteToolData Build( TenantDetails tenantDetails, string conversationId, string? responseContent, - SourceMetadata? sourceMetadata, + Channel? channel, CallerDetails? callerDetails, IDictionary? extraAttributes = null) { @@ -83,8 +83,8 @@ public static ExecuteToolData Build( // Response content if supplied AddIfNotNull(attributes, OpenTelemetryConstants.GenAiToolCallResultKey, responseContent); - // Source metadata - AddSourceMetadataAttributes(attributes, sourceMetadata); + // Channel + AddChannelAttributes(attributes, channel); // Add caller details AddCallerDetails(attributes, callerDetails); diff --git a/src/Observability/Runtime/DTOs/Builders/OutputDataBuilder.cs b/src/Observability/Runtime/DTOs/Builders/OutputDataBuilder.cs index 3029df60..77a5eeb5 100644 --- a/src/Observability/Runtime/DTOs/Builders/OutputDataBuilder.cs +++ b/src/Observability/Runtime/DTOs/Builders/OutputDataBuilder.cs @@ -22,7 +22,7 @@ public class OutputDataBuilder : BaseDataBuilder /// The details of the tenant. /// The response containing output messages. /// Optional conversation ID for the output operation. - /// Optional source metadata (channel name) for the output operation. + /// Optional channel information for the output operation. /// Optional details about the non-agentic caller. /// Optional custom start time for the operation. /// Optional custom end time for the operation. @@ -36,7 +36,7 @@ public static OutputData Build( TenantDetails tenantDetails, Response response, string? conversationId = null, - SourceMetadata? sourceMetadata = null, + Channel? channel = null, CallerDetails? callerDetails = null, DateTimeOffset? startTime = null, DateTimeOffset? endTime = null, @@ -45,7 +45,7 @@ public static OutputData Build( IDictionary? extraAttributes = null, string? traceId = null) { - var attributes = BuildAttributes(agentDetails, tenantDetails, response, conversationId, sourceMetadata, callerDetails, extraAttributes); + var attributes = BuildAttributes(agentDetails, tenantDetails, response, conversationId, channel, callerDetails, extraAttributes); return new OutputData(attributes, startTime, endTime, spanId, parentSpanId, traceId); } @@ -55,7 +55,7 @@ public static OutputData Build( TenantDetails tenantDetails, Response response, string? conversationId, - SourceMetadata? sourceMetadata, + Channel? channel, CallerDetails? callerDetails, IDictionary? extraAttributes = null) { @@ -77,8 +77,8 @@ public static OutputData Build( // Conversation ID AddIfNotNull(attributes, OpenTelemetryConstants.GenAiConversationIdKey, conversationId); - // Source metadata - AddSourceMetadataAttributes(attributes, sourceMetadata); + // Channel + AddChannelAttributes(attributes, channel); // Caller details AddCallerDetails(attributes, callerDetails); diff --git a/src/Observability/Runtime/Etw/A365EtwLogger.cs b/src/Observability/Runtime/Etw/A365EtwLogger.cs index fa7d25a9..b706fe94 100644 --- a/src/Observability/Runtime/Etw/A365EtwLogger.cs +++ b/src/Observability/Runtime/Etw/A365EtwLogger.cs @@ -45,7 +45,7 @@ public void LogInferenceCall( DateTimeOffset? endTime, string? spanId, string? parentSpanId, - SourceMetadata? sourceMetadata, + Channel? channel, CallerDetails? callerDetails, string? traceId) { @@ -60,7 +60,7 @@ public void LogInferenceCall( endTime, spanId, parentSpanId, - sourceMetadata, + channel, callerDetails: callerDetails, traceId: traceId); @@ -124,7 +124,7 @@ public void LogToolCall( DateTimeOffset? endTime, string? spanId, string? parentSpanId, - SourceMetadata? sourceMetadata, + Channel? channel, CallerDetails? callerDetails, string? traceId) { @@ -138,7 +138,7 @@ public void LogToolCall( endTime, spanId, parentSpanId, - sourceMetadata, + channel, callerDetails: callerDetails, traceId: traceId); @@ -157,7 +157,7 @@ public void LogOutput( TenantDetails tenantDetails, Response response, string? conversationId = null, - SourceMetadata? sourceMetadata = null, + Channel? channel = null, CallerDetails? callerDetails = null, DateTimeOffset? startTime = null, DateTimeOffset? endTime = null, @@ -170,7 +170,7 @@ public void LogOutput( tenantDetails, response, conversationId, - sourceMetadata, + channel, callerDetails, startTime, endTime, diff --git a/src/Observability/Runtime/Etw/IA365EtwLogger.cs b/src/Observability/Runtime/Etw/IA365EtwLogger.cs index c7121043..440fe953 100644 --- a/src/Observability/Runtime/Etw/IA365EtwLogger.cs +++ b/src/Observability/Runtime/Etw/IA365EtwLogger.cs @@ -53,7 +53,7 @@ public void LogInvokeAgent( /// Optional span ID for tracing. /// Optional parent span ID for tracing. /// Optional trace ID for distributed tracing. - /// Optional source metadata for the inference call. + /// Optional channel information for the inference call. /// Optional details of the non-agentic caller. public void LogInferenceCall( InferenceCallDetails inferenceCallDetails, @@ -66,7 +66,7 @@ public void LogInferenceCall( DateTimeOffset? endTime = null, string? spanId = null, string? parentSpanId = null, - SourceMetadata? sourceMetadata = null, + Channel? channel = null, CallerDetails? callerDetails = null, string? traceId = null); @@ -83,7 +83,7 @@ public void LogInferenceCall( /// Optional span ID for tracing. /// Optional parent span ID for tracing. /// Optional trace ID for distributed tracing. - /// Optional source metadata for the tool call. + /// Optional channel information for the tool call. /// Optional details of the non-agentic caller. public void LogToolCall( ToolCallDetails toolCallDetails, @@ -95,7 +95,7 @@ public void LogToolCall( DateTimeOffset? endTime = null, string? spanId = null, string? parentSpanId = null, - SourceMetadata? sourceMetadata = null, + Channel? channel = null, CallerDetails? callerDetails = null, string? traceId = null); @@ -106,7 +106,7 @@ public void LogToolCall( /// The details of the tenant. /// The response containing output messages. /// Optional conversation ID for the output. - /// Optional source metadata (channel name) for the output. + /// Optional channel information for the output. /// Optional details of the non-agentic caller. /// Optional start time of the output operation. /// Optional end time of the output operation. @@ -118,7 +118,7 @@ public void LogOutput( TenantDetails tenantDetails, Response response, string? conversationId = null, - SourceMetadata? sourceMetadata = null, + Channel? channel = null, CallerDetails? callerDetails = null, DateTimeOffset? startTime = null, DateTimeOffset? endTime = null, diff --git a/src/Observability/Runtime/Tracing/Contracts/Request.cs b/src/Observability/Runtime/Tracing/Contracts/Request.cs index a8a60fc9..709eb058 100644 --- a/src/Observability/Runtime/Tracing/Contracts/Request.cs +++ b/src/Observability/Runtime/Tracing/Contracts/Request.cs @@ -61,78 +61,58 @@ public enum Role } /// - /// Represents metadata about the source (i.e. channel) of an invocation. + /// Represents channel information for agent execution context. /// - public sealed class SourceMetadata : IEquatable + public sealed class Channel : IEquatable { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// Unique identifier for the source. - /// Human-readable name of the source. - /// Optional role describing the source. - /// Optional description of the source. - public SourceMetadata(string? name, Role? role = null, string? description = null, string? id = null) + /// Human-readable name of the channel. + /// Optional link for the channel. + public Channel(string? name, string? link = null) { - Id = id; Name = name; - Role = role ?? Contracts.Role.Unknown; - Description = description; + Link = link; } /// - /// Gets the unique identifier for the source. - /// - public string? Id { get; } - - /// - /// Gets the human-readable name for the source. + /// Gets the human-readable name for the channel. /// public string? Name { get; } /// - /// Gets the role associated with the source. - /// - public Role? Role { get; } - - /// - /// Gets an optional description for the source. + /// Gets an optional link for the channel. /// - public string? Description { get; } + public string? Link { get; } /// /// Deconstructs this instance for tuple deconstruction support. /// - /// Receives the source identifier. - /// Receives the source name. - /// Receives the role value. - /// Receives the description. - public void Deconstruct(out string? id, out string? name, out Role? role, out string? description) + /// Receives the channel name. + /// Receives the link. + public void Deconstruct(out string? name, out string? link) { - id = Id; name = Name; - role = Role; - description = Description; + link = Link; } /// - public bool Equals(SourceMetadata? other) + public bool Equals(Channel? other) { if (other is null) { return false; } - return string.Equals(Id, other.Id, StringComparison.Ordinal) && - string.Equals(Name, other.Name, StringComparison.Ordinal) && - Role == other.Role && - string.Equals(Description, other.Description, StringComparison.Ordinal); + return string.Equals(Name, other.Name, StringComparison.Ordinal) && + string.Equals(Link, other.Link, StringComparison.Ordinal); } /// public override bool Equals(object? obj) { - return Equals(obj as SourceMetadata); + return Equals(obj as Channel); } /// @@ -141,10 +121,8 @@ public override int GetHashCode() unchecked { int hash = 17; - hash = (hash * 31) + (Id != null ? StringComparer.Ordinal.GetHashCode(Id) : 0); hash = (hash * 31) + (Name != null ? StringComparer.Ordinal.GetHashCode(Name) : 0); - hash = (hash * 31) + (Role?.GetHashCode() ?? 0); - hash = (hash * 31) + (Description != null ? StringComparer.Ordinal.GetHashCode(Description) : 0); + hash = (hash * 31) + (Link != null ? StringComparer.Ordinal.GetHashCode(Link) : 0); return hash; } } @@ -161,13 +139,13 @@ public sealed class Request : IEquatable /// The payload content supplied to the agent. /// Optional execution type describing the request. /// Optional session identifier. - /// Optional metadata describing request origin. - public Request(string content, ExecutionType? executionType = null, string? sessionId = null, SourceMetadata? sourceMetadata = null) + /// Optional channel information describing request origin. + public Request(string content, ExecutionType? executionType = null, string? sessionId = null, Channel? channel = null) { Content = content; ExecutionType = executionType ?? Contracts.ExecutionType.Unknown; SessionId = sessionId; - SourceMetadata = sourceMetadata; + Channel = channel; } /// @@ -186,9 +164,9 @@ public Request(string content, ExecutionType? executionType = null, string? sess public string? SessionId { get; } /// - /// Gets metadata describing the origin (i.e. channel) of the request. + /// Gets channel information describing the origin of the request. /// - public SourceMetadata? SourceMetadata { get; } + public Channel? Channel { get; } /// /// Deconstructs the request for tuple deconstruction support. @@ -196,13 +174,13 @@ public Request(string content, ExecutionType? executionType = null, string? sess /// Receives the request content. /// Receives the execution type. /// Receives the session identifier. - /// Receives the source metadata. - public void Deconstruct(out string content, out ExecutionType? executionType, out string? sessionId, out SourceMetadata? sourceMetadata) + /// Receives the channel information. + public void Deconstruct(out string content, out ExecutionType? executionType, out string? sessionId, out Channel? channel) { content = Content; executionType = ExecutionType; sessionId = SessionId; - sourceMetadata = SourceMetadata; + channel = Channel; } /// @@ -216,7 +194,7 @@ public bool Equals(Request? other) return string.Equals(Content, other.Content, StringComparison.Ordinal) && ExecutionType == other.ExecutionType && string.Equals(SessionId, other.SessionId, StringComparison.Ordinal) && - EqualityComparer.Default.Equals(SourceMetadata, other.SourceMetadata); + EqualityComparer.Default.Equals(Channel, other.Channel); } /// @@ -234,7 +212,7 @@ public override int GetHashCode() hash = (hash * 31) + (Content != null ? StringComparer.Ordinal.GetHashCode(Content) : 0); hash = (hash * 31) + (ExecutionType?.GetHashCode() ?? 0); hash = (hash * 31) + (SessionId != null ? StringComparer.Ordinal.GetHashCode(SessionId) : 0); - hash = (hash * 31) + EqualityComparer.Default.GetHashCode(SourceMetadata); + hash = (hash * 31) + EqualityComparer.Default.GetHashCode(Channel); return hash; } } diff --git a/src/Observability/Runtime/Tracing/Processors/ActivityProcessor.cs b/src/Observability/Runtime/Tracing/Processors/ActivityProcessor.cs index c9a66a63..74da4b34 100644 --- a/src/Observability/Runtime/Tracing/Processors/ActivityProcessor.cs +++ b/src/Observability/Runtime/Tracing/Processors/ActivityProcessor.cs @@ -17,7 +17,7 @@ public sealed class ActivityProcessor : BaseProcessor OpenTelemetryConstants.GenAiAgentIdKey, OpenTelemetryConstants.GenAiAgentNameKey, OpenTelemetryConstants.GenAiAgentDescriptionKey, - OpenTelemetryConstants.AgentUPNKey, + OpenTelemetryConstants.AgentEmailKey, OpenTelemetryConstants.AgentBlueprintIdKey, OpenTelemetryConstants.AgentAUIDKey, OpenTelemetryConstants.AgentPlatformIdKey, @@ -41,9 +41,9 @@ public sealed class ActivityProcessor : BaseProcessor private static readonly string[] InvokeAgentAttributeKeys = new[] { - OpenTelemetryConstants.CallerIdKey, - OpenTelemetryConstants.CallerNameKey, - OpenTelemetryConstants.CallerUpnKey, + OpenTelemetryConstants.UserIdKey, + OpenTelemetryConstants.UserNameKey, + OpenTelemetryConstants.UserEmailKey, OpenTelemetryConstants.CallerClientIpKey, }; diff --git a/src/Observability/Runtime/Tracing/Scopes/ExecuteToolScope.cs b/src/Observability/Runtime/Tracing/Scopes/ExecuteToolScope.cs index 9edfb7bf..be19168c 100644 --- a/src/Observability/Runtime/Tracing/Scopes/ExecuteToolScope.cs +++ b/src/Observability/Runtime/Tracing/Scopes/ExecuteToolScope.cs @@ -29,7 +29,7 @@ public sealed class ExecuteToolScope : OpenTelemetryScope /// Optional parent used to link this span to an upstream operation. /// Use to obtain an from HTTP headers containing a W3C traceparent. /// Optional conversation or session correlation ID for the tool execution. - /// Optional metadata describing the source of the call (e.g., component, file, line) for observability. + /// Optional channel information for observability. /// Optional threat diagnostics summary containing security-related information about blocked actions. /// Optional details about the non-agentic caller. /// Optional explicit start time. Useful when recording a tool call after execution has already completed. @@ -49,9 +49,9 @@ public sealed class ExecuteToolScope : OpenTelemetryScope /// Learn more about certification requirements /// /// - public static ExecuteToolScope Start(ToolCallDetails details, AgentDetails agentDetails, TenantDetails tenantDetails, ActivityContext? parentContext = null, string? conversationId = null, SourceMetadata? sourceMetadata = null, ThreatDiagnosticsSummary? threatDiagnosticsSummary = null, CallerDetails? callerDetails = null, DateTimeOffset? startTime = null, DateTimeOffset? endTime = null, ActivityKind? spanKind = null) => new ExecuteToolScope(details, agentDetails, tenantDetails, parentContext, conversationId, sourceMetadata, threatDiagnosticsSummary, callerDetails, startTime, endTime, spanKind); + public static ExecuteToolScope Start(ToolCallDetails details, AgentDetails agentDetails, TenantDetails tenantDetails, ActivityContext? parentContext = null, string? conversationId = null, Channel? channel = null, ThreatDiagnosticsSummary? threatDiagnosticsSummary = null, CallerDetails? callerDetails = null, DateTimeOffset? startTime = null, DateTimeOffset? endTime = null, ActivityKind? spanKind = null) => new ExecuteToolScope(details, agentDetails, tenantDetails, parentContext, conversationId, channel, threatDiagnosticsSummary, callerDetails, startTime, endTime, spanKind); - private ExecuteToolScope(ToolCallDetails details, AgentDetails agentDetails, TenantDetails tenantDetails, ActivityContext? parentContext = null, string? conversationId = null, SourceMetadata? sourceMetadata = null, ThreatDiagnosticsSummary? threatDiagnosticsSummary = null, CallerDetails? callerDetails = null, DateTimeOffset? startTime = null, DateTimeOffset? endTime = null, ActivityKind? spanKind = null) + private ExecuteToolScope(ToolCallDetails details, AgentDetails agentDetails, TenantDetails tenantDetails, ActivityContext? parentContext = null, string? conversationId = null, Channel? channel = null, ThreatDiagnosticsSummary? threatDiagnosticsSummary = null, CallerDetails? callerDetails = null, DateTimeOffset? startTime = null, DateTimeOffset? endTime = null, ActivityKind? spanKind = null) : base( kind: spanKind ?? ActivityKind.Internal, agentDetails: agentDetails, @@ -62,7 +62,7 @@ private ExecuteToolScope(ToolCallDetails details, AgentDetails agentDetails, Ten endTime: endTime, parentContext: parentContext, conversationId: conversationId, - sourceMetadata: sourceMetadata, + channel: channel, callerDetails: callerDetails) { var (toolName, arguments, toolCallId, description, toolType, endpoint, toolServerName) = details; diff --git a/src/Observability/Runtime/Tracing/Scopes/InferenceScope.cs b/src/Observability/Runtime/Tracing/Scopes/InferenceScope.cs index 617c69b0..e038f6b5 100644 --- a/src/Observability/Runtime/Tracing/Scopes/InferenceScope.cs +++ b/src/Observability/Runtime/Tracing/Scopes/InferenceScope.cs @@ -25,7 +25,7 @@ public sealed class InferenceScope : OpenTelemetryScope /// Optional parent used to link this span to an upstream operation. /// Use to obtain an from HTTP headers containing a W3C traceparent. /// Optional conversation or session correlation ID for the inference. - /// Optional metadata describing the source of the call (e.g., component, file, line) for observability. + /// Optional channel information for observability. /// Optional details about the non-agentic caller. /// Optional explicit start time. Useful when recording an inference call after execution has already completed. /// Optional explicit end time. When provided, the span will use this timestamp when disposed instead of the current wall-clock time. @@ -43,9 +43,9 @@ public sealed class InferenceScope : OpenTelemetryScope /// Learn more about certification requirements /// /// - public static InferenceScope Start(InferenceCallDetails details, AgentDetails agentDetails, TenantDetails tenantDetails, ActivityContext? parentContext = null, string? conversationId = null, SourceMetadata? sourceMetadata = null, CallerDetails? callerDetails = null, DateTimeOffset? startTime = null, DateTimeOffset? endTime = null) => new InferenceScope(details, agentDetails, tenantDetails, parentContext, conversationId, sourceMetadata, callerDetails, startTime, endTime); + public static InferenceScope Start(InferenceCallDetails details, AgentDetails agentDetails, TenantDetails tenantDetails, ActivityContext? parentContext = null, string? conversationId = null, Channel? channel = null, CallerDetails? callerDetails = null, DateTimeOffset? startTime = null, DateTimeOffset? endTime = null) => new InferenceScope(details, agentDetails, tenantDetails, parentContext, conversationId, channel, callerDetails, startTime, endTime); - private InferenceScope(InferenceCallDetails details, AgentDetails agentDetails, TenantDetails tenantDetails, ActivityContext? parentContext = null, string? conversationId = null, SourceMetadata? sourceMetadata = null, CallerDetails? callerDetails = null, DateTimeOffset? startTime = null, DateTimeOffset? endTime = null) + private InferenceScope(InferenceCallDetails details, AgentDetails agentDetails, TenantDetails tenantDetails, ActivityContext? parentContext = null, string? conversationId = null, Channel? channel = null, CallerDetails? callerDetails = null, DateTimeOffset? startTime = null, DateTimeOffset? endTime = null) : base( kind: ActivityKind.Client, agentDetails: agentDetails, @@ -56,7 +56,7 @@ private InferenceScope(InferenceCallDetails details, AgentDetails agentDetails, endTime: endTime, parentContext: parentContext, conversationId: conversationId, - sourceMetadata: sourceMetadata, + channel: channel, callerDetails: callerDetails) { SetTagMaybe(GenAiOperationNameKey, details.OperationName.ToString()); diff --git a/src/Observability/Runtime/Tracing/Scopes/InvokeAgentScope.cs b/src/Observability/Runtime/Tracing/Scopes/InvokeAgentScope.cs index a605b66c..9ac9f53f 100644 --- a/src/Observability/Runtime/Tracing/Scopes/InvokeAgentScope.cs +++ b/src/Observability/Runtime/Tracing/Scopes/InvokeAgentScope.cs @@ -70,7 +70,7 @@ private InvokeAgentScope(InvokeAgentDetails invokeAgentDetails, TenantDetails te startTime: startTime, endTime: endTime, parentContext: parentContext, conversationId: conversationId, - sourceMetadata: request?.SourceMetadata, + channel: request?.Channel, callerDetails: callerDetails) { var (endpoint, _, sessionId) = invokeAgentDetails; @@ -92,7 +92,7 @@ private InvokeAgentScope(InvokeAgentDetails invokeAgentDetails, TenantDetails te SetTagMaybe(OpenTelemetryConstants.CallerAgentIdKey, callerAgentDetails.AgentId); SetTagMaybe(OpenTelemetryConstants.CallerAgentBlueprintIdKey, callerAgentDetails.AgentBlueprintId); SetTagMaybe(OpenTelemetryConstants.CallerAgentAUIDKey, callerAgentDetails.AgentAUID); - SetTagMaybe(OpenTelemetryConstants.CallerAgentUPNKey, callerAgentDetails.AgentUPN); + SetTagMaybe(OpenTelemetryConstants.CallerAgentEmailKey, callerAgentDetails.AgentUPN); SetTagMaybe(OpenTelemetryConstants.CallerAgentPlatformIdKey, callerAgentDetails.AgentPlatformId); } diff --git a/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryConstants.cs b/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryConstants.cs index 3e82356b..198382f0 100644 --- a/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryConstants.cs +++ b/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryConstants.cs @@ -61,14 +61,14 @@ public enum OperationNames public const string GenAiAgentNameKey = "gen_ai.agent.name"; public const string GenAiAgentDescriptionKey = "gen_ai.agent.description"; public const string AgentAUIDKey = "microsoft.agent.user.id"; - public const string AgentUPNKey = "microsoft.agent.user.upn"; + public const string AgentEmailKey = "microsoft.agent.user.email"; public const string AgentBlueprintIdKey = "microsoft.a365.agent.blueprint.id"; public const string AgentPlatformIdKey = "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"; + // Human caller dimensions (OTel user.* namespace) + public const string UserIdKey = "user.id"; + public const string UserEmailKey = "user.email"; + public const string UserNameKey = "user.name"; public const string CallerClientIpKey = "client.address"; // Caller agent dimensions (renamed from gen_ai.caller.agent.* to microsoft.a365.caller.agent.*) @@ -76,7 +76,7 @@ public enum OperationNames 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 CallerAgentEmailKey = "microsoft.a365.caller.agent.user.email"; public const string CallerAgentPlatformIdKey = "microsoft.a365.caller.agent.platform.id"; // Service attributes diff --git a/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryScope.cs b/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryScope.cs index b2dd9e8d..7dccc17d 100644 --- a/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryScope.cs +++ b/src/Observability/Runtime/Tracing/Scopes/OpenTelemetryScope.cs @@ -48,9 +48,9 @@ public abstract class OpenTelemetryScope : IDisposable /// operation. Use to obtain an /// from HTTP headers containing a W3C traceparent. /// Optional conversation id. - /// Optional source metadata. + /// Optional channel information. /// Optional details about the non-agentic caller. - protected OpenTelemetryScope(ActivityKind kind, AgentDetails agentDetails, TenantDetails tenantDetails, string operationName, string activityName, DateTimeOffset? startTime = null, DateTimeOffset? endTime = null, ActivityContext? parentContext = null, string? conversationId = null, SourceMetadata? sourceMetadata = null, CallerDetails? callerDetails = null) + protected OpenTelemetryScope(ActivityKind kind, AgentDetails agentDetails, TenantDetails tenantDetails, string operationName, string activityName, DateTimeOffset? startTime = null, DateTimeOffset? endTime = null, ActivityContext? parentContext = null, string? conversationId = null, Channel? channel = null, CallerDetails? callerDetails = null) { customStartTime = startTime; customEndTime = endTime; @@ -79,7 +79,7 @@ protected OpenTelemetryScope(ActivityKind kind, AgentDetails agentDetails, Tenan SetTagMaybe(GenAiAgentNameKey, agentDetails.AgentName); SetTagMaybe(GenAiAgentDescriptionKey, agentDetails.AgentDescription); SetTagMaybe(AgentAUIDKey, agentDetails.AgentAUID); - SetTagMaybe(AgentUPNKey, agentDetails.AgentUPN); + SetTagMaybe(AgentEmailKey, agentDetails.AgentUPN); SetTagMaybe(AgentBlueprintIdKey, agentDetails.AgentBlueprintId); SetTagMaybe(AgentPlatformIdKey, agentDetails.AgentPlatformId); } @@ -100,17 +100,17 @@ protected OpenTelemetryScope(ActivityKind kind, AgentDetails agentDetails, Tenan SetTagMaybe(OpenTelemetryConstants.GenAiConversationIdKey, conversationId); } - if (sourceMetadata != null) + if (channel != null) { - SetTagMaybe(OpenTelemetryConstants.ChannelNameKey, sourceMetadata.Name); - SetTagMaybe(OpenTelemetryConstants.ChannelLinkKey, sourceMetadata.Description); + SetTagMaybe(OpenTelemetryConstants.ChannelNameKey, channel.Name); + SetTagMaybe(OpenTelemetryConstants.ChannelLinkKey, channel.Link); } if (callerDetails != null) { - SetTagMaybe(OpenTelemetryConstants.CallerIdKey, callerDetails.CallerId); - SetTagMaybe(OpenTelemetryConstants.CallerUpnKey, callerDetails.CallerUpn); - SetTagMaybe(OpenTelemetryConstants.CallerNameKey, callerDetails.CallerName); + SetTagMaybe(OpenTelemetryConstants.UserIdKey, callerDetails.CallerId); + SetTagMaybe(OpenTelemetryConstants.UserEmailKey, callerDetails.CallerUpn); + SetTagMaybe(OpenTelemetryConstants.UserNameKey, callerDetails.CallerName); SetTagMaybe(OpenTelemetryConstants.CallerClientIpKey, callerDetails.CallerClientIP?.ToString()); } diff --git a/src/Observability/Runtime/Tracing/Scopes/OutputScope.cs b/src/Observability/Runtime/Tracing/Scopes/OutputScope.cs index c8439518..3af1ffa4 100644 --- a/src/Observability/Runtime/Tracing/Scopes/OutputScope.cs +++ b/src/Observability/Runtime/Tracing/Scopes/OutputScope.cs @@ -29,15 +29,15 @@ public sealed class OutputScope : OpenTelemetryScope /// Optional parent used to link this span to an upstream operation. /// Use to obtain an from HTTP headers containing a W3C traceparent. /// Optional conversation or session correlation ID for the output operation. - /// Optional metadata describing the source of the call (e.g., channel name) for observability. + /// Optional channel information for observability. /// Optional details about the non-agentic caller. /// Optional explicit start time. Useful when recording an output operation after execution has already completed. /// Optional explicit end time. When provided, the span will use this timestamp when disposed instead of the current wall-clock time. /// A new OutputScope instance. - public static OutputScope Start(AgentDetails agentDetails, TenantDetails tenantDetails, Response response, ActivityContext? parentContext = null, string? conversationId = null, SourceMetadata? sourceMetadata = null, CallerDetails? callerDetails = null, DateTimeOffset? startTime = null, DateTimeOffset? endTime = null) - => new OutputScope(agentDetails, tenantDetails, response, parentContext, conversationId, sourceMetadata, callerDetails, startTime, endTime); + public static OutputScope Start(AgentDetails agentDetails, TenantDetails tenantDetails, Response response, ActivityContext? parentContext = null, string? conversationId = null, Channel? channel = null, CallerDetails? callerDetails = null, DateTimeOffset? startTime = null, DateTimeOffset? endTime = null) + => new OutputScope(agentDetails, tenantDetails, response, parentContext, conversationId, channel, callerDetails, startTime, endTime); - private OutputScope(AgentDetails agentDetails, TenantDetails tenantDetails, Response response, ActivityContext? parentContext, string? conversationId, SourceMetadata? sourceMetadata, CallerDetails? callerDetails, DateTimeOffset? startTime, DateTimeOffset? endTime) + private OutputScope(AgentDetails agentDetails, TenantDetails tenantDetails, Response response, ActivityContext? parentContext, string? conversationId, Channel? channel, CallerDetails? callerDetails, DateTimeOffset? startTime, DateTimeOffset? endTime) : base( kind: ActivityKind.Client, agentDetails: agentDetails, @@ -48,7 +48,7 @@ private OutputScope(AgentDetails agentDetails, TenantDetails tenantDetails, Resp endTime: endTime, parentContext: parentContext, conversationId: conversationId, - sourceMetadata: sourceMetadata, + channel: channel, callerDetails: callerDetails) { if (response.Messages.Count > 0) 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 d3e3a4e9..95f0cc53 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.CallerIdKey); + capturedCallerId = Baggage.Current.GetBaggage(OpenTelemetryConstants.UserIdKey); return Task.CompletedTask; }; @@ -54,7 +54,7 @@ public async Task OnTurnAsync_SkipsBaggageForContinueConversation() NextDelegate next = (ct) => { logicCalled = true; - capturedCallerId = Baggage.Current.GetBaggage(OpenTelemetryConstants.CallerIdKey); + capturedCallerId = Baggage.Current.GetBaggage(OpenTelemetryConstants.UserIdKey); 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 44b8dc70..4ff51b23 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterAsyncE2ETests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterAsyncE2ETests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using FluentAssertions; @@ -44,9 +44,9 @@ public async Task AddTracing_And_InvokeAgentScope_ExporterMakesExpectedRequest() var expectedRequest = new Request( content: "Test request content", executionType: ExecutionType.HumanToAgent, - sourceMetadata: new SourceMetadata( + channel: new Channel( name: "msteams", - description: "https://testchannel.link")); + link: "https://testchannel.link")); var expectedCallerDetails = new CallerDetails( callerId: "caller-123", @@ -85,19 +85,19 @@ 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, "microsoft.channel.name").Should().Be(expectedRequest.SourceMetadata?.Name); - this.GetAttribute(attributes, "microsoft.channel.link").Should().Be(expectedRequest.SourceMetadata?.Description); + this.GetAttribute(attributes, "microsoft.channel.name").Should().Be(expectedRequest.Channel?.Name); + this.GetAttribute(attributes, "microsoft.channel.link").Should().Be(expectedRequest.Channel?.Link); 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, "user.id").Should().Be(expectedCallerDetails.CallerId); + this.GetAttribute(attributes, "user.email").Should().Be(expectedCallerDetails.CallerUpn); + this.GetAttribute(attributes, "user.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, "microsoft.agent.user.id").Should().Be(expectedAgentDetails.AgentAUID); - this.GetAttribute(attributes, "microsoft.agent.user.upn").Should().Be(expectedAgentDetails.AgentUPN); + this.GetAttribute(attributes, "microsoft.agent.user.email").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"); @@ -160,7 +160,7 @@ public async Task AddTracing_And_ExecuteToolScope_ExporterMakesExpectedRequest() 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, "microsoft.agent.user.id").Should().Be(expectedAgentDetails.AgentAUID); - this.GetAttribute(attributes, "microsoft.agent.user.upn").Should().Be(expectedAgentDetails.AgentUPN); + this.GetAttribute(attributes, "microsoft.agent.user.email").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); @@ -234,7 +234,7 @@ public async Task AddTracing_And_InferenceScope_ExporterMakesExpectedRequest() 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, "microsoft.agent.user.id").Should().Be(expectedAgentDetails.AgentAUID); - this.GetAttribute(attributes, "microsoft.agent.user.upn").Should().Be(expectedAgentDetails.AgentUPN); + this.GetAttribute(attributes, "microsoft.agent.user.email").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); @@ -279,7 +279,7 @@ public async Task AddTracing_NestedScopes_AllExporterRequestsReceived() var request = new Request( content: "Nested request", executionType: ExecutionType.HumanToAgent, - sourceMetadata: new SourceMetadata(name: "nested", description: "https://nestedchannel.link")); + channel: new Channel(name: "nested", link: "https://nestedchannel.link")); var toolCallDetails = new ToolCallDetails( toolName: "NestedTool", 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 e2d55314..05f152e7 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterE2ETests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.IntegrationTests/Agent365ExporterE2ETests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using FluentAssertions; @@ -44,9 +44,9 @@ public async Task AddTracing_And_InvokeAgentScope_ExporterMakesExpectedRequest() var expectedRequest = new Request( content: "Test request content", executionType: ExecutionType.HumanToAgent, - sourceMetadata: new SourceMetadata( + channel: new Channel( name: "msteams", - description: "https://testchannel.link")); + link: "https://testchannel.link")); var expectedCallerDetails = new CallerDetails( callerId: "caller-123", @@ -91,12 +91,12 @@ 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, "microsoft.channel.name").Should().Be(expectedRequest.SourceMetadata?.Name); - this.GetAttribute(attributes, "microsoft.channel.link").Should().Be(expectedRequest.SourceMetadata?.Description); + this.GetAttribute(attributes, "microsoft.channel.name").Should().Be(expectedRequest.Channel?.Name); + this.GetAttribute(attributes, "microsoft.channel.link").Should().Be(expectedRequest.Channel?.Link); 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, "user.id").Should().Be(expectedCallerDetails.CallerId); + this.GetAttribute(attributes, "user.email").Should().Be(expectedCallerDetails.CallerUpn); + this.GetAttribute(attributes, "user.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"); @@ -104,7 +104,7 @@ public async Task AddTracing_And_InvokeAgentScope_ExporterMakesExpectedRequest() 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, "microsoft.agent.user.id").Should().Be(expectedAgentDetails.AgentAUID); - this.GetAttribute(attributes, "microsoft.agent.user.upn").Should().Be(expectedAgentDetails.AgentUPN); + this.GetAttribute(attributes, "microsoft.agent.user.email").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"); @@ -187,7 +187,7 @@ public async Task AddTracing_And_ExecuteToolScope_ExporterMakesExpectedRequest() 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, "microsoft.agent.user.id").Should().Be(expectedAgentDetails.AgentAUID); - this.GetAttribute(attributes, "microsoft.agent.user.upn").Should().Be(expectedAgentDetails.AgentUPN); + this.GetAttribute(attributes, "microsoft.agent.user.email").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); @@ -199,9 +199,9 @@ public async Task AddTracing_And_ExecuteToolScope_ExporterMakesExpectedRequest() this.GetAttribute(attributes, "server.address").Should().Be(endpoint.Host); this.GetAttribute(attributes, "server.port").Should().Be(endpoint.Port.ToString()); 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, "user.id").Should().Be(expectedToolCallerDetails.CallerId); + this.GetAttribute(attributes, "user.email").Should().Be(expectedToolCallerDetails.CallerUpn); + this.GetAttribute(attributes, "user.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"); @@ -278,7 +278,7 @@ public async Task AddTracing_And_InferenceScope_ExporterMakesExpectedRequest() 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, "microsoft.agent.user.id").Should().Be(expectedAgentDetails.AgentAUID); - this.GetAttribute(attributes, "microsoft.agent.user.upn").Should().Be(expectedAgentDetails.AgentUPN); + this.GetAttribute(attributes, "microsoft.agent.user.email").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); @@ -288,9 +288,9 @@ 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, "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, "user.id").Should().Be(expectedInferenceCallerDetails.CallerId); + this.GetAttribute(attributes, "user.email").Should().Be(expectedInferenceCallerDetails.CallerUpn); + this.GetAttribute(attributes, "user.name").Should().Be(expectedInferenceCallerDetails.CallerName); this.GetAttribute(attributes, "client.address").Should().Be(expectedInferenceCallerDetails.CallerClientIP?.ToString()); } @@ -350,7 +350,7 @@ private async Task RunNestedScopes_AllExporterRequestsReceived(bool useAgentId) var request = new Request( content: "Nested request", executionType: ExecutionType.HumanToAgent, - sourceMetadata: new SourceMetadata(name: "nested", description: "https://nestedchannel.link")); + channel: new Channel(name: "nested", link: "https://nestedchannel.link")); var toolCallDetails = new ToolCallDetails( toolName: "NestedTool", @@ -445,7 +445,7 @@ public async Task Exporter_Truncates_Scope() var request = new Request( content: "Test request content", executionType: ExecutionType.HumanToAgent, - sourceMetadata: new SourceMetadata(name: "test", id: "test-id")); + channel: new Channel(name: "test")); var toolCallDetails = new ToolCallDetails( toolName: "LargeFileTool", @@ -573,7 +573,7 @@ public async Task AddTracing_MultipleInvocations_NoDuplicateExports() var request = new Request( content: "Singleton test request", executionType: ExecutionType.HumanToAgent, - sourceMetadata: new SourceMetadata(name: "test", description: "singleton test")); + channel: new Channel(name: "test", link: "singleton test")); using (var scope = InvokeAgentScope.Start(invokeAgentDetails, tenantDetails, request)) { scope.RecordInputMessages(new[] { "Test input" }); 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 346bb64f..c5b918b3 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 @@ -43,7 +43,7 @@ public void AddAgentDetails_PopulatesExpectedKeys() dict.Should().ContainKey(OpenTelemetryConstants.GenAiAgentNameKey); dict.Should().ContainKey(OpenTelemetryConstants.GenAiAgentDescriptionKey); dict.Should().ContainKey(OpenTelemetryConstants.AgentAUIDKey); - dict.Should().ContainKey(OpenTelemetryConstants.AgentUPNKey); + dict.Should().ContainKey(OpenTelemetryConstants.AgentEmailKey); dict.Should().ContainKey(OpenTelemetryConstants.AgentBlueprintIdKey); dict.Should().ContainKey(OpenTelemetryConstants.AgentPlatformIdKey); } @@ -77,7 +77,7 @@ public void AddEndpointDetails_StandardPort_OmitsPort() [TestMethod] 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 request = new Request("content", ExecutionType.HumanToAgent, "session", new Channel(name: "src-name", link: "src-desc")); var dict = TestBuilder.BuildAll(request: request); dict.Should().ContainKey(OpenTelemetryConstants.ChannelLinkKey); dict.Should().ContainKey(OpenTelemetryConstants.ChannelNameKey); @@ -88,9 +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.CallerIdKey); - dict.Should().ContainKey(OpenTelemetryConstants.CallerUpnKey); - dict.Should().ContainKey(OpenTelemetryConstants.CallerNameKey); + dict.Should().ContainKey(OpenTelemetryConstants.UserIdKey); + dict.Should().ContainKey(OpenTelemetryConstants.UserEmailKey); + dict.Should().ContainKey(OpenTelemetryConstants.UserNameKey); } [TestMethod] @@ -102,7 +102,7 @@ public void AddCallerAgentDetails_PopulatesCallerAgentKeys() dict.Should().ContainKey(OpenTelemetryConstants.CallerAgentNameKey); dict.Should().ContainKey(OpenTelemetryConstants.CallerAgentBlueprintIdKey); dict.Should().ContainKey(OpenTelemetryConstants.CallerAgentAUIDKey); - dict.Should().ContainKey(OpenTelemetryConstants.CallerAgentUPNKey); + dict.Should().ContainKey(OpenTelemetryConstants.CallerAgentEmailKey); dict.Should().ContainKey(OpenTelemetryConstants.CallerAgentPlatformIdKey); } 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 699313ed..81a9ca90 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 @@ -28,17 +28,17 @@ public void Build_WithMinimalParameters_SetsBasicAttributes() } [TestMethod] - public void Build_WithSourceMetadata_IncludesChannelAttributes() + public void Build_WithChannel_IncludesChannelAttributes() { // Arrange var details = new InferenceCallDetails(InferenceOperationType.Chat, "gpt-4o", "openai"); var agent = new AgentDetails("agent-src"); var tenant = new TenantDetails(Guid.NewGuid()); var conversationId = "conv-src-inf"; - var source = new SourceMetadata(id: "src-id", name: "ChannelInf", role: Role.Human, description: "https://channel/inf"); + var source = new Channel(name: "ChannelInf", link: "https://channel/inf"); // Act - var data = ExecuteInferenceDataBuilder.Build(details, agent, tenant, conversationId, sourceMetadata: source); + var data = ExecuteInferenceDataBuilder.Build(details, agent, tenant, conversationId, channel: source); // Assert data.Attributes.Should().ContainKey(OpenTelemetryConstants.ChannelNameKey).WhoseValue.Should().Be("ChannelInf"); @@ -198,9 +198,9 @@ public void Build_WithAllParameters_SetsAllExpectedAttributes() attrs.Should().ContainKey(OpenTelemetryConstants.GenAiInputMessagesKey); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiOutputMessagesKey); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiAgentThoughtProcessKey).WhoseValue.Should().Be(thoughtProcess); - 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.UserIdKey).WhoseValue.Should().Be("caller-inf-123"); + attrs.Should().ContainKey(OpenTelemetryConstants.UserNameKey).WhoseValue.Should().Be("Caller Inf Name"); + attrs.Should().ContainKey(OpenTelemetryConstants.UserEmailKey).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); 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 34f6b22a..91288e51 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 @@ -30,17 +30,17 @@ public void Build_WithMinimalParameters_SetsBasicAttributes() } [TestMethod] - public void Build_WithSourceMetadata_IncludesChannelAttributes() + public void Build_WithChannel_IncludesChannelAttributes() { // Arrange var toolDetails = new ToolCallDetails("toolSource", null); var agent = new AgentDetails("agent-src"); var tenant = new TenantDetails(Guid.NewGuid()); var conversationId = "conv-src-tool"; - var source = new SourceMetadata(id: "src-id", name: "ChannelTool", role: Role.Agent, description: "https://channel/tool"); + var source = new Channel(name: "ChannelTool", link: "https://channel/tool"); // Act - var data = ExecuteToolDataBuilder.Build(toolDetails, agent, tenant, conversationId, sourceMetadata: source); + var data = ExecuteToolDataBuilder.Build(toolDetails, agent, tenant, conversationId, channel: source); // Assert data.Attributes.Should().ContainKey(OpenTelemetryConstants.ChannelNameKey).WhoseValue.Should().Be("ChannelTool"); @@ -69,7 +69,7 @@ public void Build_WithFullToolDetails_IncludesAllToolAttributes() attrs.Should().ContainKey(OpenTelemetryConstants.ServerAddressKey).WhoseValue.Should().Be("example.com"); attrs.Should().ContainKey(OpenTelemetryConstants.ServerPortKey).WhoseValue.Should().Be("7071"); attrs.Should().ContainKey(OpenTelemetryConstants.AgentAUIDKey).WhoseValue.Should().Be("auid"); - attrs.Should().ContainKey(OpenTelemetryConstants.AgentUPNKey).WhoseValue.Should().Be("upn@example.com"); + attrs.Should().ContainKey(OpenTelemetryConstants.AgentEmailKey).WhoseValue.Should().Be("upn@example.com"); attrs.Should().ContainKey(OpenTelemetryConstants.AgentBlueprintIdKey).WhoseValue.Should().Be("bp-1"); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiConversationIdKey).WhoseValue.Should().Be(conversationId); } @@ -236,9 +236,9 @@ public void Build_WithAllParameters_SetsAllExpectedAttributes() attrs.Should().ContainKey(OpenTelemetryConstants.GenAiToolServerNameKey).WhoseValue.Should().Be("full-tool-server"); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiConversationIdKey); 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.UserIdKey).WhoseValue.Should().Be("caller-tool-123"); + attrs.Should().ContainKey(OpenTelemetryConstants.UserNameKey).WhoseValue.Should().Be("Caller Tool Name"); + attrs.Should().ContainKey(OpenTelemetryConstants.UserEmailKey).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); 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 f5c22275..280a80ef 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 @@ -21,7 +21,7 @@ public void Build_IncludesRequestDetails_WhenRequestProvided() "test content", ExecutionType.HumanToAgent, "session-456", - new SourceMetadata(id: "source-id", name: "source-name", role: Role.Human, description: "source-description")); + new Channel(name: "source-name", link: "source-description")); var conversationId = "conv-123"; // Act @@ -35,7 +35,7 @@ public void Build_IncludesRequestDetails_WhenRequestProvided() 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[OpenTelemetryConstants.ChannelLinkKey].Should().Be("source-description"); } [TestMethod] @@ -78,10 +78,10 @@ public void Build_IncludesCallerDetails_WhenProvided() callerDetails: callerDetails); // Assert - 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.UserIdKey); + telemetry.Attributes[OpenTelemetryConstants.UserIdKey].Should().Be("caller-123"); + telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.UserNameKey); + telemetry.Attributes[OpenTelemetryConstants.UserNameKey].Should().Be("Caller Name"); } [TestMethod] @@ -298,7 +298,7 @@ public void Build_WithAllParameters_SetsAllExpectedAttributes() "test content", ExecutionType.HumanToAgent, "session-456", - new SourceMetadata(id: "source-id", name: "source-name", role: Role.Human, description: "source-description")); + new Channel(name: "source-name", link: "source-description")); var callerAgentDetails = new AgentDetails("caller-agent-789", "CallerAgent"); var callerDetails = new CallerDetails("caller-123", "Caller Name", "caller@example.com"); var conversationId = "conv-999"; @@ -326,7 +326,7 @@ public void Build_WithAllParameters_SetsAllExpectedAttributes() // Assert telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.ChannelNameKey); - telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.CallerIdKey); + telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.UserIdKey); telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.CallerAgentIdKey); telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiInputMessagesKey); telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.GenAiOutputMessagesKey); @@ -458,7 +458,7 @@ public void Build_WithAgentPlatformId_SetsExpectedAttributes() "test content", ExecutionType.HumanToAgent, "session-456", - new SourceMetadata(id: "source-id", name: "source-name", role: Role.Human, description: "source-description")); + new Channel(name: "source-name", link: "source-description")); var callerDetails = new CallerDetails("caller-123", "Caller Name", "caller@example.com"); var conversationId = "conv-999"; var inputMessages = new[] { "Hello" }; @@ -488,12 +488,12 @@ public void Build_WithAgentPlatformId_SetsExpectedAttributes() 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.UserIdKey); + telemetry.Attributes[OpenTelemetryConstants.UserIdKey].Should().Be("caller-123"); + telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.UserNameKey); + telemetry.Attributes[OpenTelemetryConstants.UserNameKey].Should().Be("Caller Name"); + telemetry.Attributes.Should().ContainKey(OpenTelemetryConstants.UserEmailKey); + telemetry.Attributes[OpenTelemetryConstants.UserEmailKey].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 c41c0675..b6f030ae 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 @@ -30,7 +30,7 @@ public void Build_WithMinimalParameters_SetsBasicAttributes() data.Attributes.Should().NotContainKey(OpenTelemetryConstants.GenAiConversationIdKey); data.Attributes.Should().NotContainKey(OpenTelemetryConstants.ChannelNameKey); data.Attributes.Should().NotContainKey(OpenTelemetryConstants.ChannelLinkKey); - data.Attributes.Should().NotContainKey(OpenTelemetryConstants.CallerIdKey); + data.Attributes.Should().NotContainKey(OpenTelemetryConstants.UserIdKey); } [TestMethod] @@ -67,7 +67,7 @@ public void Build_WithFullAgentDetails_IncludesAllAgentAttributes() attrs.Should().ContainKey(OpenTelemetryConstants.GenAiAgentNameKey).WhoseValue.Should().Be("AgentThree"); attrs.Should().ContainKey(OpenTelemetryConstants.GenAiAgentDescriptionKey).WhoseValue.Should().Be("Description"); attrs.Should().ContainKey(OpenTelemetryConstants.AgentAUIDKey).WhoseValue.Should().Be("auid"); - attrs.Should().ContainKey(OpenTelemetryConstants.AgentUPNKey).WhoseValue.Should().Be("upn@example.com"); + attrs.Should().ContainKey(OpenTelemetryConstants.AgentEmailKey).WhoseValue.Should().Be("upn@example.com"); attrs.Should().ContainKey(OpenTelemetryConstants.AgentBlueprintIdKey).WhoseValue.Should().Be("bp-1"); attrs.Should().ContainKey(OpenTelemetryConstants.AgentPlatformIdKey).WhoseValue.Should().Be("platform-1"); @@ -131,7 +131,7 @@ public void Build_WithAllParameters_SetsAllExpectedAttributes() var tenant = new TenantDetails(Guid.NewGuid()); var response = new Response(new[] { "Hello", "World" }); var conversationId = "conv-output-all"; - var source = new SourceMetadata(id: "src-id", name: "ChannelOutput", role: Role.Human, description: "https://channel/output"); + var source = new Channel(name: "ChannelOutput", link: "https://channel/output"); var callerDetails = new CallerDetails("caller-output-123", "Output Caller Name", "calleroutput@example.com", System.Net.IPAddress.Parse("192.168.1.50"), "caller-tenant-output"); var start = DateTimeOffset.UtcNow.AddSeconds(-5); var end = DateTimeOffset.UtcNow; @@ -144,7 +144,7 @@ public void Build_WithAllParameters_SetsAllExpectedAttributes() tenant, response, conversationId: conversationId, - sourceMetadata: source, + channel: source, callerDetails: callerDetails, startTime: start, endTime: end, @@ -156,9 +156,9 @@ public void Build_WithAllParameters_SetsAllExpectedAttributes() attrs.Should().ContainKey(OpenTelemetryConstants.GenAiConversationIdKey).WhoseValue.Should().Be("conv-output-all"); 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.UserIdKey).WhoseValue.Should().Be("caller-output-123"); + attrs.Should().ContainKey(OpenTelemetryConstants.UserNameKey).WhoseValue.Should().Be("Output Caller Name"); + attrs.Should().ContainKey(OpenTelemetryConstants.UserEmailKey).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); diff --git a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Etw/EtwLoggerTests.cs b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Etw/EtwLoggerTests.cs index 3e2420ee..89e3cab7 100644 --- a/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Etw/EtwLoggerTests.cs +++ b/src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Etw/EtwLoggerTests.cs @@ -108,11 +108,11 @@ public void Logs_Output_Event() var agentDetails = new AgentDetails("agent-id", agentName: "agent-name"); var response = new Response(new[] { "Hello", "World" }); var conversationId = "conv-output-etw"; - var sourceMetadata = new SourceMetadata(name: "EtwChannel", description: "https://channel/etw"); + var sourceMetadata = new Channel(name: "EtwChannel", link: "https://channel/etw"); var callerDetails = new CallerDetails("caller-etw-123", "Etw Caller", "etw-caller@example.com"); // Act - etwLogger.LogOutput(agentDetails, tenantDetails, response, conversationId: conversationId, sourceMetadata: sourceMetadata, callerDetails: callerDetails); + etwLogger.LogOutput(agentDetails, tenantDetails, response, conversationId: conversationId, channel: sourceMetadata, callerDetails: callerDetails); // Assert var evt = listener.Events.FirstOrDefault(e => e.EventId == 2000); 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 3f1705e0..7fc3da44 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 @@ -66,9 +66,9 @@ public void Build_AddsEtwLogProcessor_AndWritesExpectedAttributes_FromInvokeAgen 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.CallerIdKey).GetString()); - Assert.AreEqual("Caller Name", attrsElement.GetProperty(OpenTelemetryConstants.CallerNameKey).GetString()); - Assert.AreEqual("caller@example.com", attrsElement.GetProperty(OpenTelemetryConstants.CallerUpnKey).GetString()); + Assert.AreEqual("caller-id-1", attrsElement.GetProperty(OpenTelemetryConstants.UserIdKey).GetString()); + Assert.AreEqual("Caller Name", attrsElement.GetProperty(OpenTelemetryConstants.UserNameKey).GetString()); + Assert.AreEqual("caller@example.com", attrsElement.GetProperty(OpenTelemetryConstants.UserEmailKey).GetString()); Assert.AreEqual("192.168.1.100", attrsElement.GetProperty(OpenTelemetryConstants.CallerClientIpKey).GetString()); } @@ -84,11 +84,11 @@ public void Build_AddsEtwLogProcessor_AndWritesExpectedAttributes_FromInferenceC var agentDetails = new AgentDetails("agent-id", agentName: "agent-name"); var inferenceDetails = new InferenceCallDetails(InferenceOperationType.Chat, "model-x", "provider-y"); string conversationId = "conv-inf-1"; - var source = new SourceMetadata(id: "src-id", name: "ChannelInf", role: Role.Human, description: "https://channel/inf"); + var source = new Channel(name: "ChannelInf", link: "https://channel/inf"); var callerDetails = new CallerDetails(callerId: "inf-caller-id", callerName: "Inference Caller", callerUpn: "infcaller@example.com", callerClientIP: IPAddress.Parse("10.0.0.50")); // Act - logger.LogInferenceCall(inferenceDetails, agentDetails, tenantDetails, conversationId, inputMessages: new[] { "hello" }, outputMessages: new[] { "world" }, sourceMetadata: source, callerDetails: callerDetails); + logger.LogInferenceCall(inferenceDetails, agentDetails, tenantDetails, conversationId, inputMessages: new[] { "hello" }, outputMessages: new[] { "world" }, channel: source, callerDetails: callerDetails); // Assert var evt = listener.Events.Find(e => e.EventId == 2000); @@ -116,9 +116,9 @@ public void Build_AddsEtwLogProcessor_AndWritesExpectedAttributes_FromInferenceC 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.CallerIdKey).GetString()); - Assert.AreEqual("Inference Caller", attrsElement.GetProperty(OpenTelemetryConstants.CallerNameKey).GetString()); - Assert.AreEqual("infcaller@example.com", attrsElement.GetProperty(OpenTelemetryConstants.CallerUpnKey).GetString()); + Assert.AreEqual("inf-caller-id", attrsElement.GetProperty(OpenTelemetryConstants.UserIdKey).GetString()); + Assert.AreEqual("Inference Caller", attrsElement.GetProperty(OpenTelemetryConstants.UserNameKey).GetString()); + Assert.AreEqual("infcaller@example.com", attrsElement.GetProperty(OpenTelemetryConstants.UserEmailKey).GetString()); Assert.AreEqual("10.0.0.50", attrsElement.GetProperty(OpenTelemetryConstants.CallerClientIpKey).GetString()); } @@ -135,11 +135,11 @@ public void Build_AddsEtwLogProcessor_AndWritesExpectedAttributes_FromToolCall() var toolDetails = new ToolCallDetails("tool-a", arguments: @"{ ""arg"": 1 }", toolCallId: "tool-call-1", description: "desc", toolType: "function"); string conversationId = "conv-tool-1"; string responseContent = @"{ ""value"": ""result"" }"; - var source = new SourceMetadata(id: "src-id", name: "ChannelInf", role: Role.Human, description: "https://channel/inf"); + var source = new Channel(name: "ChannelInf", link: "https://channel/inf"); var callerDetails = new CallerDetails(callerId: "tool-caller-id", callerName: "Tool Caller", callerUpn: "toolcaller@example.com", tenantId: "tool-caller-tenant"); // Act - logger.LogToolCall(toolDetails, agentDetails, tenantDetails, conversationId, responseContent: responseContent, sourceMetadata: source, callerDetails: callerDetails); + logger.LogToolCall(toolDetails, agentDetails, tenantDetails, conversationId, responseContent: responseContent, channel: source, callerDetails: callerDetails); // Assert var evt = listener.Events.Find(e => e.EventId == 2000); @@ -169,9 +169,9 @@ public void Build_AddsEtwLogProcessor_AndWritesExpectedAttributes_FromToolCall() 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.CallerIdKey).GetString()); - Assert.AreEqual("Tool Caller", attrsElement.GetProperty(OpenTelemetryConstants.CallerNameKey).GetString()); - Assert.AreEqual("toolcaller@example.com", attrsElement.GetProperty(OpenTelemetryConstants.CallerUpnKey).GetString()); + Assert.AreEqual("tool-caller-id", attrsElement.GetProperty(OpenTelemetryConstants.UserIdKey).GetString()); + Assert.AreEqual("Tool Caller", attrsElement.GetProperty(OpenTelemetryConstants.UserNameKey).GetString()); + Assert.AreEqual("toolcaller@example.com", attrsElement.GetProperty(OpenTelemetryConstants.UserEmailKey).GetString()); } [TestMethod] 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 f400b75a..8776aafe 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 @@ -76,16 +76,16 @@ public void Start_SetsConversationId_WhenProvided() Util.GetTenantDetails(), parentContext: null, conversationId: conversationId, - sourceMetadata: null); + channel: null); }); activity.ShouldHaveTag(OpenTelemetryConstants.GenAiConversationIdKey, conversationId); } [TestMethod] - public void Start_SetsSourceMetadata_Tags() + public void Start_SetsChannel_Tags() { - var metadata = new SourceMetadata(id: "tool-src", name: "ChannelY", role: Role.Agent, description: "https://channel/link/y"); + var metadata = new Channel(name: "ChannelY", link: "https://channel/link/y"); var activity = ListenForActivity(() => { @@ -95,11 +95,11 @@ public void Start_SetsSourceMetadata_Tags() Util.GetTenantDetails(), parentContext: null, conversationId: null, - sourceMetadata: metadata); + channel: metadata); }); activity.ShouldHaveTag(OpenTelemetryConstants.ChannelNameKey, metadata.Name!); - activity.ShouldHaveTag(OpenTelemetryConstants.ChannelLinkKey, metadata.Description!); + activity.ShouldHaveTag(OpenTelemetryConstants.ChannelLinkKey, metadata.Link!); } [TestMethod] @@ -124,7 +124,7 @@ public void ThreatDiagnosticsSummary_IsSetCorrectly_WhenProvided() tenantDetails, parentContext: null, conversationId: null, - sourceMetadata: null, + channel: null, threatDiagnosticsSummary: threatSummary); }); @@ -149,7 +149,7 @@ public void ThreatDiagnosticsSummary_IsNotSet_WhenNull() tenantDetails, parentContext: null, conversationId: null, - sourceMetadata: null, + channel: null, threatDiagnosticsSummary: null); }); @@ -229,9 +229,9 @@ public void Start_SetsCallerDetails_WhenProvided() }); // Assert - activity.ShouldHaveTag(OpenTelemetryConstants.CallerIdKey, callerDetails.CallerId); - activity.ShouldHaveTag(OpenTelemetryConstants.CallerNameKey, callerDetails.CallerName); - activity.ShouldHaveTag(OpenTelemetryConstants.CallerUpnKey, callerDetails.CallerUpn); + activity.ShouldHaveTag(OpenTelemetryConstants.UserIdKey, callerDetails.CallerId); + activity.ShouldHaveTag(OpenTelemetryConstants.UserNameKey, callerDetails.CallerName); + activity.ShouldHaveTag(OpenTelemetryConstants.UserEmailKey, callerDetails.CallerUpn); activity.ShouldHaveTag(OpenTelemetryConstants.CallerClientIpKey, callerDetails.CallerClientIP!.ToString()); } 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 f9a1f4a6..9cb1b0ad 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 @@ -156,20 +156,20 @@ public void Start_SetsConversationId_WhenProvided() Util.GetTenantDetails(), parentContext: null, conversationId: conversationId, - sourceMetadata: null); + channel: null); }); activity.ShouldHaveTag(OpenTelemetryConstants.GenAiConversationIdKey, conversationId); } [TestMethod] - public void Start_SetsSourceMetadata_Tags() + public void Start_SetsChannel_Tags() { var details = new InferenceCallDetails( InferenceOperationType.Chat, "gpt-4o", "openai"); - var metadata = new SourceMetadata(id: "src-id", name: "ChannelZ", role: Role.Human, description: "https://channel/link/z"); + var metadata = new Channel(name: "ChannelZ", link: "https://channel/link/z"); var activity = ListenForActivity(() => { @@ -179,11 +179,11 @@ public void Start_SetsSourceMetadata_Tags() Util.GetTenantDetails(), parentContext: null, conversationId: null, - sourceMetadata: metadata); + channel: metadata); }); activity.ShouldHaveTag(OpenTelemetryConstants.ChannelNameKey, metadata.Name!); - activity.ShouldHaveTag(OpenTelemetryConstants.ChannelLinkKey, metadata.Description!); + activity.ShouldHaveTag(OpenTelemetryConstants.ChannelLinkKey, metadata.Link!); } [TestMethod] @@ -230,9 +230,9 @@ public void Start_SetsCallerDetails_WhenProvided() }); // Assert - activity.ShouldHaveTag(OpenTelemetryConstants.CallerIdKey, callerDetails.CallerId); - activity.ShouldHaveTag(OpenTelemetryConstants.CallerNameKey, callerDetails.CallerName); - activity.ShouldHaveTag(OpenTelemetryConstants.CallerUpnKey, callerDetails.CallerUpn); + activity.ShouldHaveTag(OpenTelemetryConstants.UserIdKey, callerDetails.CallerId); + activity.ShouldHaveTag(OpenTelemetryConstants.UserNameKey, callerDetails.CallerName); + activity.ShouldHaveTag(OpenTelemetryConstants.UserEmailKey, callerDetails.CallerUpn); activity.ShouldHaveTag(OpenTelemetryConstants.CallerClientIpKey, callerDetails.CallerClientIP!.ToString()); } 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 93f9b4c9..3e261514 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 @@ -142,11 +142,11 @@ public void Start_WithCustomStartAndEndTime_SetsActivityTimes() } [TestMethod] - public void Start_SetsConversationIdSourceMetadataAndCallerDetails_WhenProvided() + public void Start_SetsConversationIdChannelAndCallerDetails_WhenProvided() { // Arrange var conversationId = "conv-output-123"; - var metadata = new SourceMetadata(id: "src-id", name: "ChannelOutput", role: Role.Human, description: "https://channel/output"); + var metadata = new Channel(name: "ChannelOutput", link: "https://channel/output"); var callerDetails = new CallerDetails( callerId: "caller-output-123", callerName: "Output Caller", @@ -166,7 +166,7 @@ public void Start_SetsConversationIdSourceMetadataAndCallerDetails_WhenProvided( response, parentContext: null, conversationId: conversationId, - sourceMetadata: metadata, + channel: metadata, callerDetails: callerDetails); }); @@ -175,12 +175,12 @@ public void Start_SetsConversationIdSourceMetadataAndCallerDetails_WhenProvided( // Assert - source metadata activity.ShouldHaveTag(OpenTelemetryConstants.ChannelNameKey, metadata.Name!); - activity.ShouldHaveTag(OpenTelemetryConstants.ChannelLinkKey, metadata.Description!); + activity.ShouldHaveTag(OpenTelemetryConstants.ChannelLinkKey, metadata.Link!); // Assert - caller details - activity.ShouldHaveTag(OpenTelemetryConstants.CallerIdKey, callerDetails.CallerId); - activity.ShouldHaveTag(OpenTelemetryConstants.CallerNameKey, callerDetails.CallerName); - activity.ShouldHaveTag(OpenTelemetryConstants.CallerUpnKey, callerDetails.CallerUpn); + activity.ShouldHaveTag(OpenTelemetryConstants.UserIdKey, callerDetails.CallerId); + activity.ShouldHaveTag(OpenTelemetryConstants.UserNameKey, callerDetails.CallerName); + activity.ShouldHaveTag(OpenTelemetryConstants.UserEmailKey, callerDetails.CallerUpn); activity.ShouldHaveTag(OpenTelemetryConstants.CallerClientIpKey, callerDetails.CallerClientIP!.ToString()); }