feat(langchain): add semconv attributes, operation mapping, and content recording modules [1/5]#4450
Open
nagkumar91 wants to merge 1 commit intoopen-telemetry:mainfrom
Open
Conversation
…nt recording modules Add foundation modules for enhanced LangChain GenAI semantic convention tracing: - semconv_attributes.py: Per-operation attribute matrix based on OTel GenAI semantic conventions. Single source of truth for which attributes apply to which operations (chat, text_completion, invoke_agent, execute_tool, invoke_workflow, retrieval). - operation_mapping.py: Callback-to-semconv operation mapping. Maps each LangChain callback to the correct GenAI semantic convention operation name. Includes heuristic classification for on_chain_start callbacks (agents vs workflows vs internal plumbing) and LangGraph marker recognition. - content_recording.py: Thin integration layer over the shared genai content capture utilities. Provides clear APIs for the callback handler to decide what content should be recorded on spans and events. Part 1 of a series breaking down open-telemetry#4389 into smaller reviewable PRs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Apr 16, 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.
Description
Add foundation modules for enhanced LangChain GenAI semantic convention tracing. These are internal building-block modules that will be consumed by subsequent PRs in this series.
New Modules
semconv_attributes.pyPer-operation attribute matrix based on OTel GenAI semantic conventions. Single source of truth for which attributes apply to which operations (chat, text_completion, invoke_agent, execute_tool, invoke_workflow, retrieval). Defines requirement levels (REQUIRED, CONDITIONALLY_REQUIRED, RECOMMENDED, OPT_IN) following the GenAI semconv spec.
operation_mapping.pyCallback-to-semconv operation mapping. Maps each LangChain callback to the correct GenAI semantic convention operation name. Includes heuristic classification for
on_chain_startcallbacks (agents vs workflows vs internal plumbing) and LangGraph marker recognition.content_recording.pyThin integration layer over the shared genai content capture utilities. Provides clear APIs for the callback handler to decide what content should be recorded on spans and events.
Tests
test_operation_mapping.py— comprehensive tests for chain classification, agent name resolution, LangGraph markerstest_content_recording.py— tests for content policy modes, redaction behaviorPR Series
This is PR 1 of 5 breaking down #4389 into smaller reviewable units:
Type of change
Checklist