feat(langchain): Set gen_ai.operation.name and gen_ai.pipeline.name on LLM spans#5849
Draft
ericapisani wants to merge 1 commit intomasterfrom
Draft
feat(langchain): Set gen_ai.operation.name and gen_ai.pipeline.name on LLM spans#5849ericapisani wants to merge 1 commit intomasterfrom
ericapisani wants to merge 1 commit intomasterfrom
Conversation
…rt tests Add name kwarg to on_llm_start call in test_langchain_message_truncation and assert that gen_ai.pipeline.name is set correctly when a pipeline name is provided. Also add gen_ai.operation.name assertions to relevant tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Langchain
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 13 passed | Total: 13 | Pass Rate: 100% | Execution Time: 9.21s All tests are passing successfully. ❌ Patch coverage is 0.00%. Project has 14385 uncovered lines. Files with missing lines (1)
Generated by Codecov Action |
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.
Set
gen_ai.operation.nameandgen_ai.pipeline.namespan attributes on spans created byon_llm_startin the LangChain integration.on_llm_starthandles non-chat LLM calls (e.g. completion models). It was already setting span attributes for model, system, and token usage, but was missing the operation name and pipeline name attributes that other handlers set. This adds:gen_ai.operation.name = "generate_text"to align with the span op (gen_ai.generate_text)gen_ai.pipeline.namefrom thenamekwarg passed by LangChain, when presentTests are updated in
test_langchain_message_truncationandtest_langchain_response_model_extractionto assert these attributes are set correctly.Part of SDK-669, is the second part of changes that are being pulled out of #5705