traceloop / traceloop/openllmetry

LangChain: bare tool loop without a workflow span produces one trace per invocation — expected? docs note?

Open Beginner friendly
#4,347 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.4k
Forks
1.1k
Avg merge
8d 14h
Merged PRs (30d)
2

Description

Setup: opentelemetry-instrumentation-langchain 0.62.1, langchain-core 1.4.8, a plain agent loop (model.invoke -> execute tool -> repeat) with no @workflow decorator and no enclosing span.

Observed: every chat span and every execute_tool span lands in its own trace (9 spans -> 9 distinct trace ids, all parentless). Reproduction script here: https://github.com/Dnakitare/kagua/blob/main/fixtures/otel/generate_openllmetry.py

I understand why: with no active span at invoke time, each callback root starts a fresh trace. And wrapping the loop in @workflow (or any parent span) fixes it. So this may be entirely by design.

Two questions:

  1. Is this the intended behavior for bare loops, or would you take a change that keeps a session-scoped parent so consecutive invocations in one loop share a trace?
  2. If it's intended, would you take a docs PR that calls it out? For anyone doing trace-level analysis downstream (in my case, replaying traces for authority verification, where within-task correlation is the whole game), the fragmentation is easy to miss and quietly breaks cross-span reasoning. A one-paragraph note in the LangChain instrumentation docs would save people the debugging session.

Happy to write the docs PR if that's the preferred resolution.

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 with the reproduction script at fixtures/otel/generate_openllmetry.py and verify the separate traces for the bare model/tool loop. Then locate the LangChain instrumentation documentation and clarify whether an enclosing @workflow or parent span is required for shared trace context; done means the behavior and workaround are documented if it is intentional.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation, observability
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.