fix(openai): mark traced openai spans as llm#85
fix(openai): mark traced openai spans as llm#85Abhijeet Prasad (AbhiPrasad) wants to merge 2 commits into
Conversation
Set braintrust.span_attributes.type to "llm" for the chat completions and responses tracers so Braintrust classifies emitted spans correctly in the UI. Extend the VCR-backed OpenAI assertions to verify the attribute is present on exported spans. Fixes #81
| } | ||
| } | ||
|
|
||
| if err := internal.SetJSONAttr(span, "braintrust.span_attributes", map[string]string{"type": "llm"}); err != nil { |
There was a problem hiding this comment.
this is a bit long i'd split the map into a constant
There was a problem hiding this comment.
a map can't be constant, you can only declare it as a var, and I'd like to avoid that because I don't want it to be mutable. I guess I could use a helper function that returns a map. but that feels too much for this case.
I could extract braintrust.span_attributes and llm into constants, so you'd get something like:
if err := internal.SetJSONAttr(span, internal.AttrSpanAttributes, map[string]string{"type": internal.SpanTypeLLM}); err != nil {but the length is still long. OTEL semantic conventions follows this above pattern.
There was a problem hiding this comment.
i'd still do attrs := map[]; setJsonAttr(span, attrs)
There was a problem hiding this comment.
done with bc4e400
also going to follow up and clean up our integrations to use constants after this PR
Set braintrust.span_attributes.type to "llm" for the chat completions and responses tracers so Braintrust classifies emitted spans correctly in the UI.
Extend the VCR-backed OpenAI assertions to verify the attribute is present on exported spans.
Fixes #81