Skip to content

feat(langchain): Set gen_ai.operation.name and gen_ai.pipeline.name on LLM spans#5849

Draft
ericapisani wants to merge 1 commit intomasterfrom
ep/sdk-669-add-pipeline-to-span-attributes-93e
Draft

feat(langchain): Set gen_ai.operation.name and gen_ai.pipeline.name on LLM spans#5849
ericapisani wants to merge 1 commit intomasterfrom
ep/sdk-669-add-pipeline-to-span-attributes-93e

Conversation

@ericapisani
Copy link
Member

@ericapisani ericapisani commented Mar 24, 2026

Set gen_ai.operation.name and gen_ai.pipeline.name span attributes on spans created by on_llm_start in the LangChain integration.

on_llm_start handles 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.name from the name kwarg passed by LangChain, when present

Tests are updated in test_langchain_message_truncation and test_langchain_response_model_extraction to assert these attributes are set correctly.

Part of SDK-669, is the second part of changes that are being pulled out of #5705

…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>
@linear-code
Copy link

linear-code bot commented Mar 24, 2026

@github-actions
Copy link
Contributor

github-actions bot commented Mar 24, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Langchain

  • Set gen_ai.operation.name and gen_ai.pipeline.name on LLM spans by ericapisani in #5849
  • Update LLM span operation to gen_ai.generate_text by ericapisani in #5796

Internal Changes 🔧

  • (langchain) Consolidate available tools assertion by alexander-alderman-webb in #5721

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 24, 2026

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)
File Patch % Lines
langchain.py 3.26% ⚠️ 594 Missing

Generated by Codecov Action

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.

1 participant