telemetry

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttrSpeechID   = "lk.speech_id"
	AttrAgentLabel = "lk.agent_label"
	AttrStartTime  = "lk.start_time"
	AttrEndTime    = "lk.end_time"
	AttrRetryCount = "lk.retry_count"

	AttrParticipantID       = "lk.participant_id"
	AttrParticipantIdentity = "lk.participant_identity"
	AttrParticipantKind     = "lk.participant_kind"

	AttrJobID          = "lk.job_id"
	AttrAgentName      = "lk.agent_name"
	AttrRoomName       = "lk.room_name"
	AttrSessionOptions = "lk.session_options"

	AttrAgentTurnID       = "lk.generation_id"
	AttrAgentParentTurnID = "lk.parent_generation_id"
	AttrUserInput         = "lk.user_input"
	AttrInstructions      = "lk.instructions"
	AttrSpeechInterrupted = "lk.interrupted"

	AttrChatCtx               = "lk.chat_ctx"
	AttrFunctionTools         = "lk.function_tools"
	AttrProviderTools         = "lk.provider_tools"
	AttrToolSets              = "lk.tool_sets"
	AttrResponseText          = "lk.response.text"
	AttrResponseFunctionCalls = "lk.response.function_calls"

	AttrFunctionToolID      = "lk.function_tool.id"
	AttrFunctionToolName    = "lk.function_tool.name"
	AttrFunctionToolArgs    = "lk.function_tool.arguments"
	AttrFunctionToolIsError = "lk.function_tool.is_error"
	AttrFunctionToolOutput  = "lk.function_tool.output"

	AttrTTSInputText = "lk.input_text"
	AttrTTSStreaming = "lk.tts.streaming"
	AttrTTSLabel     = "lk.tts.label"

	AttrEOUProbability       = "lk.eou.probability"
	AttrEOUUnlikelyThreshold = "lk.eou.unlikely_threshold"
	AttrEOUDelay             = "lk.eou.endpointing_delay"
	AttrEOULanguage          = "lk.eou.language"
	AttrUserTranscript       = "lk.user_transcript"
	AttrTranscriptConfidence = "lk.transcript_confidence"
	AttrTranscriptionDelay   = "lk.transcription_delay"
	AttrEndOfTurnDelay       = "lk.end_of_turn_delay"

	AttrGenAIOperationName     = "gen_ai.operation.name"
	AttrGenAIProviderName      = "gen_ai.provider.name"
	AttrGenAIRequestModel      = "gen_ai.request.model"
	AttrGenAIUsageInputTokens  = "gen_ai.usage.input_tokens"
	AttrGenAIUsageOutputTokens = "gen_ai.usage.output_tokens"
)

Variables

View Source
var ChatLogger log.Logger
View Source
var Tracer = otel.Tracer("livekit-agents")

Functions

func InitLoggerProvider

func InitLoggerProvider(ctx context.Context, endpoint string, headers map[string]string) error

func LogMetrics

func LogMetrics(metrics AgentMetrics)

func NewLLMSpan

func NewLLMSpan(ctx context.Context, model, provider string) (context.Context, trace.Span)

func NewSTTStreamSpan

func NewSTTStreamSpan(ctx context.Context, model, provider string) (context.Context, trace.Span)

func NewTTSStreamSpan

func NewTTSStreamSpan(ctx context.Context, model, provider string) (context.Context, trace.Span)

func RecordChatEvent

func RecordChatEvent(ctx context.Context, eventType string, body string, attributes map[string]interface{})

func ShutdownLoggerProvider

func ShutdownLoggerProvider(ctx context.Context) error

func StartSpan

func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)

Types

type AgentMetrics

type AgentMetrics interface {
	GetType() string
}

type CachedTokenDetails

type CachedTokenDetails struct {
	AudioTokens int
	TextTokens  int
	ImageTokens int
}

type EOUMetrics

type EOUMetrics struct {
	Timestamp                time.Time
	EndOfUtteranceDelay      float64
	TranscriptionDelay       float64
	OnUserTurnCompletedDelay float64
	SpeechID                 string
	Metadata                 *Metadata
}

func (*EOUMetrics) GetType

func (m *EOUMetrics) GetType() string

type HttpServer

