|
| 1 | +--- |
| 2 | +status: proposed |
| 3 | +contact: jpalvarezl |
| 4 | +date: 2026-09-09 |
| 5 | +deciders: [eavanvalkenburg, moonbox3] |
| 6 | +--- |
| 7 | + |
| 8 | +# Separate Foundry trace attribution from exporter configuration |
| 9 | + |
| 10 | +## Context and Problem Statement |
| 11 | + |
| 12 | +[Issue #7492](https://github.com/microsoft/agent-framework/issues/7492) reports |
| 13 | +client spans reaching Application Insights but missing from the Foundry agent |
| 14 | +trace view. Exporting telemetry and identifying the project/agent represented |
| 15 | +by an operation are separate concerns. |
| 16 | + |
| 17 | +The initial fix in [PR #7981](https://github.com/microsoft/agent-framework/pull/7981) |
| 18 | +resolved project identity only through `FoundryAgent.configure_azure_monitor()`. |
| 19 | +That left applications configuring their own exporters without an attribution |
| 20 | +path. It also let optional identity-discovery failures abort usable export. |
| 21 | +Separately, recording the last child chat's response ID could assign an |
| 22 | +after-run provider's ID to the agent invocation. |
| 23 | + |
| 24 | +## Decision Drivers |
| 25 | + |
| 26 | +- Support application-managed exporters without reconfiguring global providers. |
| 27 | +- Keep identity scoped to the agent/project rather than a process-wide setting. |
| 28 | +- Preserve export when optional metadata discovery fails, with a visible warning. |
| 29 | +- Use the completed agent-owned operation for response identity. |
| 30 | +- Preserve public response-ID suppression, continuation, and usage semantics. |
| 31 | +- Do not generalize one successful root-span arrangement into a universal |
| 32 | + requirement that every application root carry project attributes. |
| 33 | + |
| 34 | +## Considered Options |
| 35 | + |
| 36 | +- **Helper-only discovery.** Simple, but couples identity to one exporter helper |
| 37 | + and leaves application-managed configurations unsupported. |
| 38 | +- **Automatic discovery on each run.** Convenient, but introduces implicit |
| 39 | + network work, latency, and failure handling into the invocation path. |
| 40 | +- **Explicit per-agent identity plus cached helper discovery.** Supports both |
| 41 | + setup styles without run-time discovery. Applications using their own |
| 42 | + exporters must supply the project ARM ID. |
| 43 | + |
| 44 | +## Decision Outcome |
| 45 | + |
| 46 | +Choose **explicit per-agent identity plus cached helper discovery**: |
| 47 | + |
| 48 | +- Add keyword-only `project_arm_id` to `RawFoundryAgent` and `FoundryAgent`. |
| 49 | + The full project ARM ID is validated at construction; it is not inferred from |
| 50 | + the data-plane endpoint or read implicitly from an environment variable. |
| 51 | +- `FoundryAgent` emits the project attribute alongside agent identity on its |
| 52 | + `invoke_agent` span, which may be nested beneath an application span. |
| 53 | +- The Azure Monitor helper discovers and caches identity only when no ID was |
| 54 | + supplied. Expected discovery/metadata errors log a warning and preserve |
| 55 | + export; unexpected programming errors and cancellation still propagate. |
| 56 | +- Capture response identity from the agent-owned chat result before conversion |
| 57 | + and after-run callbacks. In streaming, use the underlying final response, |
| 58 | + including finalizer-only metadata. Keep this private telemetry identity |
| 59 | + separate from the public response/continuation fields. |
| 60 | +- Consolidate invocation bookkeeping into one owner-scoped context state. |
| 61 | + Child chats can still contribute usage without choosing the agent's identity. |
| 62 | + |
| 63 | +The public SDK does not yet expose project identity directly |
| 64 | +([Azure/azure-sdk-for-python#48825](https://github.com/Azure/azure-sdk-for-python/issues/48825)). |
| 65 | +Connection-ID parsing remains a bounded discovery workaround, not a requirement |
| 66 | +for applications that already know their project ARM ID. |
| 67 | + |
| 68 | +Acceptance distinguishes local emission, Application Insights ingestion, and |
| 69 | +personal inspection of client spans in Foundry. Supported examples use full |
| 70 | +project ARM IDs; alternate formats and service-side legacy-key behavior are not |
| 71 | +new guarantees of this API. |
0 commit comments