Align GenAI instrumentations with A365 observability schema#75
Merged
Conversation
hectorhdzg
commented
Apr 25, 2026
Member
- Add SpanKind per operation: SERVER for agent/invoke_agent, CLIENT for chat/execute_tool/handoff/generation/function/mcp_tools
- Use structured message format (versioned envelope with MessagePart[]) for input/output messages
- Replace graph_node_id/graph_node_parent_id with gen_ai.agent.name and microsoft.a365.caller.agent.name attributes
- Add gen_ai.conversation.id as separate attribute (split from session_id)
- Add error.type attribute on error spans
- Remove isContentRecordingEnabled option: content is now always recorded
- Handoff spans set invoke_agent operation with caller/target agent names
- Use safeSerializeToJson for tool arguments/results
- Support both Responses API and Chat Completions token usage shapes
- Update tests for new structured message format and attribute changes
Sync OpenAI Agents and LangChain instrumentations with the A365 Node.js observability extensions (Agent365-nodejs commit b091a8b): - Add SpanKind per operation: SERVER for agent/invoke_agent, CLIENT for chat/execute_tool/handoff/generation/function/mcp_tools - Use structured message format (versioned envelope with MessagePart[]) for input/output messages via serializeMessages - Replace graph_node_id/graph_node_parent_id with gen_ai.agent.name and microsoft.a365.caller.agent.name attributes - Add gen_ai.conversation.id as separate attribute (split from session_id) - Add error.type attribute on error spans - Remove isContentRecordingEnabled option: content is now always recorded - Handoff spans set invoke_agent operation with caller/target agent names - Use safeSerializeToJson for tool arguments/results - Support both Responses API and Chat Completions token usage shapes - Update tests for new structured message format and attribute changes
hectorhdzg
requested review from
JacksonWeber,
MSNev,
lzchen and
rads-1996
as code owners
April 25, 2026 00:22
Member
Author
|
@fpfp100 please take a look at this one |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aligns the OpenAI Agents + LangChain GenAI instrumentations with the A365 observability schema by updating span kinds/attributes and moving to a versioned structured message envelope for recorded content.
Changes:
- Update span attributes to the new schema (agent/caller names, separate
gen_ai.conversation.id,error.type) and adjust span kinds (SERVER/CLIENT). - Replace legacy input/output content handling with structured
{ version, messages: MessagePart[] }serialization and safer JSON serialization for tool args/results. - Remove
isContentRecordingEnabledconfiguration and update tests/samples accordingly (content now always recorded).
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/internal/unit/main.test.ts | Updates distro instrumentation test to remove isContentRecordingEnabled expectations. |
| test/internal/unit/genai/openai/utils.test.ts | Updates OpenAI utils unit tests for structured message serialization + removed CONTENT_KEYS. |
| test/internal/unit/genai/openai/openAIAgentsTraceProcessor.test.ts | Updates OpenAI Agents trace processor tests for new attributes and always-on content. |
| test/internal/unit/genai/langchain/utils.test.ts | Updates LangChain utils tests for structured messages and separate conversation id attribute. |
| test/internal/unit/genai/langchain/tracer.test.ts | Updates LangChain tracer tests for CLIENT span kind and always-on content. |
| src/types.ts | Removes content-recording options from GenAI instrumentation config types. |
| src/genai/semconv.ts | Adds microsoft.a365.caller.agent.name and gen_ai.conversation.id constants. |
| src/genai/instrumentations/openai/utils.ts | Adds structured message builders, safe JSON serialization, and token-usage normalization. |
| src/genai/instrumentations/openai/semconv.ts | Removes legacy graph node attribute constants. |
| src/genai/instrumentations/openai/openAIAgentsTraceProcessor.ts | Implements new span kinds, new attributes, structured message serialization, and always-on content. |
| src/genai/instrumentations/openai/openAIAgentsTraceInstrumentor.ts | Stops passing removed content-recording config option to processor. |
| src/genai/instrumentations/langchain/utils.ts | Switches LangChain message/tool serialization to structured envelopes + safe JSON; splits conversation id. |
| src/genai/instrumentations/langchain/tracer.ts | Implements new span kinds, adds error.type and caller-agent attribute, removes content-recording option. |
| src/genai/instrumentations/langchain/langchainTraceInstrumentor.ts | Removes content-recording option threading; simplifies instrumentation hook. |
| src/distro/distro.ts | Stops passing LangChain instrumentation options that no longer exist/are used. |
| samples/src/openaiInstrumentation.ts | Removes isContentRecordingEnabled from sample configuration. |
| samples/src/langchainInstrumentation.ts | Removes isContentRecordingEnabled from sample configuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…en cache - PR #235: Update default auth scope to api://9b975845-388f-4429-889e-eab1ef63949c/.default - PR #237: Add payload chunking with maxPayloadBytes option (default 900KB), estimateSpanBytes/chunkBySize utilities, and per-chunk export with all-or-nothing semantics - PR #238: Restore AgenticTokenCache with authHandlerName parameter - Update functional tests to align with PR microsoft#75 schema changes (SpanKind, gen_ai.agent.name, content always recorded)
Contributor
|
please include PR #240, 238, 235 also. |
- Add gen_ai.operation.name check in partitionByIdentity() to filter non-genAI spans - Only export spans with known genAI operations (invoke_agent, execute_tool, output_messages, chat, Chat, TextCompletion, GenerateContent) - Add test for filtering spans with missing or unknown gen_ai.operation.name
rads-1996
approved these changes
Apr 27, 2026
Member
Author
|
It included migration of following PRs |
hectorhdzg
added a commit
to hectorhdzg/opentelemetry-distro-javascript
that referenced
this pull request
Apr 27, 2026
Merge upstream/main and update CHANGELOG with all changes since 0.1.0-alpha.6: Breaking Changes: - Default to GenAI-only instrumentations when A365 is enabled (microsoft#79) - Align GenAI instrumentations with A365 observability schema (microsoft#75) Features: - Add ESM loader entrypoint (microsoft#74) Bug Fixes: - Resolve logger lazily in Agent365Exporter (microsoft#81) - Register A365SpanProcessor for console fallback path (microsoft#78) - Restore AgenticTokenCache removed in microsoft#66 (microsoft#77) Other: - Bump postcss from 8.5.8 to 8.5.10 (microsoft#72)
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.