Skip to content

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

Merged
ericapisani merged 4 commits intomasterfrom
ep/sdk-669-add-pipeline-to-span-attributes-93e
Mar 25, 2026
Merged

feat(langchain): Set gen_ai.operation.name and gen_ai.pipeline.name on LLM spans#5849
ericapisani merged 4 commits 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
  • Broaden AI provider detection beyond OpenAI and Anthropic by ericapisani in #5707
  • Update LLM span operation to gen_ai.generate_text by ericapisani in #5796

Internal Changes 🔧

Langchain

  • Add text completion test by alexander-alderman-webb in #5740
  • Add tool execution test by alexander-alderman-webb in #5739
  • Add basic agent test with Responses call by alexander-alderman-webb in #5726
  • Replace mocks with httpx types by alexander-alderman-webb in #5724
  • Consolidate span origin assertion by alexander-alderman-webb in #5723
  • Consolidate available tools assertion by alexander-alderman-webb in #5721

Other

  • Temporarily stop running litellm tests by alexander-alderman-webb in #5851

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 24, 2026

Codecov Results 📊

14 passed | Total: 14 | Pass Rate: 100% | Execution Time: 3.08s

All tests are passing successfully.

❌ Patch coverage is 0.00%. Project has 15429 uncovered lines.

Files with missing lines (1)
File Patch % Lines
langchain.py 3.25% ⚠️ 595 Missing

Generated by Codecov Action

@ericapisani ericapisani marked this pull request as ready for review March 25, 2026 09:17
@ericapisani ericapisani requested a review from a team as a code owner March 25, 2026 09:17
Copy link
Contributor

@alexander-alderman-webb alexander-alderman-webb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@ericapisani ericapisani merged commit a5d04d6 into master Mar 25, 2026
158 checks passed
@ericapisani ericapisani deleted the ep/sdk-669-add-pipeline-to-span-attributes-93e branch March 25, 2026 09:47
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.

2 participants