Skip to content

Commit dbda794

Browse files
authored
Merge pull request #74 from microsoft/aaronpowell/issue68
Fix tracing for Azure AI Foundry and update deployment script
2 parents bb4ff5f + 2f2315f commit dbda794

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

infra/deploy.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ if [ -f "$CSHARP_PROJECT_PATH" ]; then
9696
dotnet user-secrets set "Parameters:ResourceGroupName" "$RESOURCE_GROUP_NAME" --project "$CSHARP_PROJECT_PATH"
9797
dotnet user-secrets set "Parameters:ApplicationInsightsName" "$APPLICATION_INSIGHTS_NAME" --project "$CSHARP_PROJECT_PATH"
9898
dotnet user-secrets set "Azure:ResourceGroup" "$RESOURCE_GROUP_NAME" --project "$CSHARP_PROJECT_PATH"
99-
dotnet user-secrets set "Azure:Location" "$AZURE_LOCATION" --project "$CSHARP_PROJECT_PATH"
100-
dotnet user-secrets set "Azure:SubscriptionId" "$AZURE_SUBSCRIPTION_ID" --project "$CSHARP_PROJECT_PATH"
99+
dotnet user-secrets set "Azure:Location" "$RG_LOCATION" --project "$CSHARP_PROJECT_PATH"
100+
dotnet user-secrets set "Azure:SubscriptionId" "$SUBSCRIPTION_ID" --project "$CSHARP_PROJECT_PATH"
101101
dotnet user-secrets set "Parameters:UniqueSuffix" "$UNIQUE_SUFFIX" --project "$CSHARP_PROJECT_PATH"
102102
fi
103103

src/csharp/McpAgentWorkshop.ServiceDefaults/Extensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder) w
6363
.AddHttpClientInstrumentation()
6464
.AddRuntimeInstrumentation()
6565
.AddMeter("Experimental.ModelContextProtocol")
66+
.AddMeter("McpAgentWorkshop.WorkshopApi")
6667
.AddMeter("McpAgentWorkshop.McpServer")
6768
.AddMeter("Experimental.Microsoft.Extensions.AI")
6869
.AddMeter("Azure.AI.Agents.Persistent.PersistentAgentsClient");
@@ -80,6 +81,7 @@ public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder) w
8081
//.AddGrpcClientInstrumentation()
8182
.AddHttpClientInstrumentation()
8283
.AddSource("Experimental.ModelContextProtocol")
84+
.AddSource("McpAgentWorkshop.WorkshopApi")
8385
.AddSource("McpAgentWorkshop.McpServer")
8486
.AddSource("Experimental.Microsoft.Extensions.AI")
8587
.AddSource("Azure.AI.Agents.Persistent.PersistentAgentsClient");

src/csharp/McpAgentWorkshop.WorkshopApi/Services/AgentService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.ClientModel;
2+
using System.Diagnostics;
23
using System.Runtime.CompilerServices;
34
using Azure.AI.Agents.Persistent;
45
using McpAgentWorkshop.WorkshopApi.Models;
@@ -18,6 +19,8 @@ public partial class AgentService(
1819

1920
public async Task InitialiseAgentAsync()
2021
{
22+
using var activity = Diagnostics.ActivitySource.StartActivity(name: "Zava Agent Initialization");
23+
2124
logger.LogInformation("Creating new agent: {AgentName}", AgentName);
2225

2326
var instructions = Path.Combine(sharedPath, "instructions", InstructionsFile);
@@ -82,7 +85,7 @@ public async IAsyncEnumerable<ChatResponse> ProcessChatMessageAsync(ChatRequest
8285
request.Message;
8386
var spanName = $"Zava Agent Chat Request: {messagePreview}";
8487

85-
using var activity = Diagnostics.ActivitySource.StartActivity(spanName);
88+
using var activity = Diagnostics.ActivitySource.StartActivity(spanName, ActivityKind.Server);
8689

8790
PersistentAgentThread sessionThread;
8891
AsyncCollectionResult<StreamingUpdate>? runStream = null;

src/csharp/McpAgentWorkshop.WorkshopApi/WorkshopHost.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@
4747
return fileInfo is not null ? TypedResults.File(fileInfo) : Results.NotFound();
4848
});
4949

50+
await app.StartAsync();
51+
5052
var agentService = app.Services.GetRequiredService<AgentService>();
5153
await agentService.InitialiseAgentAsync();
5254

53-
app.Run();
55+
await app.WaitForShutdownAsync();

0 commit comments

Comments
 (0)