OpenAI auto instrumentation fix attributes#122
Merged
nikhilNava merged 4 commits intomainfrom Jan 21, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes attribute mapping issues in OpenAI auto-instrumentation to ensure proper telemetry data collection according to the observability schema.
Changes:
- Updated FunctionSpan attributes to use correct semantic convention keys (GEN_AI_TOOL_ARGS_KEY instead of GEN_AI_INPUT_MESSAGES_KEY, GEN_AI_EVENT_CONTENT instead of GEN_AI_OUTPUT_MESSAGES_KEY)
- Implemented input/output message capture mechanism from GenerationSpan to populate AgentSpan attributes
- Added tool_call_id tracking to link tool calls from GenerationSpan to FunctionSpan execution
- Added new integration test validating required attributes on invoke_agent spans
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| test_openai_trace_processor.py | Added comprehensive integration test to validate all required attributes on invoke_agent spans, including execution type, agent details, and input/output messages |
| utils.py | Fixed attribute keys in get_attributes_from_function_span_data; added helper functions to capture and track tool call IDs, input/output messages, and find ancestor agent spans |
| trace_processor.py | Added tracking dictionaries for agent spans, parent-child relationships, and pending tool calls; updated span processing to capture and propagate messages and tool call IDs; changed agent span attribute from GEN_AI_GRAPH_NODE_ID to GEN_AI_EXECUTION_TYPE_KEY |
| util.py | Added GEN_AI_CALLER_CLIENT_IP_KEY to COMMON_ATTRIBUTES list for proper telemetry collection |
...y-extensions-openai/microsoft_agents_a365/observability/extensions/openai/trace_processor.py
Outdated
Show resolved
Hide resolved
...servability-extensions-openai/microsoft_agents_a365/observability/extensions/openai/utils.py
Show resolved
Hide resolved
...servability-extensions-openai/microsoft_agents_a365/observability/extensions/openai/utils.py
Show resolved
Hide resolved
...servability-extensions-openai/microsoft_agents_a365/observability/extensions/openai/utils.py
Show resolved
Hide resolved
...servability-extensions-openai/microsoft_agents_a365/observability/extensions/openai/utils.py
Show resolved
Hide resolved
Contributor
|
@nikhilNava I've opened a new pull request, #125, to work on those changes. Once the pull request is ready, I'll request review from you. |
* Initial plan * Implement bounded size for _pending_tool_calls to prevent memory growth Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com> * Fix trailing empty line in test file Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
juliomenendez
previously approved these changes
Jan 21, 2026
Contributor
Author
|
@copilot - fix formatting my running |
Contributor
|
@nikhilNava I've opened a new pull request, #126, to work on those changes. Once the pull request is ready, I'll request review from you. |
* Initial plan * Fix formatting with ruff format Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
...servability-extensions-openai/microsoft_agents_a365/observability/extensions/openai/utils.py
Show resolved
Hide resolved
...y-extensions-openai/microsoft_agents_a365/observability/extensions/openai/trace_processor.py
Show resolved
Hide resolved
...y-extensions-openai/microsoft_agents_a365/observability/extensions/openai/trace_processor.py
Show resolved
Hide resolved
...y-extensions-openai/microsoft_agents_a365/observability/extensions/openai/trace_processor.py
Show resolved
Hide resolved
...servability-extensions-openai/microsoft_agents_a365/observability/extensions/openai/utils.py
Show resolved
Hide resolved
...servability-extensions-openai/microsoft_agents_a365/observability/extensions/openai/utils.py
Show resolved
Hide resolved
...servability-extensions-openai/microsoft_agents_a365/observability/extensions/openai/utils.py
Show resolved
Hide resolved
threddy
approved these changes
Jan 21, 2026
juliomenendez
approved these changes
Jan 21, 2026
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
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.
Task
For open ai auto instrumentation fix update the spanProcessor so the generated spans pass certification.
Aditionally ensure that on invoke span the input and outputs are string or list of strings
Solution
After the updates view the spans below
Invoke agent span
Execute tool span
Inference Span