Uh oh!
There was an error while loading. Please reload this page.
.NET: Add hosted agent observability sample - #5660
Conversation
Mirrors the Python sample added in microsoft#5608 for Foundry hosted agents. The .NET hosting library already wires OpenTelemetry automatically via Microsoft.Agents.AI.Foundry.Hosting (ApplyOpenTelemetry) plus Azure.AI.AgentServer.Core's AddAgentHostTelemetry, so no framework changes are needed. The sample is documentation plus a runnable artifact that produces an interesting span tree (invoke_agent / agent_invoke / chat / execute_tool). Adds Hosted-Observability under FoundryHostedAgents/responses with two small tools (GetCurrentLocation, GetWeather), agent.yaml / agent.manifest.yaml declaring OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT (the .NET equivalent of Python's ENABLE_SENSITIVE_DATA), Dockerfile + Dockerfile.contributor, .env.example and README explaining the .NET vs Python defaults. Project added to agent-framework-dotnet.slnx.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a .NET “Hosted-Observability” sample under Foundry hosted agents to mirror the Python observability sample and demonstrate OpenTelemetry span emission end-to-end.
Changes:
- Introduces a new hosted agent sample with two demo tools to generate an observable span tree.
- Adds Foundry agent configuration/manifest files enabling GenAI message content capture via OTel env var.
- Registers the new sample project in
agent-framework-dotnet.slnx.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Observability/agent.yaml | Defines hosted agent container config and env var for sensitive span content capture |
| dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Observability/agent.manifest.yaml | Adds manifest metadata and template configuration for deployment |
| dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Observability/README.md | Documents how instrumentation works in .NET and expected spans |
| dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Observability/Program.cs | Implements the sample agent, tools, and local credential behavior |
| dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Observability/HostedObservability.csproj | Adds the sample project targeting net10.0 with required references |
| dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Observability/Dockerfile.contributor | Contributor Docker workflow for ProjectReference builds |
| dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Observability/Dockerfile | End-user Docker workflow building via SDK image |
| dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Observability/.env.example | Documents required env vars for local runs and optional AI telemetry |
| dotnet/agent-framework-dotnet.slnx | Includes the new sample project in the solution explorer hierarchy |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Motivation and Context
PR #5608 added a Foundry hosted agent observability sample for Python. There was no equivalent under
dotnet/samples/04-hosting/FoundryHostedAgents/responses/. This adds parity coverage so .NET users discover the same scenario.Description
New sample
Hosted-Observabilitymirroring the layout ofHosted-LocalToolswith two demo tools (GetCurrentLocation,GetWeather) so a request produces a span tree covering agent invocation, the chat call, and tool execution.Key behavioural differences vs the Python sample called out in the README:
ENABLE_INSTRUMENTATIONMicrosoft.Agents.AI.Foundry.Hosting.ServiceCollectionExtensions.ApplyOpenTelemetryautomatically wraps the agent andAzure.AI.AgentServer.Core.AddAgentHostTelemetry()wires the OTLP exporter.ENABLE_SENSITIVE_DATA=trueOTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true(read byOpenTelemetryAgent.EnableSensitiveData).APPLICATIONINSIGHTS_CONNECTION_STRINGinjected by FoundrySo no framework changes were needed. The PR is samples plus a slnx entry only.
Files added under
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Observability/:HostedObservability.csprojProgram.csagent.yamlandagent.manifest.yamldeclaringOTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENTDockerfileandDockerfile.contributor.env.exampleREADME.mdexplaining the .NET vs Python differences and the expected span treeagent-framework-dotnet.slnxupdated to register the new project.Verification
dotnet build dotnet/agent-framework-dotnet.slnx --tl:off: 0 warnings, 0 errors.mcr.microsoft.com/dotnet/sdk:10.0,--verify-no-changes --verbosity diagnostic) on the new csproj: clean.Contribution Checklist