RunLLM How do I disable the default openai agents tracing and enable Phoenix tracing?
To disable the default OpenAI Agents SDK tracing and enable Phoenix tracing, use the Phoenix register function with auto_instrument=True to set up tracing, and ensure you do not initialize the default OpenAI tracing. If OpenAI tracing is already active, you can call OpenAIInstrumentor().uninstrument() before registering Phoenix tracing. Then, instrument Phoenix as follows: LBKSfrom phoenix.otel import register tracer_provider = register( project_name="agents", endpoint="http://localhost:6006/v1/traces", auto_instrument=True )LBKSThis setup ensures only Phoenix handles tracing, and OpenAI's default tracing is disabled. For more, see OpenAI Agents SDK Tracing and OpenAI Tracing.Would you like more detail?Sources:
- OpenAI Agents SDK Tracing
- OpenAI Tracing
馃挕聽Hint: Mention RunLLM in the thread for followups.
RunLLM So OpenAI agents has tracing on by default. I can turn it off, but it messes with the Phoenix tracing. if I don't turn it off, Phoenix and OpenAI get the tracing. I don't want both to get the traces.
To ensure only Phoenix receives traces and not the default OpenAI Agents tracing, do not enable OpenAI's built-in tracing. Instead, use Phoenix's register with auto_instrument=True to handle all tracing. If OpenAI tracing is already active, call OpenAIInstrumentor().uninstrument() before registering Phoenix tracing. This prevents duplicate traces and ensures only Phoenix collects them, as described in OpenAI Agents SDK Tracing.Would you like a step-by-step code example?Sources:
- OpenAI Agents SDK Tracing
馃挕聽Hint: Mention RunLLM in the thread for followups.
RunLLM can you give me a full example using OpenAIInstrumentor().uninstrument()?
Certainly! Here is a full example that disables the default OpenAI tracing using OpenAIInstrumentor().uninstrument() before enabling Phoenix tracing: LBKSfrom openinference.instrumentation.openai import OpenAIInstrumentor from phoenix.otel import registerLBKS# Disable OpenAI's default tracing OpenAIInstrumentor().uninstrument()LBKS# Register Phoenix tracing tracer_provider = register( project_name="agents", endpoint="http://localhost:6006/v1/traces", auto_instrument=True )LBKS# Now use OpenAI as usual; only Phoenix will receive traces import openai client = openai.OpenAI() response = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": "Write a haiku."}], ) print(response.choices[0].message.content)LBKSThis ensures only Phoenix receives traces, not the default OpenAI tracing. See OpenAI Agents SDK Tracing for more details.Sources:
- https://github.com/Arize-ai/phoenix/issues/2340
- https://github.com/Arize-ai/phoenix/blob/main/docs/tracing/how-to-tracing/setup-tracing-python.md
馃挕聽Hint: Mention RunLLM in the thread for followups.
RunLLM so that's what I'm trying. Here's my code:
from openinference.instrumentation.openai_agents import OpenAIAgentsInstrumentor
# Disable OpenAI's default tracing
OpenAIAgentsInstrumentor().uninstrument()
client = AsyncOpenAI(
base_url=BASE_URL,
api_key=API_KEY,
)I get a message: Attempting to uninstrument while already uninstrumented but it is still sending to openai
The message Attempting to uninstrument while already uninstrumented means the OpenAIAgentsInstrumentor was not active, so calling .uninstrument() had no effect. If traces are still being sent to OpenAI, it's likely that tracing is being enabled elsewhere鈥攑ossibly by auto-instrumentation or another instrumentor.According to OpenAI Agents SDK Tracing, you should ensure that only Phoenix tracing is registered and that no other tracing (including OpenAI's) is initialized. Double-check that you are not calling any other tracing setup (including environment-based auto-instrumentation) before or after your uninstrument() call.Would you like help debugging where tracing might be getting enabled?Sources:
- https://arize-ai.slack.com/archives/C04R3GXC8HK/p1722528199.497779
- https://github.com/Arize-ai/phoenix/issues/2510
馃挕聽Hint: Mention RunLLM in the thread for followups.
hey Brandon B. - I'm not super familiar but this might be relevant? https://github.com/Arize-ai/openinference/pull/1586
Mikyo I'll take a look at that. Thanks!
Mikyo That is absolutely related. I'm still working through the code to see what's missing though. Thanks for sharing that!
Sounds good! Let us know if you need anything
