Skip to content

Align GenAI instrumentations with A365 observability schema#75

Merged
hectorhdzg merged 6 commits into
microsoft:mainfrom
hectorhdzg:a365-sync-upstream
Apr 27, 2026
Merged

Align GenAI instrumentations with A365 observability schema#75
hectorhdzg merged 6 commits into
microsoft:mainfrom
hectorhdzg:a365-sync-upstream

Conversation

@hectorhdzg

Copy link
Copy Markdown
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
Copilot AI review requested due to automatic review settings April 25, 2026 00:22
@hectorhdzg

Copy link
Copy Markdown
Member Author

@fpfp100 please take a look at this one

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 isContentRecordingEnabled configuration 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.

Comment thread src/genai/instrumentations/openai/openAIAgentsTraceProcessor.ts Outdated
Comment thread src/genai/instrumentations/openai/utils.ts
Comment thread src/genai/instrumentations/openai/utils.ts
Comment thread src/genai/instrumentations/openai/openAIAgentsTraceProcessor.ts
…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)
@fpfp100

fpfp100 commented Apr 27, 2026

Copy link
Copy Markdown
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
@hectorhdzg

Copy link
Copy Markdown
Member Author

@hectorhdzg
hectorhdzg merged commit 0c3e2d3 into microsoft:main Apr 27, 2026
5 checks passed
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants