openai

package
v0.4.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package openai provides OpenInference semantic conventions hooks for OpenAI instrumentation used by the ExtProc router filter.

Package openai provides OpenInference semantic conventions hooks for OpenAI instrumentation used by the ExtProc router filter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewChatCompletionRecorder

func NewChatCompletionRecorder(config *openinference.TraceConfig) tracing.ChatCompletionRecorder

NewChatCompletionRecorder creates a tracing.ChatCompletionRecorder with the given config using the OpenInference configuration specification.

Parameters:

  • config: configuration for redaction. Defaults to NewTraceConfigFromEnv().

See: https://github.com/Arize-ai/openinference/blob/main/spec/configuration.md

func NewChatCompletionRecorderFromEnv

func NewChatCompletionRecorderFromEnv() tracing.ChatCompletionRecorder

NewChatCompletionRecorderFromEnv creates an api.ChatCompletionRecorder from environment variables using the OpenInference configuration specification.

See: https://github.com/Arize-ai/openinference/blob/main/spec/configuration.md

func NewCompletionRecorder added in v0.4.0

func NewCompletionRecorder(config *openinference.TraceConfig) tracing.CompletionRecorder

NewCompletionRecorder creates a tracing.CompletionRecorder with the given config using the OpenInference configuration specification.

Parameters:

  • config: configuration for redaction. Defaults to NewTraceConfigFromEnv().

See: https://github.com/Arize-ai/openinference/blob/main/spec/semantic_conventions.md#completions-api-legacy-text-completion

func NewCompletionRecorderFromEnv added in v0.4.0

func NewCompletionRecorderFromEnv() tracing.CompletionRecorder

NewCompletionRecorderFromEnv creates an api.CompletionRecorder from environment variables using the OpenInference configuration specification.

See: https://github.com/Arize-ai/openinference/blob/main/spec/semantic_conventions.md#completions-api-legacy-text-completion

func NewEmbeddingsRecorder added in v0.4.0

func NewEmbeddingsRecorder(config *openinference.TraceConfig) tracing.EmbeddingsRecorder

NewEmbeddingsRecorder creates a tracing.EmbeddingsRecorder with the given config using the OpenInference configuration specification.

Parameters:

  • config: configuration for redaction. Defaults to NewTraceConfigFromEnv().

See: https://github.com/Arize-ai/openinference/blob/main/spec/embedding_spans.md

func NewEmbeddingsRecorderFromEnv added in v0.4.0

func NewEmbeddingsRecorderFromEnv() tracing.EmbeddingsRecorder

NewEmbeddingsRecorderFromEnv creates an api.EmbeddingsRecorder from environment variables using the OpenInference configuration specification.

See: https://github.com/Arize-ai/openinference/blob/main/spec/embedding_spans.md

func NewImageGenerationRecorder added in v0.4.0

func NewImageGenerationRecorder(config *openinference.TraceConfig) tracing.ImageGenerationRecorder

NewImageGenerationRecorder creates a tracing.ImageGenerationRecorder with the given config using the OpenInference configuration specification.

Parameters:

  • config: configuration for redaction. Defaults to NewTraceConfigFromEnv().

See: https://github.com/Arize-ai/openinference/blob/main/spec/configuration.md

func NewImageGenerationRecorderFromEnv added in v0.4.0

func NewImageGenerationRecorderFromEnv() tracing.ImageGenerationRecorder

NewImageGenerationRecorderFromEnv creates an api.ImageGenerationRecorder from environment variables using the OpenInference configuration specification.

See: https://github.com/Arize-ai/openinference/blob/main/spec/configuration.md

Types

type ChatCompletionRecorder

type ChatCompletionRecorder struct {
	// contains filtered or unexported fields
}

ChatCompletionRecorder implements recorders for OpenInference chat completion spans.

func (*ChatCompletionRecorder) RecordRequest

func (r *ChatCompletionRecorder) RecordRequest(span trace.Span, chatReq *openai.ChatCompletionRequest, body []byte)

RecordRequest implements the same method as defined in tracing.ChatCompletionRecorder.

func (*ChatCompletionRecorder) RecordResponse

func (r *ChatCompletionRecorder) RecordResponse(span trace.Span, resp *openai.ChatCompletionResponse)

RecordResponse implements the same method as defined in tracing.ChatCompletionRecorder.

func (*ChatCompletionRecorder) RecordResponseChunks

func (r *ChatCompletionRecorder) RecordResponseChunks(span trace.Span, chunks []*openai.ChatCompletionResponseChunk)

RecordResponseChunks implements the same method as defined in tracing.ChatCompletionRecorder.

func (*ChatCompletionRecorder) RecordResponseOnError

func (r *ChatCompletionRecorder) RecordResponseOnError(span trace.Span, statusCode int, body []byte)

RecordResponseOnError implements the same method as defined in tracing.ChatCompletionRecorder.

func (*ChatCompletionRecorder) StartParams

func (r *ChatCompletionRecorder) StartParams(*openai.ChatCompletionRequest, []byte) (spanName string, opts []trace.SpanStartOption)

StartParams implements the same method as defined in tracing.ChatCompletionRecorder.

type CompletionRecorder added in v0.4.0

type CompletionRecorder struct {
	// contains filtered or unexported fields
}

CompletionRecorder implements recorders for OpenInference completions spans.

func (*CompletionRecorder) RecordRequest added in v0.4.0

func (r *CompletionRecorder) RecordRequest(span trace.Span, req *openai.CompletionRequest, body []byte)

RecordRequest implements the same method as defined in tracing.CompletionRecorder.

func (*CompletionRecorder) RecordResponse added in v0.4.0

func (r *CompletionRecorder) RecordResponse(span trace.Span, resp *openai.CompletionResponse)

RecordResponse implements the same method as defined in tracing.CompletionRecorder.

func (*CompletionRecorder) RecordResponseChunks added in v0.4.0

func (r *CompletionRecorder) RecordResponseChunks(span trace.Span, chunks []*openai.CompletionResponse)

RecordResponseChunks implements the same method as defined in tracing.CompletionRecorder. For completions, streaming chunks are full CompletionResponse objects (not deltas like chat). This method aggregates chunks into a single response for recording.

func (*CompletionRecorder) RecordResponseOnError added in v0.4.0

func (r *CompletionRecorder) RecordResponseOnError(span trace.Span, statusCode int, body []byte)

RecordResponseOnError implements the same method as defined in tracing.CompletionRecorder.

func (*CompletionRecorder) StartParams added in v0.4.0

func (r *CompletionRecorder) StartParams(*openai.CompletionRequest, []byte) (spanName string, opts []trace.SpanStartOption)

StartParams implements the same method as defined in tracing.CompletionRecorder.

type EmbeddingsRecorder added in v0.4.0

type EmbeddingsRecorder struct {
	// contains filtered or unexported fields
}

EmbeddingsRecorder implements recorders for OpenInference embeddings spans.

func (*EmbeddingsRecorder) RecordRequest added in v0.4.0

func (r *EmbeddingsRecorder) RecordRequest(span trace.Span, embReq *openai.EmbeddingRequest, body []byte)

RecordRequest implements the same method as defined in tracing.EmbeddingsRecorder.

func (*EmbeddingsRecorder) RecordResponse added in v0.4.0

func (r *EmbeddingsRecorder) RecordResponse(span trace.Span, resp *openai.EmbeddingResponse)

RecordResponse implements the same method as defined in tracing.EmbeddingsRecorder.

func (*EmbeddingsRecorder) RecordResponseOnError added in v0.4.0

func (r *EmbeddingsRecorder) RecordResponseOnError(span trace.Span, statusCode int, body []byte)

RecordResponseOnError implements the same method as defined in tracing.EmbeddingsRecorder.

func (*EmbeddingsRecorder) StartParams added in v0.4.0

func (r *EmbeddingsRecorder) StartParams(*openai.EmbeddingRequest, []byte) (spanName string, opts []trace.SpanStartOption)

StartParams implements the same method as defined in tracing.EmbeddingsRecorder.

type ImageGenerationRecorder added in v0.4.0

type ImageGenerationRecorder struct {
	// contains filtered or unexported fields
}

ImageGenerationRecorder implements recorders for OpenInference image generation spans.

func (*ImageGenerationRecorder) RecordRequest added in v0.4.0

func (r *ImageGenerationRecorder) RecordRequest(span trace.Span, req *openaisdk.ImageGenerateParams, body []byte)

RecordRequest implements the same method as defined in tracing.ImageGenerationRecorder.

func (*ImageGenerationRecorder) RecordResponse added in v0.4.0

func (r *ImageGenerationRecorder) RecordResponse(span trace.Span, resp *openaisdk.ImagesResponse)

RecordResponse implements the same method as defined in tracing.ImageGenerationRecorder.

func (*ImageGenerationRecorder) RecordResponseOnError added in v0.4.0

func (r *ImageGenerationRecorder) RecordResponseOnError(span trace.Span, statusCode int, body []byte)

RecordResponseOnError implements the same method as defined in tracing.ImageGenerationRecorder.

func (*ImageGenerationRecorder) StartParams added in v0.4.0

func (r *ImageGenerationRecorder) StartParams(*openaisdk.ImageGenerateParams, []byte) (spanName string, opts []trace.SpanStartOption)

StartParams implements the same method as defined in tracing.ImageGenerationRecorder.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL