Update langchain instrumentation (update to latest semantic conventions, bug fixes, update semantic conventions version, etc.)#129
Open
rads-1996 wants to merge 7 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates GenAI semantic convention usage and improves LangChain GenAI instrumentation to emit spec-conformant provider/role/message attributes (including Gemini and tool/function message handling).
Changes:
- Replaced hard-coded GenAI attribute keys with
opentelemetry-semantic-conventionsconstants and bumped the semconv dependency. - Added robust message conversion utilities (role normalization, tool calls/results, reasoning parts) and provider normalization.
- Updated LangChain callback handler and tests to reflect spec role/provider names and new span emission behavior (Gemini, finish reasons).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| util/opentelemetry-util-genai/src/opentelemetry/util/genai/_inference_invocation.py | Switch reasoning token attribute to semconv constant. |
| util/opentelemetry-util-genai/src/opentelemetry/util/genai/_agent_invocation.py | Switch agent/version + cache token attributes to semconv constants. |
| util/opentelemetry-util-genai/pyproject.toml | Bump semantic conventions dependency to access GenAI constants. |
| instrumentation/opentelemetry-instrumentation-genai-langchain/src/opentelemetry/instrumentation/genai/langchain/utils.py | Introduce provider normalization + structured message conversion for roles/tool calls/reasoning. |
| instrumentation/opentelemetry-instrumentation-genai-langchain/src/opentelemetry/instrumentation/genai/langchain/callback_handler.py | Use new conversion utilities; expand model/provider support; improve finish_reason extraction. |
| instrumentation/opentelemetry-instrumentation-genai-langchain/tests/test_llm_call.py | Update assertions for spec roles/providers; add Gemini + FunctionMessage mapping test. |
| instrumentation/opentelemetry-instrumentation-genai-langchain/tests/test_callback_handler.py | Add tests for finish_reason defaults and propagation in output conversion. |
| instrumentation/opentelemetry-instrumentation-genai-langchain/src/opentelemetry/instrumentation/genai/langchain/span_manager.py | Remove legacy span manager implementation. |
JacksonWeber
approved these changes
Jun 12, 2026
e9122f0 to
6252165
Compare
lzchen
reviewed
Jun 15, 2026
| # Mapping from LangChain ``ls_provider`` metadata values to the well-known | ||
| # ``gen_ai.provider.name`` values defined by the GenAI semantic conventions. | ||
| _PROVIDER_NAME_OVERRIDES: dict[str, str] = { | ||
| "amazon_bedrock": GenAIAttributes.GenAiProviderNameValues.AWS_BEDROCK.value, |
Contributor
There was a problem hiding this comment.
Curious as to where you got this list from?
Author
There was a problem hiding this comment.
had this list, I just used the semconv versions of those,
Contributor
lzchen
reviewed
Jun 15, 2026
26fd2ff to
aaa3a08
Compare
lzchen
approved these changes
Jun 15, 2026
nagkumar91
approved these changes
Jun 15, 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
Update LangChain instrumentation to latest GenAI semantic conventions
Follow-up PR
Fixes part of #126
Type of change
Please delete options that are not relevant.
Checklist
See CONTRIBUTING.md
for the style guide, changelog guidance, and more.