metrics

package
v0.1.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatCompletion

type ChatCompletion interface {
	// StartRequest initializes timing for a new request.
	StartRequest()
	// SetModel sets the model the request. This is usually called after parsing the request body .
	SetModel(model string)
	// SetBackend sets the selected backend when the routing decision has been made. This is usually called
	// after parsing the request body to determine the model and invoke the routing logic.
	SetBackend(backend filterapi.Backend)

	// RecordTokenUsage records token usage metrics.
	RecordTokenUsage(ctx context.Context, inputTokens, outputTokens, totalTokens uint32)
	// RecordRequestCompletion records latency metrics for the entire request
	RecordRequestCompletion(ctx context.Context, success bool)
	// RecordTokenLatency records latency metrics for token generation.
	RecordTokenLatency(ctx context.Context, tokens uint32)
}

ChatCompletion is the interface for the chat completion AI Gateway metrics.

func NewChatCompletion

func NewChatCompletion(meter metric.Meter) ChatCompletion

NewChatCompletion creates a new ChatCompletion instance.

Jump to

Keyboard shortcuts

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