Skip to content

[bot] OpenAI and Anthropic tracers do not set braintrust.span_attributes with {"type": "llm"} #123

@braintrust-bot

Description

@braintrust-bot

Summary

The OpenAI chat completions tracer, OpenAI Responses API tracer, and Anthropic messages tracer do not set braintrust.span_attributes with {"type": "llm"} on their spans. Every other integration in the repository correctly sets this attribute. This causes spans from the three highest-traffic integrations to lack proper LLM span categorization in the Braintrust UI.

What is missing

1. These tracers do NOT set braintrust.span_attributes:

  • trace/contrib/openai/chatcompletions.gochatCompletionsTracer.StartSpan() (line 38): no span_attributes set
  • trace/contrib/openai/responses.goresponsesTracer.StartSpan() (line 39): no span_attributes set
  • trace/contrib/anthropic/messages.gomessagesTracer.StartSpan() (line 38): no span_attributes set

2. These tracers DO correctly set it:

Integration File Line
OpenAI embeddings trace/contrib/openai/embeddings.go 40
Gemini generateContent trace/contrib/genai/generatecontent.go 121
Gemini embedContent trace/contrib/genai/embedcontent.go 41
Genkit generate trace/contrib/genkit/tracegenkit.go 77
Genkit embedder trace/contrib/genkit/embedder.go 116
LangChainGo LLM trace/contrib/langchaingo/tracelangchaingo.go 207
LangChainGo embedder trace/contrib/langchaingo/embedder.go 134
Eino model trace/contrib/cloudwego/eino/traceeino.go 124
Eino embedding trace/contrib/cloudwego/eino/traceeino.go 179
ADK trace/contrib/adk/traceadk.go 326, 430
Bedrock Converse trace/contrib/bedrockruntime/converse.go 170
Bedrock InvokeModel trace/contrib/bedrockruntime/invokemodel.go 46, 102

3. Impact

Per Braintrust's advanced tracing documentation, span_attributes.type = "llm" enables:

  • LLM-specific span icons in the UI for easy identification
  • The "Try prompt" button in the Braintrust UI
  • Proper categorization for LLM-specific monitoring and duration metrics

Without this attribute, OpenAI and Anthropic spans appear as generic spans rather than recognized LLM calls, despite being the most commonly used integrations.

4. The fix is straightforward

Add this call in each tracer's StartSpan method, matching the pattern used by all other integrations:

if err := internal.SetJSONAttr(span, "braintrust.span_attributes", map[string]string{"type": "llm"}); err != nil {
    return ctx, span, err
}

Braintrust docs status

Braintrust's advanced tracing docs explicitly document span_attributes.type as a recognized attribute with "llm" as a valid value that enables LLM-specific UI features. Status: supported.

Upstream sources

  • This is an internal consistency issue, not an upstream API gap. The braintrust.span_attributes attribute is a Braintrust convention used across all other integrations in this repository.

Braintrust docs sources

Local repo files inspected

  • trace/contrib/openai/chatcompletions.goStartSpan() method: no span_attributes set
  • trace/contrib/openai/responses.goStartSpan() method: no span_attributes set
  • trace/contrib/anthropic/messages.goStartSpan() method: no span_attributes set
  • trace/contrib/openai/embeddings.go — correctly sets span_attributes at line 40
  • All other integration files listed in the table above — all correctly set span_attributes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions