Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public override async Task<ChatResponse> GetResponseAsync(

// A single request into this GetResponseAsync may result in multiple requests to the inner client.
// Create an activity to group them together for better observability.
using Activity? activity = _activitySource?.StartActivity($"{nameof(FunctionInvokingChatClient)}.{nameof(GetResponseAsync)}");
using Activity? activity = _activitySource?.StartActivity(OpenTelemetryConsts.GenAI.OrchestrateToolsName);

// Copy the original messages in order to avoid enumerating the original messages multiple times.
// The IEnumerable can represent an arbitrary amount of work.
Expand Down Expand Up @@ -408,7 +408,7 @@ public override async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseA

// A single request into this GetStreamingResponseAsync may result in multiple requests to the inner client.
// Create an activity to group them together for better observability.
using Activity? activity = _activitySource?.StartActivity($"{nameof(FunctionInvokingChatClient)}.{nameof(GetStreamingResponseAsync)}");
using Activity? activity = _activitySource?.StartActivity(OpenTelemetryConsts.GenAI.OrchestrateToolsName);
UsageDetails? totalUsage = activity is { IsAllDataRequested: true } ? new() : null; // tracked usage across all turns, to be used for activity purposes

// Copy the original messages in order to avoid enumerating the original messages multiple times.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static class GenAI
public const string ChatName = "chat";
public const string EmbeddingsName = "embeddings";
public const string ExecuteToolName = "execute_tool";
public const string OrchestrateToolsName = "orchestrate_tools"; // Non-standard
public const string GenerateContentName = "generate_content";

public const string SystemInstructions = "gen_ai.system_instructions";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,11 +678,11 @@ public async Task FunctionInvocationTrackedWithActivity(bool enableTelemetry, bo
Func<ChatClientBuilder, ChatClientBuilder> configure = b => b.Use(c =>
new FunctionInvokingChatClient(new OpenTelemetryChatClient(c, sourceName: sourceName) { EnableSensitiveData = enableSensitiveData }));

await InvokeAsync(() => InvokeAndAssertAsync(options, plan, configurePipeline: configure), streaming: false);
await InvokeAsync(() => InvokeAndAssertAsync(options, plan, configurePipeline: configure));

await InvokeAsync(() => InvokeAndAssertStreamingAsync(options, plan, configurePipeline: configure), streaming: true);
await InvokeAsync(() => InvokeAndAssertStreamingAsync(options, plan, configurePipeline: configure));

async Task InvokeAsync(Func<Task> work, bool streaming)
async Task InvokeAsync(Func<Task> work)
{
var activities = new List<Activity>();
using TracerProvider? tracerProvider = enableTelemetry ?
Expand All @@ -700,7 +700,7 @@ async Task InvokeAsync(Func<Task> work, bool streaming)
activity => Assert.Equal("chat", activity.DisplayName),
activity => Assert.Equal("execute_tool Func1", activity.DisplayName),
activity => Assert.Equal("chat", activity.DisplayName),
activity => Assert.Equal(streaming ? "FunctionInvokingChatClient.GetStreamingResponseAsync" : "FunctionInvokingChatClient.GetResponseAsync", activity.DisplayName));
activity => Assert.Equal("orchestrate_tools", activity.DisplayName));

var executeTool = activities[1];
if (enableSensitiveData)
Expand Down
Loading