Skip to content

OTel GenAI Traces for Agent and Tool #6653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 12, 2025
Merged

OTel GenAI Traces for Agent and Tool #6653

merged 10 commits into from
Jun 12, 2025

Conversation

ekzhu
Copy link
Collaborator

@ekzhu ekzhu commented Jun 9, 2025

Add OTel GenAI traces:

  • create_agent
  • invoke_agnet
  • execute_tool

Introduces context manager helpers to create these traces. The helpers also serve as instrumentation points for other instrumentation libraries.

Resolves #6644

@ekzhu ekzhu changed the title OTel GenAI Traces OTel GenAI Traces for Agent and Tool Jun 9, 2025
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

Attention: Patch coverage is 70.00000% with 54 lines in your changes missing coverage. Please review.

Project coverage is 79.65%. Comparing base (892492f) to head (68db1e4).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...autogen-core/src/autogen_core/_telemetry/_genai.py 46.15% 35 Missing ⚠️
...utogen-ext/src/autogen_ext/tools/mcp/_workbench.py 57.14% 9 Missing ⚠️
...t/src/autogen_agentchat/agents/_base_chat_agent.py 87.69% 8 Missing ⚠️
...entchat/teams/_group_chat/_chat_agent_container.py 94.11% 1 Missing ⚠️
...xt/src/autogen_ext/agents/azure/_azure_ai_agent.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6653      +/-   ##
==========================================
- Coverage   79.78%   79.65%   -0.13%     
==========================================
  Files         228      229       +1     
  Lines       17054    17126      +72     
==========================================
+ Hits        13606    13642      +36     
- Misses       3448     3484      +36     
Flag Coverage Δ
unittests 79.65% <70.00%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ekzhu ekzhu requested a review from jackgerrits June 9, 2025 16:08
@ekzhu
Copy link
Collaborator Author

ekzhu commented Jun 9, 2025

@EItanya please take a look

Copy link
Contributor

@EItanya EItanya left a comment

Choose a reason for hiding this comment

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

These changes make sense to me overall, I am going to do dig deeper into the other instrumentation libraries now to make sure it makes sense in that context as well

Copy link
Contributor

@EItanya EItanya left a comment

Choose a reason for hiding this comment

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

My one major comment is about error.type attribute. That seems to be the only stable attribute in these spans. I'm not a Python expert, but can we capture the exception, add it, and then bubble it up?

@ekzhu
Copy link
Collaborator Author

ekzhu commented Jun 12, 2025

My one major comment is about error.type attribute. That seems to be the only stable attribute in these spans. I'm not a Python expert, but can we capture the exception, add it, and then bubble it up?

Yes, this is done. I added try-catch block to set the attribute if an error occurs.

Copy link
Contributor

@EItanya EItanya left a comment

Choose a reason for hiding this comment

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

These changes look great, I am going to test them out in kagent today :)

@ekzhu ekzhu merged commit e14fb8f into main Jun 12, 2025
64 of 65 checks passed
@ekzhu ekzhu deleted the ekzhu-otel-genai branch June 12, 2025 22:07
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.

OTel traces should follow semantic convention for GenAI
3 participants