-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: Otel instrumentation version 3 #3021
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
feat: Otel instrumentation version 3 #3021
Conversation
… use it consistently
…mentation settings
InstrumentationSettings
version 3 There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for OpenTelemetry instrumentation version 3, implementing a new configuration system for span naming and attribute schemas. The main purpose is to provide semantic span names (e.g., invoke_agent {name}
, execute_tool {name}
) and standardized gen_ai.*
attributes for better observability.
- Added
InstrumentationConfig
class to centralize span naming and attribute configuration across versions - Updated span naming patterns for v3+ with semantic naming conventions
- Migrated attribute schemas to use standardized
gen_ai.*
format for v3+
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
pydantic_ai_slim/pydantic_ai/_instrumentation.py | New file implementing InstrumentationConfig class for version-specific span naming and attributes |
pydantic_ai_slim/pydantic_ai/models/instrumented.py | Updated version type annotation to include version 3 and changed default to use constant |
pydantic_ai_slim/pydantic_ai/agent/init.py | Updated agent run span creation to use versioned configuration |
pydantic_ai_slim/pydantic_ai/_tool_manager.py | Modified tool execution spans to use versioned naming and attributes |
pydantic_ai_slim/pydantic_ai/_output.py | Updated output function spans to use versioned configuration |
pydantic_ai_slim/pydantic_ai/_run_context.py | Added instrumentation version field to RunContext |
pydantic_ai_slim/pydantic_ai/_agent_graph.py | Updated to pass instrumentation version to run context |
tests/test_logfire.py | Comprehensive test updates with version 3 test cases and expected span names/attributes |
tests/models/test_fallback.py | Added gen_ai.agent.name attribute to test expectations |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…attributes lookup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Thanks @alexmojaki legend. |
Fixes #2964
Key Changes:
InstrumentationNames
class - Centralizes span naming and attribute configuration for different instrumentation versions (v2 vs v3+)InstrumentationSettings
. These could potentially be staticmethods inInstrumentationSettings
. Feel free to suggest changing to this if it feels more appropriate.invoke_agent {name}
andexecute_tool {name}
vs v2's generic namesgen_ai.*
attributes (e.g.,gen_ai.agent.name
,gen_ai.tool.call.arguments
)