Documentation
¶
Index ¶
- func ConfigureMetrics(logger zerolog.Logger) (http.Handler, error)
- func ConfigureOTel(ctx context.Context, endpoint, projectName string, token *BearerToken, ...) error
- func ContextWithSession(ctx context.Context, sessionID, userID string) context.Context
- func RecordGenAISessionDuration(ctx context.Context, provider, model string, seconds float64)
- func RecordGenAITimePerOutputToken(ctx context.Context, operation, provider, model string, seconds float64)
- func RecordGenAITimeToFirstToken(ctx context.Context, operation, provider, model string, seconds float64)
- func RecordGenAITokenUsage(ctx context.Context, operation, provider, model string, ...)
- func RecordGenAITokenUsageByModality(ctx context.Context, operation, provider, model, tokenType, modality string, ...)
- func RecordGenAIToolDuration(ctx context.Context, toolName string, seconds float64)
- func RecordMemorySearchDuration(ctx context.Context, mode string, seconds float64)
- func RecordMemorySearchPhase(ctx context.Context, phase string, seconds float64)
- type BearerToken
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureMetrics ¶
ConfigureMetrics installs a Prometheus-backed MeterProvider and registers the GenAI client metric instruments. It returns an http.Handler that serves the metrics in Prometheus text format (mount at /metrics). Metrics are pull-based and entirely independent of the OTLP trace export — nothing is pushed to the trace backend. Safe to call once at startup.
func ConfigureOTel ¶
func ConfigureOTel(ctx context.Context, endpoint, projectName string, token *BearerToken, logger zerolog.Logger) error
ConfigureOTel sets the global TracerProvider. When endpoint is empty, installs a no-op provider (zero overhead). Safe to call multiple times. A non-nil token is sent as a bearer header with every export.
func ContextWithSession ¶
ContextWithSession is the Go equivalent of Phoenix's setSession() — it stores session.id and user.id in baggage so the sessionBaggageProcessor stamps them onto every child span automatically. Phoenix indexes sessions on "session.id".
func RecordGenAISessionDuration ¶
RecordGenAISessionDuration records a completed voice session's wall-clock duration. No-op when not configured.
func RecordGenAITimePerOutputToken ¶
func RecordGenAITimePerOutputToken(ctx context.Context, operation, provider, model string, seconds float64)
RecordGenAITimePerOutputToken records TPOT: mean output streaming latency per output token within a turn (output-streaming duration ÷ output token count). No-op when not configured.
func RecordGenAITimeToFirstToken ¶
func RecordGenAITimeToFirstToken(ctx context.Context, operation, provider, model string, seconds float64)
RecordGenAITimeToFirstToken records time-to-first-token (TTFT): the latency from the end of user input to the first model output chunk. No-op when not configured.
func RecordGenAITokenUsage ¶
func RecordGenAITokenUsage(ctx context.Context, operation, provider, model string, inputTokens, outputTokens int64)
RecordGenAITokenUsage records the gen_ai.client.token.usage histogram, split by token type ("input"/"output"). No-op when metrics are not configured.
func RecordGenAITokenUsageByModality ¶
func RecordGenAITokenUsageByModality(ctx context.Context, operation, provider, model, tokenType, modality string, tokens int64)
RecordGenAITokenUsageByModality records the gen_ai.client.token.usage histogram split by token type ("input"/"output") AND modality ("audio"/"text"/…), so the metric reconciles to the per-modality Vertex Live billing SKUs (audio-in vs text-in vs audio-out vs text-out). tokenType is "input" or "output"; modality is the lower-cased SDK modality string. No-op when metrics are not configured or tokens <= 0.
func RecordGenAIToolDuration ¶
RecordGenAIToolDuration records a tool call's execution latency, labeled by tool name (gen_ai.tool.name). No-op when not configured.
func RecordMemorySearchDuration ¶
RecordMemorySearchDuration records a memory search's latency, labeled by mode ("lexical" for the no-network fast path, "fused" when semantic search ran). No-op when not configured.
Types ¶
type BearerToken ¶
type BearerToken struct {
// contains filtered or unexported fields
}
BearerToken sends an Authorization: Bearer header on every OTLP export. The token can arrive after the exporter starts (it is read from a Secret once the cluster cache syncs) and can change while running; until it is set, exports go out without the header and the collector decides what to do with them.
func (*BearerToken) GetRequestMetadata ¶
GetRequestMetadata implements grpc credentials.PerRPCCredentials.
func (*BearerToken) RequireTransportSecurity ¶
func (b *BearerToken) RequireTransportSecurity() bool
RequireTransportSecurity is false: the collector is usually a cluster-local Service reached over plaintext gRPC.