open-telemetry / open-telemetry/opentelemetry-python-genai

[langchain] Classify agent chains by name on on_chain_start

Open
#579 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

openinference-migration
Dominant language
Python
Stars
39
Forks
63
Avg merge
1d 15h
Merged PRs (30d)
175

Description

[!NOTE]
This issue was generated with AI assistance and requires investigation and confirmation prior to being worked on.

Part of #543.

In on_chain_start, agent classification currently requires explicit metadata keys (otel_agent_span, agent_name, agent_type). Standard LangChain agent chains (e.g. AgentExecutor) without explicit metadata are either misclassified as workflows or suppressed.

OpenInference classifies any chain whose name contains "agent" as an agent span.

  • Classify chains with "agent" in the chain/runnable name as invoke_agent (gen_ai.operation.name: "invoke_agent")
  • Resolve agent name from chain/runnable name
  • Set standard agent attributes (gen_ai.agent.name, gen_ai.conversation.id, gen_ai.input.messages, gen_ai.output.messages)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the on_chain_start entry point and the existing classification logic for otel_agent_span, agent_name, and agent_type. Compare its behavior with standard LangChain chains such as AgentExecutor, then verify that names containing "agent" produce invoke_agent spans with the requested agent name and standard attributes; add or update focused tests if the surrounding code provides them.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.