Skip to content
Merged
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
13 changes: 13 additions & 0 deletions develop-docs/sdk/telemetry/traces/modules/ai-agents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ Additional attributes on the span:
| `gen_ai.tool.call.arguments` | string | Arguments of the tool call (stringified). | `'{"max":10}'` |
| `gen_ai.tool.call.result` | string | Result of the tool call (stringified). | `"7"` |

## Derived by Relay

Relay sets these attributes during ingestion:

- `gen_ai.operation.type` is inferred from `gen_ai.operation.name` with a `sentry.op` fallback.
- `gen_ai.response.model` is set to `gen_ai.request.model` if not already present.
- `gen_ai.usage.total_tokens` is computed as `gen_ai.usage.input_tokens + gen_ai.usage.output_tokens`.
- `gen_ai.response.tokens_per_second` is computed as `gen_ai.usage.output_tokens` divided by the span duration.
- `gen_ai.context.window_size` is looked up from the model metadata registry by `gen_ai.response.model`.
- `gen_ai.context.utilization` is computed as `gen_ai.usage.total_tokens / gen_ai.context.window_size`.
- `gen_ai.cost.input_tokens`, `gen_ai.cost.output_tokens`, and `gen_ai.cost.total_tokens` are calculated from token counts and per-token pricing in the model registry.


**[0]:**

Span attributes only allow primitive data types (like `int`, `float`, `boolean`, `string`). This means you need to use a stringified version of a list of dictionaries. Do NOT set the object/array `[{"foo": "bar"}]` but rather the string `'[{"foo": "bar"}]'` (must be parsable JSON).
Expand Down
Loading