Add A365-specific OpenAI Agents SDK instrumentor#132
Merged
hectorhdzg merged 2 commits intoMay 12, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a bundled, A365-specific OpenAI Agents SDK instrumentor and wires the distro to use it when enable_a365=True, so emitted spans follow A365’s expected envelope/message formats and attributes (e.g., custom.parent.span.id, per-message indexing, handoff parent IDs).
Changes:
- Introduces a new
A365OpenAIAgentsInstrumentor+OpenAIAgentsTraceProcessor+ message-mapping utilities undersrc/microsoft/opentelemetry/_genai/_openai_agents/. - Updates distro instrumentation setup to select the bundled instrumentor for
openai_agentswhen A365 is enabled. - Adds unit + integration tests plus documentation updates describing the dual-instrumentor behavior.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/openai_agents/test_utils.py | Unit tests for new OpenAI Agents utility helpers. |
| tests/openai_agents/test_trace_processor.py | Unit tests for the new OpenAI Agents trace processor behavior. |
| tests/openai_agents/test_trace_instrumentor.py | Unit tests for the new A365 OpenAI Agents instrumentor registration logic. |
| tests/openai_agents/test_message_mapper.py | Unit tests for mapping raw OpenAI/Agents message shapes into A365 versioned message envelopes. |
| tests/openai_agents/integration/test_openai_agents_trace_processor.py | Integration tests against real OpenAI/Azure OpenAI for end-to-end span assertions. |
| tests/openai_agents/integration/conftest.py | Integration fixtures for OpenAI/Azure OpenAI env configuration + marker registration. |
| tests/openai_agents/integration/init.py | Marks integration tests package. |
| tests/openai_agents/init.py | Marks openai_agents tests package. |
| src/microsoft/opentelemetry/_genai/_openai_agents/_utils.py | Core attribute extraction helpers for Agents/Response/ChatCompletions span data. |
| src/microsoft/opentelemetry/_genai/_openai_agents/_trace_processor.py | New processor translating OpenAI Agents spans into OTel spans enriched with A365 attributes. |
| src/microsoft/opentelemetry/_genai/_openai_agents/_trace_instrumentor.py | New BaseInstrumentor registering the A365 trace processor with the Agents SDK. |
| src/microsoft/opentelemetry/_genai/_openai_agents/_message_mapper.py | Maps raw gen_ai.input/output.messages JSON into A365 versioned message envelopes. |
| src/microsoft/opentelemetry/_genai/_openai_agents/_constants.py | New constants for span kind keys and message-attribute subkeys used by the Agents bridge. |
| src/microsoft/opentelemetry/_genai/_openai_agents/init.py | Declares the new package. |
| src/microsoft/opentelemetry/_distro.py | Routes openai_agents instrumentation to the bundled A365 instrumentor when enable_a365=True. |
| README.md | Documents the dual-instrumentor behavior for openai_agents. |
| pyproject.toml | Adds openai-agents optional extra. |
| MIGRATION_A365.md | Updates migration guidance for the new A365 Agents instrumentor behavior. |
| CHANGELOG.md | Notes the new A365-specific OpenAI Agents instrumentor feature. |
| A365_DOCUMENTATION.md | Documents the dual instrumentation selection and implications for exporters. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
nikhilNava
approved these changes
May 11, 2026
b3397c4 to
b46db04
Compare
When enable_a365=True, the distro now uses a bundled A365OpenAIAgentsInstrumentor instead of the upstream opentelemetry-instrumentation-openai-agents-v2. This produces spans with the A365 versioned envelope format including custom.parent.span.id, per-message indexed attributes, detailed token counts, and graph_node_parent_id for handoffs. - Port trace processor, message mapper, utils, and constants from Agent365-python - Wire A365 instrumentor in _distro.py (skip upstream when A365 enabled) - Add openai-agents as optional dependency - Add unit tests (70 tests) and integration test scaffolding - Update A365_DOCUMENTATION.md, MIGRATION_A365.md, README.md, CHANGELOG.md
b46db04 to
219aa61
Compare
rads-1996
approved these changes
May 12, 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.
When enable_a365=True, the distro now uses a bundled A365OpenAIAgentsInstrumentor instead of the upstream opentelemetry-instrumentation-openai-agents-v2. This produces spans with the A365 versioned envelope format including custom.parent.span.id, per-message indexed attributes, detailed token counts, and graph_node_parent_id for handoffs.
Fixes #130 — ResponseSpanData no longer maps to chat, eliminating duplicate span names with GenerationSpanData. It now gets its own response span name.
Fixes #131 — tool_call_id correlation between GenerationSpanData and FunctionSpanData is now tracked. The processor captures IDs from generation output and stamps gen_ai.tool.call.id on the corresponding function span.
Fixes #133 — CustomSpanData (e.g. turn) now maps to chain instead of unknown, preserving the original span name.
Fixes #134 — Agent identity is no longer hardcoded. Spans are created through the standard OTel Tracer.start_span() API, so A365SpanProcessor stamps real identity from baggage.
Fixes #135 — All baggage attributes now propagate to auto-instrumented spans. The old GenAISemanticProcessor created spans outside the OTel span lifecycle; the new processor participates in the normal pipeline.