Commit c493d82
Add OTEL gen-ai message format for auto-instrumented message tracing (#231)
* Add OTEL gen-ai message format support for auto-instrumented input/output message tracing
- OpenAI extension: Auto-record structured InputMessages/OutputMessages on response, generation,
and function spans via OpenAIAgentsTraceProcessor with isContentRecordingEnabled option
- LangChain extension: Auto-record structured InputMessages/OutputMessages on chat, invoke_agent,
and execute_tool spans via LangChainTracer with isContentRecordingEnabled option
- LangChain v1 support: Fix setToolAttributes to handle plain string tool results (v1 format),
fix tool_call_id extraction from inputs, fix setSystemInstructionsAttribute to use getMessageType()
for all message formats, fix setTokenAttributes to check last message for usage_metadata,
fix getModel to check v1 direct response_metadata path
- Add message-schema-validator test helper for validating OTEL gen-ai message contract
- Add LangChainMessageContract and OpenAIMessageContract test suites
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Address code review findings (CRM-001 through CRM-013)
- CRM-001: Move GEN_AI_TOOL_TYPE_KEY setAttribute outside forEach loop
- CRM-002: Wrap string output/input fallbacks in versioned OTEL message envelope
- CRM-003: Support tokenUsage shape (promptTokens/completionTokens) in setTokenAttributes
- CRM-009: Remove unused getAttributesFromInput export
- CRM-010: Replace dead extractMessageContent with extractStringContent delegating to extractRawContent
- CRM-011: Fix self-referential comment
- CRM-006: Add direct v1 constructor format tests for input/output messages
- CRM-007: Add response span content-gating suppression test
- CRM-008: Add empty array and null entry edge case tests
- CRM-013: Add function_call, input_file, malformed JSON, and unknown block type tests
- Fix getMessageType to skip v1 'constructor' type and check id array for message class
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Remove isContentRecordingEnabled gating, remove truncateValue from extensions, align tool serialization
- Remove isContentRecordingEnabled toggle: content recording is now ON by default
(aligned with Python/.NET SDKs). suppressInvokeAgentInput remains.
- Remove truncateValue from both extensions: truncation now happens at the
span/exporter level in core, not pre-truncated in extensions.
- Use safeSerializeToJson for tool arguments/results in both extensions,
matching the core ExecuteToolScope pattern from PR #228.
- Export safeSerializeToJson from core index.ts.
- Add tool argument validation tests for both OpenAI and LangChain extensions.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Address PR review: fix output fallback, input_image part type, stale JSDoc
- processResponseSpanData: add else fallback for non-array output via
wrapRawContentAsOutputMessages (handles object output)
- mapInputContentBlock: map input_image to type 'blob' (matches BlobPart
contract) instead of non-standard 'image'
- Remove stale @param options JSDoc from LangChainTraceInstrumentor.instrument
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Use MAX_SPAN_SIZE_BYTES constant for truncation, export from observability, add missing expect import
- Replace hardcoded 1024 with MAX_SPAN_SIZE_BYTES in OpenAI extensions Utils
- Export MAX_SPAN_SIZE_BYTES from observability package
- Add missing `import { expect } from '@jest/globals'` to test helper
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Peng Fan <pefan@microsoft.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent c3803eb commit c493d82
File tree
13 files changed
+1262
-275
lines changed- packages
- agents-a365-observability-extensions-langchain/src
- agents-a365-observability-extensions-openai/src
- agents-a365-observability/src
- tests/observability
- extension
- helpers
- langchain
- openai
- integration
13 files changed
+1262
-275
lines changedLines changed: 9 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | | - | |
| 24 | + | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
| |||
42 | 41 | | |
43 | 42 | | |
44 | 43 | | |
45 | | - | |
46 | 44 | | |
47 | 45 | | |
48 | 46 | | |
49 | 47 | | |
50 | 48 | | |
51 | | - | |
| 49 | + | |
52 | 50 | | |
53 | | - | |
| 51 | + | |
54 | 52 | | |
55 | 53 | | |
56 | 54 | | |
| |||
104 | 102 | | |
105 | 103 | | |
106 | 104 | | |
107 | | - | |
| 105 | + | |
108 | 106 | | |
109 | 107 | | |
110 | 108 | | |
| |||
154 | 152 | | |
155 | 153 | | |
156 | 154 | | |
157 | | - | |
158 | 155 | | |
159 | | - | |
160 | | - | |
| 156 | + | |
| 157 | + | |
161 | 158 | | |
162 | 159 | | |
163 | 160 | | |
| |||
191 | 188 | | |
192 | 189 | | |
193 | 190 | | |
194 | | - | |
195 | 191 | | |
196 | 192 | | |
197 | | - | |
| 193 | + | |
198 | 194 | | |
199 | 195 | | |
200 | 196 | | |
201 | 197 | | |
202 | | - | |
| 198 | + | |
203 | 199 | | |
204 | 200 | | |
205 | 201 | | |
206 | 202 | | |
207 | 203 | | |
208 | | - | |
| 204 | + | |
209 | 205 | | |
210 | 206 | | |
211 | 207 | | |
0 commit comments