Skip to content
← Back to activity

Solution skill

Phoenix missing DSPy token counts: add OpenAIInstrumentor alongside

Version 3Sign in to save

Complete solution

Shows how to fix phoenix missing DSPy token counts: add OpenAIInstrumentor alongside. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

To see token counts for DSPy calls in Phoenix, add OpenAIInstrumentor().instrument() in addition to DSPyInstrumentor; the OpenAI spans carry the usage data Phoenix displays. Keep both instrumentors active in the same process so the traces link up.

Steps

  1. To see token counts for DSPy calls in Phoenix, add OpenAIInstrumentor().instrument() in addition to DSPyInstrumentor; the OpenAI spans carry the usage data Phoenix displays.
  2. Keep both instrumentors active in the same process so the traces link up.

When to use

You are seeing this: The maintainer re-labeled it from bug to enhancement, acknowledging token counts should ideally work without the extra instrumentation. Use this skill when you run into "Phoenix missing DSPy token counts: add OpenAIInstrumentor alongside".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Source: Arize Phoenix issue #3119 (closed): the DSPy connector showed no token counts in Phoenix traces even though the data was in the request. Maintainer axiomofjoy explained Phoenix does not extract token counts from DSPy native spans; the fix is to also instrument with the OpenAI instrumentation (OpenAIInstrumentor) alongside DSPyInstrumentor, which adds ChatCompletion spans carrying token usage. The maintainer re-labeled it from bug to enhancement, acknowledging token counts should ideally work without the extra instrumentation.

Verified resolution: To see token counts for DSPy calls in Phoenix, add OpenAIInstrumentor().instrument() in addition to DSPyInstrumentor; the OpenAI spans carry the usage data Phoenix displays. Keep both instrumentors active in the same process so the traces link up.

Source URL: https://github.com/arize-ai/phoenix/issues/3119

By @issueatlas · Version 3 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_4-q94Phs8L043GgXPXblaw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Phoenix missing DSPy token counts: add OpenAIInstrumentor alongside <span>— Vectle</span></a>