Skip to content
Closed
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion examples/kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ The `transform/claude_code` processor in `otel-collector.yaml` fills part of the

* `claude_code.tool` becomes `execute_tool`, with `gen_ai.tool.name` taken from `tool_name` (minus the `mcp__<server>__` prefix)
* `claude_code.llm_request` becomes `chat`, with the model and token usage, cache reads and writes included
* the `Agent` tool's `subagent_type` becomes the call's `gen_ai.tool.call.arguments` when Claude Code runs with `OTEL_LOG_TOOL_DETAILS=1`

Tool arguments stay missing, since Claude Code doesn't put them on its spans. From `v1.0.0-alpha12` on, the runtime writes its own GenAI spans and marks its resource with `kagent.genai.producer`. The recipe skips those processes, so calls are never counted twice, and you can drop it from the Collector config.
Other tool arguments stay missing, since Claude Code doesn't put them on its spans. From `v1.0.0-alpha12` on, the runtime writes its own GenAI spans and marks its resource with `kagent.genai.producer`. The recipe skips those processes, so calls are never counted twice, and you can drop it from the Collector config.

## Clean up

Expand Down
3 changes: 2 additions & 1 deletion examples/kubernetes/otel-collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ data:
- set(span.attributes["gen_ai.usage.cache_read.input_tokens"], span.attributes["cache_read_tokens"]) where span.name == "claude_code.llm_request"
- set(span.attributes["gen_ai.usage.cache_write.input_tokens"], span.attributes["cache_creation_tokens"]) where span.name == "claude_code.llm_request"
- set(span.attributes["gen_ai.usage.output_tokens"], span.attributes["output_tokens"]) where span.name == "claude_code.llm_request"
- set(span.attributes["gen_ai.tool.call.arguments"], {"subagent_type":span.attributes["subagent_type"]}) where span.name == "claude_code.tool" and span.attributes["subagent_type"] != nil

filter/not_from_agentevals:
error_mode: ignore
Expand Down Expand Up @@ -104,7 +105,7 @@ spec:
app: otel-collector
annotations:
# bump to restart the Collector after editing the ConfigMap
config-revision: "2"
config-revision: "3"
spec:
containers:
- name: otelcol
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/otlp/kagent/v1.0.0-alpha9/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ Prompts:
| `claude_native_1turn_subagent.json` | Claude harness | 1 | Claude Code native spans only, with an `Agent` subagent. |
| `claude_native_2turn.json` | Claude harness | 2 | Claude Code native spans only. Spans with `session.id` export before kagent's `invoke_agent`. |
| `claude_recipe_2turn.json` | Claude harness | 2 | `transform/claude_code` from `examples/kubernetes/otel-collector.yaml` applied: tool calls by name without arguments, model calls with usage. |
| `claude_recipe_1turn_subagent.json` | Claude harness | 1 | `claude_native_1turn_subagent.json` with the same recipe applied: the `Agent` call has `{"subagent_type":"general-purpose"}` as its arguments, the subagent's tool calls stay inside the turn. |

Changes from the download:

* The `agentevals.*` resource attributes the download endpoint stamps are removed, since `agentevals.session_name` would override session keying.
* Written as compact JSON. Claude Code `tool.output` span event outputs are cut to 500 characters.
* `claude_recipe_2turn` was recorded with an earlier recipe that left out cache tokens. Its `claude_code.*` attributes are the output of today's recipe on Collector contrib 0.162.0. Ids, timestamps, parents and resources are as recorded.
* `claude_recipe_1turn_subagent` is `claude_native_1turn_subagent` sent through today's recipe on Collector contrib 0.162.0 (only `transform/claude_code` in the pipeline, file exporter). The empty `status` objects the Collector adds to spans without a status are removed. Nothing else differs from the native file but the `gen_ai.*` attributes the recipe adds.

Content: cluster namespaces, pod and service names, the agent system prompt and the answers. No credentials.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
{
"schema": "otel_core.truth/v1",
"fixture": "kagent/v1.0.0-alpha9/claude_recipe_1turn_subagent",
"source": "kagent 46fdd3d7 Claude harness, examples/kubernetes transform/claude_code applied by Collector contrib 0.162.0, Agent subagent",
"session_key": {
"kind": "conversation",
"value": "01a11b07-989c-75f1-a60f-369a2f489b92"
},
"turns": [
{
"user_text": "Use your tools to list the namespaces in this cluster, then tell me how many pods are running in the kagent namespace. Answer in two short sentences.",
"final_text": "I've launched an agent to query the Kubernetes cluster. It's running in the background and will report back with the namespaces and pod count shortly. count shortly.I'll help you query the Kubernetes cluster. First, let me fetch the schema for the k8s_get_resources tool.Now I'll make the two queries to get the namespaces and pod count.I got the namespaces successfully, but the pod query returned a very large result. Let me read the saved file to count the pods.Let me use bash to extract the pod count from the JSON file.Let me try a different approach using grep to count the pods.Perfect! I've successfully queried the Kubernetes cluster. Here's what I found:\n\n## Namespaces in the Cluster\n\nThe cluster has **10 namespaces**:\n\n1. **agentevals** - Active\n2. **ate-system** - Active\n3. **default** - Active\n4. **kagent** - Active (the target namespace)\n5. **kube-node-lease** - Active\n6. **kube-public** - Active\n7. **kube-system** - Active\n8. **local-path-storage** - Active\n9. **metallb-system** - Active\n10. **podcertificate-controller-system** - Active\n\n## Pods in the kagent Namespace\n\nThe **kagent namespace** is currently running **14 pods**.The cluster has 10 namespaces: agentevals, ate-system, default, kagent, kube-node-lease, kube-public, kube-system, local-path-storage, metallb-system, and podcertificate-controller-system. There are currently 14 pods running in the kagent namespace.",
"intermediate_texts": [],
"agents": [
"claude-test"
],
"tool_calls": [
{
"name": "ToolSearch",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Agent",
"args": {
"subagent_type": "general-purpose"
},
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "ToolSearch",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "k8s_get_resources",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "k8s_get_resources",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Read",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Read",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
},
{
"name": "Bash",
"args": null,
"result": null,
"is_error": false,
"error_type": null
}
],
"tokens": {
"input": 600357,
"output": 5602
},
"llm_calls": 28
}
],
"content_captured": true,
"tokens": {
"input": 600357,
"output": 5602
}
}