Skip to content

Wire telemetry into the framework#195

Merged
anbuzin merged 5 commits into
mainfrom
telemetry-wiring
Jul 9, 2026
Merged

Wire telemetry into the framework#195
anbuzin merged 5 commits into
mainfrom
telemetry-wiring

Conversation

@anbuzin

@anbuzin anbuzin commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Instruments the framework using the telemetry system implemented in #194 .

uv run examples/agents/telemetry.py

@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ai-python Ready Ready Preview, Comment Jul 9, 2026 5:44pm

Comment thread src/ai/agents/agent.py
Comment thread src/ai/agents/agent.py Outdated
Comment thread src/ai/agents/agent.py
Comment on lines +719 to +725
if res.results:
data.result = res.results[0].result
data.is_error = any(p.is_error for p in res.results)
# A tool exception is caught and converted to an error
# result before it reaches this block, so it never hits the
# span's own except path — thread it through explicitly.
sp.error = res.exception

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.

Sigh, filling in the data object like this after already creating it and passing it to the span does seem pretty ugly to me, now that I look at it.

It's better than otel's sp.add_attribute("result", res.results[0].result) but I think that needing to save data to a variable and then updating it there and depending on the span holding a reference to it instead of making a copy is a little smelly.

I added https://github.com/vercel-labs/ai-python/pull/194/changes#r3548140961 comment based on this thought. I think we should make that improvement but we don't actually need to update this PR to fully take advantage of it right now.

Base automatically changed from telemetry-core to main July 9, 2026 17:19
@anbuzin
anbuzin force-pushed the telemetry-wiring branch from 7e9f9bd to 6221a23 Compare July 9, 2026 17:41
Co-authored-by: Michael J. Sullivan <sully@msully.net>
@anbuzin
anbuzin merged commit b74710c into main Jul 9, 2026
7 checks passed
@anbuzin
anbuzin deleted the telemetry-wiring branch July 9, 2026 17:47
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