type HttpServer struct {
	Host string
	Port int
	// contains filtered or unexported fields
}

func NewHttpServer

func NewHttpServer(host string, port int) *HttpServer

func (*HttpServer) Start

func (s *HttpServer) Start() error

func (*HttpServer) Stop

func (s *HttpServer) Stop(ctx context.Context) error

type InputTokenDetails

type InputTokenDetails struct {
	AudioTokens         int
	TextTokens          int
	ImageTokens         int
	CachedTokens        int
	CachedTokensDetails *CachedTokenDetails
}

type LLMMetrics

type LLMMetrics struct {
	Label              string
	RequestID          string
	Timestamp          time.Time
	Duration           float64
	TTFT               float64
	Cancelled          bool
	CompletionTokens   int
	PromptTokens       int
	PromptCachedTokens int
	TotalTokens        int
	TokensPerSecond    float64
	SpeechID           string
	Metadata           *Metadata
}

func (*LLMMetrics) GetType

func (m *LLMMetrics) GetType() string

type Metadata

type Metadata struct {
	ModelName     string
	ModelProvider string
}

type MetricLabels

type MetricLabels struct {
	AgentName           string
	AgentVersion        string
	RoomName            string
	ParticipantIdentity string
}

type MetricRegistry

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

func NewMetricRegistry

func NewMetricRegistry() *MetricRegistry

func (*MetricRegistry) GetUsageCollector

func (r *MetricRegistry) GetUsageCollector(labels MetricLabels) *UsageCollector

type OutputTokenDetails

type OutputTokenDetails struct {
	TextTokens  int
	AudioTokens int
	ImageTokens int
}

type RealtimeModelMetrics

type RealtimeModelMetrics struct {
	Label              string
	RequestID          string
	Timestamp          time.Time
	Duration           float64
	TTFT               float64
	Cancelled          bool
	InputTokens        int
	OutputTokens       int
	TotalTokens        int
	TokensPerSecond    float64
	InputTokenDetails  InputTokenDetails
	OutputTokenDetails OutputTokenDetails
	Metadata           *Metadata
}

func (*RealtimeModelMetrics) GetType

func (m *RealtimeModelMetrics) GetType() string

type STTMetrics

type STTMetrics struct {
	Label         string
	RequestID     string
	Timestamp     time.Time
	Duration      float64
	AudioDuration float64
	Streamed      bool
	Metadata      *Metadata
}

func (*STTMetrics) GetType

func (m *STTMetrics) GetType() string

type SpanContext

type SpanContext struct {
	SpeechID string
	Span     trace.Span
}

type TTSMetrics

type TTSMetrics struct {
	Label           string
	RequestID       string
	Timestamp       time.Time
	TTFB            float64
	Duration        float64
	AudioDuration   float64
	Cancelled       bool
	CharactersCount int
	Streamed        bool
	SegmentID       string
	SpeechID        string
	Metadata        *Metadata
}

func (*TTSMetrics) GetType

func (m *TTSMetrics) GetType() string

type UsageCollector

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

func NewUsageCollector

func NewUsageCollector() *UsageCollector

func (*UsageCollector) Collect

func (c *UsageCollector) Collect(metrics AgentMetrics)

func (*UsageCollector) GetSummary

func (c *UsageCollector) GetSummary() UsageSummary

type UsageSummary

type UsageSummary struct {
	LLMPromptTokens           int
	LLMPromptCachedTokens     int
	LLMInputAudioTokens       int
	LLMInputCachedAudioTokens int
	LLMInputTextTokens        int
	LLMInputCachedTextTokens  int
	LLMInputImageTokens       int
	LLMInputCachedImageTokens int
	LLMCompletionTokens       int
	LLMOutputAudioTokens      int
	LLMOutputImageTokens      int
	LLMOutputTextTokens       int
	TTSCharactersCount        int
	TTSAudioDuration          float64
	STTAudioDuration          float64
}

type VADMetrics

type VADMetrics struct {
	Label                  string
	Timestamp              time.Time
	IdleTime               float64
	InferenceDurationTotal float64
	InferenceCount         int
	Metadata               *Metadata
}

func (*VADMetrics) GetType

func (m *VADMetrics) GetType() string

Jump to

Keyboard shortcuts

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