🐛 Bug Report: Traces go missing when a model reports 0 tokens
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 62/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- observability
Direzione di ricerca
Start by running the reproduction script in the issue, which uses a mocked OpenAI transport returning zero token usage, and confirm both span lists are empty. The two instrumentors involved are LangchainInstrumentor and OpenAIInstrumentor, so compare how each handles a zero token count in the usage data. Done when both spans appear with 0 tokens and later calls keep being traced.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Which component is this bug for?
Langchain Instrumentation
📜 Description
When a model returns 0 in its token usage, the Langchain span is never sent, and later LLM calls stop being traced too.
Local models and proxies often report 0 tokens, so this is easy to hit.
This is what i assume and reviewed, correct me if i am wrong
👟 Reproduction steps
No API key needed, it uses a fake OpenAI server that returns 0 tokens:
import httpx
import openai
from langchain_openai import ChatOpenAI
from opentelemetry.instrumentation.langchain import LangchainInstrumentor
from opentelemetry.instrumentation.openai import OpenAIInstrumentor
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter
exporter = InMemorySpanExporter()
provider = TracerProvider()
provider.add_span_processor(SimpleSpanProcessor(exporter))
LangchainInstrumentor().instrument(tracer_provider=provider)
OpenAIInstrumentor().instrument(tracer_provider=provider)
# fake OpenAI server that reports 0 tokens
http = httpx.Client(transport=httpx.MockTransport(lambda request: httpx.Response(200, json={
"id": "1", "object": "chat.completion", "created": 0, "model": "m",
"choices": [{"index": 0, "message": {"role": "assistant", "content": "hi"}, "finish_reason": "stop"}],
"usage": {"prompt_tokens": 0, "completion_tokens": 0, "total_tokens": 0},
})))
ChatOpenAI(model="m", api_key="x", base_url="http://mock/v1", http_client=http).invoke("hi")
print("langchain spans:", [s.name for s in exporter.get_finished_spans()])
exporter.clear()
openai.OpenAI(api_key="x", base_url="http://mock/v1", http_client=http).chat.completions.create(
model="m", messages=[{"role": "user", "content": "hi"}]
)
print("openai spans:", [s.name for s in exporter.get_finished_spans()])
👍 Expected behavior
langchain spans: ['ChatOpenAI.chat']
openai spans: ['openai.chat']
👎 Actual Behavior with Screenshots
langchain spans: []
openai spans: []
If you change the usage to non-zero numbers, both spans show up as expected.
🤖 Python Version
3.11
📃 Provide any additional context for the Bug.
No response
👀 Have you spent some time to check if this bug has been raised before?
- I checked and didn't find similar issue
Are you willing to submit PR?
Yes I am willing to submit a PR!
- Lingua principale
- Python
- Stelle
- 7.5k
- Fork
- 1.2k
- Merge medio
- 1g 23h
- PR unite (30g)
- 3
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di traceloop/openllmetry
-
🐛 Bug Report: OpenAI Responses: with_raw_response.create() raises when the body can't be parsed, though the uninstrumented call returnsForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug python
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
traceloop/openllmetry#4717 ·
I maintainer di solito rispondono entro 1 giorno
-
🐛 Bug Report: Incomplete cache token migration after #4243 breaks Bedrock and Groq instrumentationForse già presa @Quantum-Enigma-dot l’ha presa 21 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
traceloop/openllmetry#4665 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
🐛 Bug Report: OpenAI instrumentation drops gen_ai.usage.reasoning_tokens on streamed chat completionsForse già presa @jayfeng7 l’ha presa 23 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
traceloop/openllmetry#4660 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Bug Report: Failed dataset deletes still remove local rows and columnsForse già presa @inchang-ing l’ha presa 32 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
traceloop/openllmetry#4630 ·
I maintainer di solito rispondono entro 1 giorno
-
🐛 Bug Report: LiteLLM instrumentation does not record seed, stop, frequency_penalty, presence_penaltyForse già presa @shantam77 l’ha presa 38 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
traceloop/openllmetry#4598 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di traceloop/openllmetry
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
mozilla-ai/cq#601 ·
I maintainer di solito rispondono entro 1 giorno
-
Bump Python to 3.14 or 3.15Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
intcomma returns exponential notation for large floatsForse già presa @Omarinho12345 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
python-humanize/humanize#521 ·
I maintainer di solito rispondono entro 1 giorno
-
LUCJ pass manager raises NoEdgeBetweenNodes when an edge is bad for two two-qubit gatesForse già presa @hat-im l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
opensubtitlescom: provider rejects pt-PT even though its own converter maps itForse già presa @paulo-0308 l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
Diaoul/subliminal#1405 ·