-
Notifications
You must be signed in to change notification settings - Fork 363
fix(tracing): use a span processor to add custom span attributes #1104
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
Conversation
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 a custom span processor to propagate kagent-specific attributes to all tracing spans, including those created by auto-instrumentation libraries. The change ensures that user_id, task_id, and session_id attributes are automatically added to all spans in a request context.
- Introduces
KagentAttributesSpanProcessorthat reads attributes from OpenTelemetry context and applies them to spans - Registers the new span processor alongside the existing OTLP processor in the tracing configuration
- Refactors attribute setting in
_agent_executor.pyto use context variables instead of manually setting attributes on individual spans, and fixes a typo in the conversation ID attribute name
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| python/packages/kagent-core/src/kagent/core/tracing/_span_processor.py | Implements the new KagentAttributesSpanProcessor class and helper functions for managing kagent span attributes in the OpenTelemetry context |
| python/packages/kagent-core/src/kagent/core/tracing/_utils.py | Integrates the new span processor by registering it alongside the OTLP processor in both the existing and new TracerProvider code paths |
| python/packages/kagent-adk/src/kagent/adk/_agent_executor.py | Refactors to set attributes via context variables at the start of request handling instead of manually setting them on individual spans, and fixes the "gen_ai.converstation.id" typo to "gen_ai.conversation.id" |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
python/packages/kagent-core/src/kagent/core/tracing/_span_processor.py
Outdated
Show resolved
Hide resolved
f732faa to
69ab337
Compare
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
06d0ce4 to
bab2750
Compare
80e3107 to
d8fb212
Compare
ab682ed to
96da0f4
Compare
ee06296 to
76fc396
Compare
046cd7d to
60fb794
Compare
d1893a9 to
e926981
Compare
Signed-off-by: David Haifley <david.haifley@solo.io>
21fd721 to
f304951
Compare
Uh oh!
There was an error while loading. Please reload this page.