Attributing Agent Tool Calls to Named Users in Datadog and Grafana
Tag agent traces with human, agent, and credential identities to show whose authority acted.

Attributing agent tool calls to named users in Datadog and Grafana requires a composite identity linking the human initiator, agent, and downstream credential through every span. Standard traces show what happened but leave out whose authority made it possible. Instrumentation adds that missing context, and gateway records show whether the identity was verified and the action was allowed.
Why standard APM traces miss the most important fact about an agent action
A security engineer opens a Datadog or Grafana trace and finds the tool call that read sensitive data. The timing, service, and outcome are visible. But which person authorized it remains unclear. If the agent used a developer’s credentials or a shared service account, the receiving service records the token’s access without distinguishing between a person issuing the request and an agent acting during their session.
Datadog’s own research found that application logs could record an agent’s final API call without showing which prompt, retrieved content, or earlier tool result led to it. Sensitive data can pass through tool calls, RAG results, and system prompt content while the agent runs, where standard input/output monitoring cannot see it. In a multi-step run, disconnected spans leave the investigator with individual events but no reliable chain of authority.
What a complete attribution record actually contains
A composite identity separates three principals that a single user ID would blur together. The human initiator is the person whose session identity comes from an identity provider such as Okta, Microsoft Entra ID, or Google Workspace. The agent principal identifies the agent requesting the action. The downstream credential identifies the principal the receiving service actually authenticated. These are separate answers to separate questions.
This distinction also separates trace telemetry from audit evidence. Instrumented code emits telemetry, so a misconfigured or malicious agent may omit it or invent a user ID. An audit record instead needs platform-verified identity, an immutable and attributable record, and export to the security team’s SIEM. For a tool call, that record names the person, client, server, tool, and outcome.
Credential class is useful context, but it is not the credential principal itself. A tag saying Personal Access Token distinguishes an authentication method without, on its own, establishing whose credential the service accepted. The complete attribution record binds the human and agent identities to that downstream authority rather than treating any one of them as a substitute for the others.
How the OpenTelemetry GenAI conventions model agent and tool-call spans
OpenTelemetry’s GenAI conventions shipped their first standalone release, v0.1.0, on November 21, 2026. The conventions give the run a shared structure. An invoke_agent root contains chat <model> spans and execute_tool <name> spans, directly or through intermediate spans. Tool spans include gen_ai.tool.name, gen_ai.tool.call.id, and the tool type, with error.type required on error. Arguments and results remain opt-in, and content capture is off by default.
MCP conventions add client and server spans named {mcp.method.name} {target}. OpenTelemetry recommends these “instead of RPC semantic conventions” because they provide domain-specific context. However, conventions do not transport context by themselves. Instrumentation must inject it through the configured propagators into the MCP request’s params._meta property bag, which is required even when HTTP headers carry context. Without this, the agent and MCP server can produce traces that are not linked.
Identity is still a custom addition to this structure. No gen_ai.* attribute defines the verified human initiator, IdP-resolved identity, or policy decision. Also, every gen_ai.* attribute is still at Development status, and v0.1.0 had breaking renames. Teams that build attribution around these fields therefore need to plan for changes in both their names and their semantics.
Injecting the composite identity into Datadog traces
For Datadog instrumentation, begin with the distinction between organization and user credentials. DD-API-KEY identifies the organization. In the July 2026 comparison, DD-APPLICATION-KEY was scoped to its creator and could have authorization scopes, while Personal Access Tokens were user-scoped, short-lived, and scoped by default. Neither credential path automatically enforced or rotated credentials per agent session. The key owner is not necessarily the session user.
Add the IdP-resolved session identity to the invoke_agent root with the team-defined tag human.identity. Add agent.identity on its own and use credential.type to show whether the credential is a Personal Access Token, application key, or Workload Identity. These custom tags require separate identity verification. Propagate the identity context as baggage and attach the fields to every child span, including execute_tool spans. Inject W3C TraceContext into the MCP request metadata so the server span joins the agent trace.
Start that root span at session initialization, before the first user message. Coding agents can run repository-controlled code during context loading, before the user speaks. Datadog’s official MCP server also exposes write actions affecting dashboards, alert rules, and incidents, making attribution especially important for calls that change production state.
What the resulting audit records look like in Datadog
In Datadog’s trace view, the root span then shows human.identity, agent.identity, and credential.type. Child tool spans retain those tags, while the propagated trace ID connects the MCP server span to the same run. An access reviewer can follow the session’s tool calls in order and distinguish the named initiator from the agent and credential class.
That context also gives monitors and alerts a more useful frame. Datadog’s teams use AI Guard to record human and agent identities separately and detect atypical behavior within a session. Their research found that prompt injection matches or attempted exfiltration are stronger signals when linked to sensitive tool output and actions that come later. Changes in token usage, cost, or model activity add context when the combined behavior crosses a security boundary.
Content visibility remains a separate instrumentation choice. Datadog found that system prompts made up most of the input token volume and were the largest prompt injection attack surface, so prompt content, even hashed, helps with an audit. None of these trace fields proves that the IdP verified the identity at call time, that policy permitted the action, or that the record is immutable. Those are different kinds of evidence.
Injecting the composite identity into Grafana traces
For Grafana, use the same identity fields and MCP context propagation, but build against OpenTelemetry directly. Grafana’s stack uses Tempo for traces, Loki for logs, and Mimir for metrics, with native OTLP ingestion. It lacks a native AI agent observability layer that supplies the attribution work. The application must emit the GenAI span structure and populate its custom identity attributes.
Add the human identity, agent identity, and credential type as resource or span attributes, then carry that context through child tool calls. A resource identity is queried as resource.human.identity, while a tool span’s name is queried as span.gen_ai.tool.name. Tempo’s TraceQL can filter on those fields only if instrumentation actually supplied them.
Grafana Alerting can use metric queries derived from span attributes to detect a named user’s agent exceeding a tool-call rate, accessing a sensitive tool type, or triggering an error sequence. Loki can correlate MCP server logs with Tempo through the propagated trace ID, including arguments and results when those logs contain them. Because the GenAI attributes are still at Development status, teams should version-pin their OpenTelemetry collector configuration and plan for dashboard and alert-rule updates they may need.
What the resulting audit records look like in Grafana
In Grafana Explore, a correctly instrumented Tempo trace shows the invoke_agent root with the human, agent, and credential fields. Its child execute_tool spans also contain gen_ai.tool.name and gen_ai.tool.call.id. The MCP server span appears in that same trace. The investigator no longer has to treat it as an unrelated event.
An access-review query can combine resource.human.identity = "alice@example.com" with span.gen_ai.tool.name = "write_dashboard" across a time window. That pattern retrieves write-action tool calls attributed to the named user, provided identity was stored at the resource level. A dashboard panel driven by a Tempo metrics query can count execute_tool spans grouped by human.identity and gen_ai.tool.name. The tracing data already present yields a named-user tool-call heatmap.
At this point, Grafana and Datadog can produce equivalent trace records from the same conventions and custom fields. Datadog adds AI Guard for behavioral monitoring, while Grafana requires that layer externally. On its own, neither platform can turn the identity it was given into gateway-verified evidence.
Why trace instrumentation alone cannot close the attribution gap
The tracing work is necessary for investigation, but governed access needs a separate source of authority. Instrumentation depends on the agent cooperating. Unapproved MCP servers outside central governance can leave no governed trace, and a shared service account gives the IdP no person to resolve.
Datadog’s research shows how the timing of checks can change whether data is exposed. An ordinary request to a customer support agent could trigger a tool call reaching payment information before authorization checks engaged. A trace helps explain that failure afterward, but only a check before execution can prevent the exposure.
That check belongs on the request path. It requires role-based policy evaluation, argument scanning, and hash-pinned tool descriptions before execution, with result scanning before returned content reaches the model. It also requires an immutable record the agent cannot skip or falsify.
Where an MCP gateway sits relative to Datadog and Grafana in the attribution stack

