Skip to content

Traces appear but spans show "No spans found" despite successful export #2477

@jaijuneja

Description

@jaijuneja
Image

Description

When using the SDK tracing API, traces show up in the OpenAI Platform Traces UI but opening a trace shows "No spans found". Verbose logging shows 4 items exported (1 trace + 3 spans), and the ingest API returns 204, so export appears to succeed.

Expected behavior

  • Trace and spans appear in the UI
  • Spans are nested under the trace (AgentSpan, CustomSpan, ResponseSpan, etc.)

Actual behavior

  • Trace appears with correct metadata
  • UI shows "No spans found"
  • Logs show Exported 4 items and the request returns 204

Verbose debug output

With enable_verbose_stdout_logging(), we see spans created and exported:

Setting current trace: trace_xxx
Creating span <CustomSpanData> with id None
Creating span <AgentSpanData> with id None
Running agent Greeter (turn 1)
Creating span <ResponseSpanData> with id None
...
Resetting current trace
Shutting down trace provider
Shutting down trace processor
Exported 4 items

So 4 items (1 trace + 3 spans) are sent and the export succeeds, but the UI still shows no spans.

Minimal reproduction

import asyncio
import os

from dotenv import load_dotenv
load_dotenv(override=True)

from agents import Agent, Runner, custom_span, gen_trace_id, trace
from agents import set_tracing_export_api_key, set_trace_processors
from agents.tracing import default_exporter
from agents.tracing.processors import BatchTraceProcessor

if os.environ.get("OPENAI_API_KEY"):
    set_tracing_export_api_key(os.environ["OPENAI_API_KEY"])

# Long schedule_delay so trace + spans export together on shutdown
# (avoids 5s timer exporting trace before spans finish)
processor = BatchTraceProcessor(default_exporter(), schedule_delay=3600.0)
set_trace_processors([processor])

async def main():
    trace_id = gen_trace_id()
    workflow_trace = trace("trace_test", trace_id=trace_id)
    print(f"View trace: https://platform.openai.com/traces/trace?trace_id={trace_id}")
    workflow_trace.start(mark_as_current=True)

    agent = Agent(
        name="Greeter",
        instructions="You are helpful. Reply briefly.",
        model="gpt-4o-mini",
    )

    with custom_span(name="agent_run", data={"query": "hello"}):
        result = await Runner.run(agent, "Say hello in one word.")

    print(f"Result: {result.final_output}")
    workflow_trace.finish(reset_current=True)
    processor.force_flush()
    print(f"Done. Check trace: https://platform.openai.com/traces/trace?trace_id={trace_id}")

if __name__ == "__main__":
    asyncio.run(main())

What we tried

  1. force_flush() before exit – still no spans in UI
  2. set_trace_processors with schedule_delay=3600 – to keep trace and spans in the same export batch (default 5s timer can export trace before spans finish) – still no spans
  3. set_tracing_export_api_key() – API key is set and ingest returns 204
  4. New vs old API key – same behavior

Environment

  • openai-agents-0.8.4
  • Python 3.12
  • macOS

Questions

  1. Is there a known gap or bug in the Platform Traces UI for ingested spans?
  2. Does the ingest API accept spans but not surface them in the UI?
  3. Is there a required payload or ordering for spans in the ingest request?

Related: #31 (trace visibility issues), #1845 (RealtimeAgent traces without spans)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions