@@ -57,6 +57,11 @@ func (NoopTracing) ChatCompletionTracer() ChatCompletionTracer {
5757 return NoopChatCompletionTracer {}
5858}
5959
60+ // EmbeddingsTracer implements Tracing.EmbeddingsTracer.
61+ func (NoopTracing ) EmbeddingsTracer () EmbeddingsTracer {
62+ return NoopEmbeddingsTracer {}
63+ }
64+
6065// ImageGenerationTracer implements Tracing.ImageGenerationTracer.
6166func (NoopTracing ) ImageGenerationTracer () ImageGenerationTracer {
6267 return NoopImageGenerationTracer {}
@@ -142,6 +147,35 @@ func (NoopChatCompletionTracer) StartSpanAndInjectHeaders(context.Context, map[s
142147 return nil
143148}
144149
150+ // EmbeddingsTracer creates spans for OpenAI embeddings requests.
151+ type EmbeddingsTracer interface {
152+ // StartSpanAndInjectHeaders starts a span and injects trace context into
153+ // the header mutation.
154+ //
155+ // Parameters:
156+ // - ctx: might include a parent span context.
157+ // - headers: Incoming HTTP headers used to extract parent trace context.
158+ // - headerMutation: The new Embeddings Span will have its context
159+ // written to these headers unless NoopTracing is used.
160+ // - req: The OpenAI embeddings request. Used to record request attributes.
161+ // - body: contains the original raw request body as a byte slice.
162+ //
163+ // Returns nil unless the span is sampled.
164+ StartSpanAndInjectHeaders (ctx context.Context , headers map [string ]string , headerMutation * extprocv3.HeaderMutation , req * openai.EmbeddingRequest , body []byte ) EmbeddingsSpan
165+ }
166+
167+ // EmbeddingsSpan represents an OpenAI embeddings request.
168+ type EmbeddingsSpan interface {
169+ // RecordResponse records the response attributes to the span.
170+ RecordResponse (resp * openai.EmbeddingResponse )
171+
172+ // EndSpanOnError finalizes and ends the span with an error status.
173+ EndSpanOnError (statusCode int , body []byte )
174+
175+ // EndSpan finalizes and ends the span.
176+ EndSpan ()
177+ }
178+
145179// ImageGenerationTracer creates spans for OpenAI image generation requests.
146180type ImageGenerationTracer interface {
147181 // StartSpanAndInjectHeaders starts a span and injects trace context into
0 commit comments