An MCP gateway gives the agent one MCP server to connect to while keeping connections to upstream servers. It resolves the session to a person or agent identity in the IdP and acts as the OAuth client to upstream services. This places enforcement before execution for calls routed through it. The gateway complements traces.
Before allowing a call, the gateway checks the caller’s role against the server, tool, and arguments, scans arguments for secrets and personal data, and checks tool descriptions pinned by hash for drift. After execution, it scans results for sensitive data and prompt injection before the model reads them. It writes an immutable record naming the person, client, server, tool, and outcome. That record is the verified counterpart to application telemetry.
Gateway-emitted OpenTelemetry spans can provide verified composite identity fields as resource attributes in Datadog APM or Tempo. Structured audit events stream to the SIEM and can reach Datadog Log Management or Loki for correlation by trace ID. The propagated context binds those events to the agent’s run. Managed options in the notes include Microsoft Azure API Management for MCP and AWS AgentCore Gateway, both generally available in 2025, and Google Agent Gateway, generally available in June 2026. Per-call checks add latency across multi-step runs, but that is the explicit trade-off for pre-call enforcement.
What the complete attribution picture looks like when traces and gateway records are combined
With both layers operating, the investigation can distinguish what the agent reported from what the gateway verified. In Datadog, the application’s root span keeps the identity it was given, while the gateway span has the IdP-verified identity for the call. A monitor can alert when they diverge. In Grafana, the shared trace ID brings agent and gateway spans into the same Tempo trace view, with arguments and results where captured.
Access reviews can then filter on verified human.identity across agents, use gen_ai.tool.name to inspect sensitive tools, and examine the gateway’s policy.decision field. The SIEM stream also exposes attempted calls the gateway blocked, including attempts absent from agent-emitted traces. Datadog’s AI-BOM inventory pattern shows who owns the components and how they fit together by mapping agents, model versions, tools, and connected services to the gateway registry. Server and tool names link each call back to that inventory.
Output evaluation, cost attribution, and how real-time blocking works are still separate concerns. The attribution payoff is a sequence the investigator can reconstruct. A prompt injection match in a system prompt span can connect to a sensitive execute_tool span and then to anomalous downstream data access in the SIEM. With the verified person, agent, and credential linked to that chain, events once spread across separate systems form an attack sequence that an investigator can follow.


