stats

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tokens

func Tokens(text string) (int, error)

Tokens counts the number of tokens in a given text using the tiktoken library.

Types

type Entry

type Entry struct {
	// Title is the name of the statistic.
	Title string

	// Value is the value of the statistic, formatted as a string.
	Value string
}

Entry is a struct that represents a single entry in the statistics.

type Stats

type Stats struct {
	// name is a string that represents the name of the statistics.
	Name string
	// contains filtered or unexported fields
}

Stats is a struct that contains interaction statistics between components.

func (*Stats) A2AMessages

func (s *Stats) A2AMessages() int

A2AMessages returns the number of A2A requests.

func (*Stats) A2AReq

func (s *Stats) A2AReq(duration time.Duration, reqt, respt, reqb, respb int)

A2AReq records a request statistics made to the A2A service.

func (*Stats) Add added in v0.2.1

func (s *Stats) Add(other *Stats) *Stats

Add combines the current Stats instance with another and returns a new Stats instance. It does not mutate either of the original Stats instances.

func (*Stats) AverageA2AReqBytes

func (s *Stats) AverageA2AReqBytes() float64

AverageA2AReqBytes calculates the average number of A2A request bytes.

func (*Stats) AverageA2AReqDuration

func (s *Stats) AverageA2AReqDuration() time.Duration

AverageA2AReqDuration calculates the average duration of A2A requests.

func (*Stats) AverageA2AReqTokens

func (s *Stats) AverageA2AReqTokens() float64

AverageA2AReqTokens calculates the average number of A2A request tokens.

func (*Stats) AverageA2ARespBytes

func (s *Stats) AverageA2ARespBytes() float64

AverageA2ARespBytes calculates the average number of A2A response bytes.

func (*Stats) AverageA2ARespTokens

func (s *Stats) AverageA2ARespTokens() float64

AverageA2ARespTokens calculates the average number of A2A response tokens.

func (*Stats) AverageLLMReqBytes

func (s *Stats) AverageLLMReqBytes() float64

AverageLLMReqBytes calculates the average number of LLM request bytes.

func (*Stats) AverageLLMReqDuration

func (s *Stats) AverageLLMReqDuration() time.Duration

AverageLLMReqDuration calculates the average duration of LLM requests.

func (*Stats) AverageLLMReqTokens

func (s *Stats) AverageLLMReqTokens() float64

AverageLLMReqTokens calculates the average number of LLM request tokens.

func (*Stats) AverageLLMRespBytes

func (s *Stats) AverageLLMRespBytes() float64

AverageLLMRespBytes calculates the average number of LLM response bytes.

func (*Stats) AverageLLMRespTokens

func (s *Stats) AverageLLMRespTokens() float64

AverageLLMRespTokens calculates the average number of LLM response tokens.

func (*Stats) Entries

func (s *Stats) Entries() []Entry

Entries generates a list of statistics entries.

func (*Stats) LLMReq

func (s *Stats) LLMReq(duration time.Duration, reqt, respt, reqb, respb int)

LLMReq records a request statistics made to the LLM.

func (*Stats) TotalA2ABytes

func (s *Stats) TotalA2ABytes() int

TotalA2ABytes calculates the total A2A bytes (request + response).

func (*Stats) TotalA2AReqBytes

func (s *Stats) TotalA2AReqBytes() int

TotalA2AReqBytes calculates the total A2A request bytes.

func (*Stats) TotalA2AReqDuration

func (s *Stats) TotalA2AReqDuration() time.Duration

TotalA2AReqDuration calculates the total duration of A2A requests.

func (*Stats) TotalA2AReqTokens

func (s *Stats) TotalA2AReqTokens() int

TotalA2AReqTokens calculates the total A2A request tokens.

func (*Stats) TotalA2ARespBytes

func (s *Stats) TotalA2ARespBytes() int

TotalA2ARespBytes calculates the total A2A response bytes.

func (*Stats) TotalA2ARespTokens

func (s *Stats) TotalA2ARespTokens() int

TotalA2ARespTokens calculates the total A2A response tokens.

func (*Stats) TotalA2ATokens

func (s *Stats) TotalA2ATokens() int

TotalA2ATokens calculates the total A2A tokens (request + response).

func (*Stats) TotalLLMBytes

func (s *Stats) TotalLLMBytes() int

TotalLLMBytes calculates the total LLM bytes (request + response).

func (*Stats) TotalLLMReqBytes

func (s *Stats) TotalLLMReqBytes() int

TotalLLMReqBytes calculates the total LLM request bytes.

func (*Stats) TotalLLMReqDuration

func (s *Stats) TotalLLMReqDuration() time.Duration

TotalLLMReqDuration calculates the total duration of LLM requests.

func (*Stats) TotalLLMReqTokens

func (s *Stats) TotalLLMReqTokens() int

TotalLLMReqTokens calculates the total LLM request tokens.

func (*Stats) TotalLLMRequests

func (s *Stats) TotalLLMRequests() []time.Duration

TotalLLMRequests returns a copy of the total LLM requests durations.

func (*Stats) TotalLLMRespBytes

func (s *Stats) TotalLLMRespBytes() int

TotalLLMRespBytes calculates the total LLM response bytes.

func (*Stats) TotalLLMRespTokens

func (s *Stats) TotalLLMRespTokens() int

TotalLLMRespTokens calculates the total LLM response tokens.

func (*Stats) TotalLLMTokens

func (s *Stats) TotalLLMTokens() int

TotalLLMTokens calculates the total LLM tokens (request + response).

type Writer

type Writer interface {
	Print(stats ...*Stats) error
}

Writer writes Stats to a prarticular output.

func NewCSVWriter

func NewCSVWriter(path string) Writer

NewCSVWriter created an instance of StatsWriter that saves statistics in CSV format.

func NewStdWriter

func NewStdWriter(logger log.Logger) Writer

NewStdWriter creates an instance of StatsWriter that prints statistics to the stdout.

Jump to

Keyboard shortcuts

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