Skip to content

[OpenAI Agents Auto-Instrument] ResponseSpanData mapped to chat operation produces duplicate span names with GenerationSpanData #130

Description

@fpfp100

Summary

The GenAISemanticProcessor in opentelemetry-instrumentation-openai-agents maps ResponseSpanData to GenAIOperationName.CHAT, causing its span name to be chat {model} (e.g. chat gpt-4o-mini). This is the same span name generated for GenerationSpanData, making them indistinguishable in traces.

Details

In span_processor.py line 1533-1534:

elif _is_instance_of(span_data, ResponseSpanData):
    return GenAIOperationName.CHAT  # Response typically from chat

The OpenAI Agents SDK emits both ResponseSpanData (high-level API response wrapper) and GenerationSpanData (underlying chat completion) for a single LLM call. When both map to chat, the trace shows two spans named chat gpt-4o-mini with no way to tell them apart without inspecting attributes or parent-child relationships.

Expected behavior

ResponseSpanData should use a distinct operation name (e.g. response) so that the span name differentiates it from the GenerationSpanData chat span. This is how the base A365 SDK (OpenAIAgentsTraceProcessor) handles it — ResponseSpanData gets span name response while GenerationSpanData gets chat {model}.

Reproduction

  1. Run any agent using OpenAIAgentsInstrumentor with console exporter enabled
  2. Send a message that triggers an LLM call
  3. Observe two spans both named chat gpt-4o-mini in the trace output

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions