-
Notifications
You must be signed in to change notification settings - Fork 513
feat: Tracing and Instrumentation #2309
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
Draft
marklysze
wants to merge
17
commits into
main
Choose a base branch
from
feat/tracing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This comment has been minimized.
This comment has been minimized.
…port to ClickHouse
Codecov Report❌ Patch coverage is
... and 20 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
This WIP PR introduces OpenTelemetry-based distributed tracing for AG2 multi-agent conversations. It enables observability into agent workflows, LLM calls, tool executions, and human-in-the-loop interactions.
Approach
OpenTelemetry GenAI Semantic Conventions
The implementation follows the OpenTelemetry GenAI Semantic Conventions with AG2-specific extensions. This ensures compatibility with standard observability tools (Grafana, Jaeger, Honeycomb, etc.) while capturing AG2-specific context.
Trace Hierarchy
Instrumentation Points
conversationconversationinitiate_chat,a_initiate_chat,run_chat,a_run_chatagentinvoke_agentgenerate_reply,a_generate_reply, remote A2A callsllmchatOpenAIWrapper.create()toolexecute_toolexecute_function,a_execute_functionspeaker_selectionspeaker_selectionhuman_inputawait_human_inputcode_executionexecute_codemulti_conversationinitiate_chatsCentral LLM Instrumentation
All LLM providers (OpenAI, Anthropic, Gemini, Bedrock, Mistral, etc.) are instrumented through a single point:
OpenAIWrapper.create(). This captures:Distributed Tracing (A2A)
For remote agents using the A2A protocol, trace context is automatically propagated via W3C Trace Context headers, enabling end-to-end traces across service boundaries.
Current API (WIP)
Standard Attributes (OTEL GenAI)
gen_ai.operation.name- Operation typegen_ai.agent.name- Agent namegen_ai.provider.name- LLM providergen_ai.request.model/gen_ai.response.modelgen_ai.usage.input_tokens/gen_ai.usage.output_tokensgen_ai.tool.name,gen_ai.tool.call.id,gen_ai.tool.call.argumentsgen_ai.input.messages/gen_ai.output.messagesAG2-Specific Extensions
ag2.span.type- Span classificationag2.speaker_selection.candidates/ag2.speaker_selection.selectedag2.human_input.prompt/ag2.human_input.responseag2.code_execution.exit_code/ag2.code_execution.outputag2.chats.count,ag2.chats.mode,ag2.chats.recipientsgen_ai.usage.cost- AG2 cost trackinggen_ai.conversation.id/gen_ai.conversation.turnsFiles
Note: This draft PR contains temporary files under the root tracing folder that you can use to test out the implementation.
autogen/instrumentation.pyautogen/tracing/utils.pytracing/TRACING.mdtracing/OTEL_GENAI_CONVENTION_AG2.mdtracing/agents/*.pytracing/docker-compose.yamlLocal Testing
Status
DRAFT - Open for feedback! Please feel free to provide suggestions for the approach, in particular the API design.
Tracing examples
Related issue number
N/A
Checks