Skip to content

Document telemetry resource attributes and runtime metrics - #592

Merged
kristin-kronstain-brown merged 2 commits into
mainfrom
kkb-kagent-3107-telemetry
Oct 14, 2026
Merged

kristin-kronstain-brown merged 2 commits into
mainfrom
kkb-kagent-3107-telemetry

Conversation

@kristin-kronstain-brown

Copy link
Copy Markdown
Contributor

Documents the user-facing telemetry changes from kagent-dev/kagent#3107 (first shipped in v1.0.0-alpha10).

What changed in kagent

  • The runtime identity moved to resource attributes: gen_ai.main_agent.id, gen_ai.main_agent.name, and kagent.runtime. The resource-level gen_ai.agent.* names are gone.
  • Agent runtimes can export the new gen_ai.invoke_agent.duration histogram over OTLP when otel.metrics.enabled is true.
  • A reference Collector values file was added at examples/observability/collector-values.yaml.

What this PR changes

  • Tracing: the correlation attributes table now says whether each attribute is on the span or on the resource, and adds gen_ai.main_agent.id. The search step shows both kinds of filter.
  • Metrics: new "Agent runtime metrics" section for gen_ai_invoke_agent_duration_seconds, its labels, and an example p95 query.
  • OTel stack and Lightweight OTel stack: turn on otel.metrics in the kagent Helm values, add it to the field table and the cleanup step, and point production readers to the reference Collector values.

Not verified

Nothing here was run on a cluster. To check it:

  1. Follow either OTel stack guide through the kagent telemetry step, including otel.metrics.enabled: true.
  2. Create a new Session and invoke the Agent.
  3. In Prometheus, run histogram_quantile(0.95, sum by (le, gen_ai_agent_name) (rate(gen_ai_invoke_agent_duration_seconds_bucket[5m]))). It should return data.
  4. In the tracing backend, open a runtime span for the same request. The span carries gen_ai.conversation.id, and the resource carries gen_ai.main_agent.id and kagent.runtime.

kagent-dev/kagent#3103 (same author, merged the day before, same source files) may be part of the same change and was not reviewed for this PR.

🤖 Generated with Claude Code

kagent-dev/kagent#3107 moved the runtime identity to resource attributes
(gen_ai.main_agent.*, kagent.runtime), added the gen_ai.invoke_agent.duration
metric behind otel.metrics.enabled, and added a reference Collector values
file. Update the tracing, metrics, and OTel stack pages to match.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Kristin Brown <kristin.brown@solo.io>
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Docs preview

Link Points at
Branch preview The newest push to this branch. Updates in place.
Commit preview 302953e only. Frozen.

Both are uploaded Worker versions and serve no production traffic.


The Agent Substrate `atecontroller` component reports the same `controller_runtime_*` and `workqueue_*` metrics for its own reconcilers. To keep the two apart in a query, filter by the scrape job, such as `job="kagent-controller-metrics"` in the OTel stack.

## Agent runtime metrics

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked whether this section should also carry alpha12's kagent.execute_tool.duration and kagent.client.inference.*. It should not: those exist only in telemetry/registry/ and the contract doc, with no Go emitting them yet. Scope here is right.


## Agent runtime metrics

Agent runtimes export metrics over OTLP when the kagent Helm release sets `otel.metrics.enabled` to `true`. The stack guides convert these OpenTelemetry metrics to Prometheus names in the collector.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude and codex are the only runtimes that report the histogram in this section, so it is worth saying before the table.

Suggested change
Agent runtimes export metrics over OTLP when the kagent Helm release sets `otel.metrics.enabled` to `true`. The stack guides convert these OpenTelemetry metrics to Prometheus names in the collector.
Agent runtimes export metrics over OTLP when the kagent Helm release sets `otel.metrics.enabled` to `true`. The `claude` and `codex` runtimes are the only ones that report the histogram in this section. The stack guides convert these OpenTelemetry metrics to Prometheus names in the collector.


| Metric | Type | Measures |
| ------ | ---- | -------- |
| `gen_ai_invoke_agent_duration_seconds` | Histogram | Time that one `invoke_agent` execution segment takes. kagent records this metric with every `invoke_agent` span that it opens. A collector can derive the same metric from runtime-owned `invoke_agent` spans before sampling. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InvocationDuration is constructed in one place, go/adk/pkg/a2a/server/tracing.go:59, inside if telemetry.Runtime.NativeHarness() — true only for claude and codex, covered by TestInvocationDurationOnlyForNativeHarnesses. On the default kagent runtime this metric and the p95 query never produce data. Your closing sentence already points at the workaround; this makes the opening agree with it.

Suggested change
| `gen_ai_invoke_agent_duration_seconds` | Histogram | Time that one `invoke_agent` execution segment takes. kagent records this metric with every `invoke_agent` span that it opens. A collector can derive the same metric from runtime-owned `invoke_agent` spans before sampling. |
| `gen_ai_invoke_agent_duration_seconds` | Histogram | Time that one `invoke_agent` execution segment takes. Only the `claude` and `codex` runtimes record it. The `kagent` runtime emits its own `invoke_agent` spans, so its wrapper stays a transport span and records no duration. For that runtime, derive the metric from those spans in the collector before sampling. |

Signed-off-by: Kristin Brown <kristin.brown@solo.io>
@kristin-kronstain-brown

Copy link
Copy Markdown
Contributor Author

Addressed feedback: 302953e

@kristin-kronstain-brown
kristin-kronstain-brown merged commit 4f86518 into main Oct 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants