🐛 Bug Report: OpenAI Responses API records no metrics (gen_ai.client.operation.duration, gen_ai.client.token.usage)
Maintainers usually reply within 1 day
@zhaoruizhe81 is already working on this.
Since Oct 10, 2026.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 70/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- observability
Research direction
Start with the wrappers in opentelemetry/instrumentation/openai/v1/init.py (responses_get_or_create_wrapper and async_responses_get_or_create_wrapper) and with v1/responses_wrappers.py, then compare them with the Chat Completions path that already records gen_ai.client.operation.duration and gen_ai.client.token.usage. Run the reproduction script in the issue: it should show new gen_ai metric points for responses.create, sync and async, on success and on the InternalServerError path, with error.type set on failure. Streaming should record metrics too.
Written by the indexing model from the issue text.
Description
Which component is this bug for?
OpenAI Instrumentation
📜 Description
For Chat Completions, the OpenAI instrumentation records gen_ai.client.operation.duration and gen_ai.client.token.usage, including a duration point with error.type when the call fails. For the Responses API (client.responses.create), no metric is recorded at all, neither on success nor on failure. Spans are created normally.
In opentelemetry/instrumentation/openai/v1/__init__.py, the Responses wrappers (responses_get_or_create_wrapper, async_responses_get_or_create_wrapper) only receive the tracer, and v1/responses_wrappers.py never records to the duration or token histograms. So an application that moves from Chat Completions to the Responses API loses its latency and token-usage metrics without any warning.
gen_ai.client.operation.duration is a required metric in the OpenTelemetry GenAI semantic conventions, and gen_ai.client.token.usage is recommended whenever token counts are available. The Responses API returns them in usage, and the span already records them.
👟 Reproduction steps
pip install openai httpx opentelemetry-sdk opentelemetry-instrumentation-openai
import httpx, openai
from opentelemetry.instrumentation.openai import OpenAIInstrumentor
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import InMemoryMetricReader
from opentelemetry.sdk.trace import TracerProvider
def respond(request): # local stand-in for the OpenAI API
if request.url.path.endswith("/responses"):
return httpx.Response(200, json={
"id": "resp_1", "object": "response", "created_at": 0, "status": "completed", "model": "gpt-4o-mini",
"output": [{"type": "message", "id": "msg_1", "status": "completed", "role": "assistant",
"content": [{"type": "output_text", "text": "hi", "annotations": []}]}],
"parallel_tool_calls": True, "tool_choice": "auto", "tools": [],
"usage": {"input_tokens": 7, "output_tokens": 3, "total_tokens": 10,
"input_tokens_details": {"cached_tokens": 0}, "output_tokens_details": {"reasoning_tokens": 0}}})
return httpx.Response(200, json={
"id": "chatcmpl-1", "object": "chat.completion", "created": 0, "model": "gpt-4o-mini",
"choices": [{"index": 0, "message": {"role": "assistant", "content": "hi"}, "finish_reason": "stop"}],
"usage": {"prompt_tokens": 7, "completion_tokens": 3, "total_tokens": 10}})
reader = InMemoryMetricReader()
OpenAIInstrumentor().instrument(tracer_provider=TracerProvider(),
meter_provider=MeterProvider(metric_readers=[reader]))
client = openai.OpenAI(api_key="x", max_retries=0,
http_client=httpx.Client(transport=httpx.MockTransport(respond)))
def gen_ai_points():
data = reader.get_metrics_data()
return sum(p.count for rm in (data.resource_metrics if data else []) for sm in rm.scope_metrics
for m in sm.metrics if m.name.startswith("gen_ai.client.") for p in m.data.data_points)
before = gen_ai_points()
client.chat.completions.create(model="gpt-4o-mini", messages=[{"role": "user", "content": "hello"}])
print("chat.completions.create: new gen_ai metric points =", gen_ai_points() - before)
before = gen_ai_points()
client.responses.create(model="gpt-4o-mini", input="hello")
print("responses.create: new gen_ai metric points =", gen_ai_points() - before)
👍 Expected behavior
responses.create (sync and async, streaming and non-streaming) records gen_ai.client.operation.duration for every call, with error.type when the call fails, and gen_ai.client.token.usage (input and output) from response.usage, as Chat Completions does.
👎 Actual Behavior with Screenshots
chat.completions.create ok new metric points: gen_ai.client.token.usage (output) +1, gen_ai.client.token.usage (input) +1, gen_ai.client.operation.duration +1
responses.create ok new metric points: NONE
chat.completions.create InternalServerError new metric points: gen_ai.client.operation.duration (error.type=InternalServerError) +1
responses.create InternalServerError new metric points: NONE
🤖 Python Version
3.12
📃 Provide any additional context for the Bug.
opentelemetry-instrumentation-openai 0.62.4 (also main at df4921a), openai 2.54.0.
👀 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?
None
- Dominant language
- Python
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 2
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from traceloop/openllmetry
-
bug python
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
traceloop/openllmetry#4717 ·
Maintainers usually reply within 1 day
-
🐛 Bug Report: Incomplete cache token migration after #4243 breaks Bedrock and Groq instrumentationPossibly taken @Quantum-Enigma-dot claimed this 21 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
traceloop/openllmetry#4665 · 1 comment ·
Maintainers usually reply within 1 day
-
🐛 Bug Report: OpenAI instrumentation drops gen_ai.usage.reasoning_tokens on streamed chat completionsPossibly taken @jayfeng7 claimed this 23 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
traceloop/openllmetry#4660 · 1 comment ·
Maintainers usually reply within 1 day
-
Bug Report: Failed dataset deletes still remove local rows and columnsPossibly taken @inchang-ing claimed this 32 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
traceloop/openllmetry#4630 ·
Maintainers usually reply within 1 day
-
🐛 Bug Report: LiteLLM instrumentation does not record seed, stop, frequency_penalty, presence_penaltyPossibly taken @shantam77 claimed this 38 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
traceloop/openllmetry#4598 · 2 comments ·
Maintainers usually reply within 1 day
All issues in traceloop/openllmetry
Similar issues
-
opensubtitlescom: provider rejects pt-PT even though its own converter maps itPossibly taken @paulo-0308 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Diaoul/subliminal#1405 ·
-
Internal ErrorOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
frappe/frappe_docker#2071 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
The-Pocket/PocketFlow#161 ·
-
comp/desktop P2 type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NousResearch/hermes-agent#157702 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
zai-org/zcode-plugins#202 ·
Maintainers usually reply within 1 day