stats

package
v0.0.0-...-d9b4d38 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package stats contains functionality that is used to parse the log file produced by reproxy, to extract stat information.

Index

Constants

View Source
const (
	// AggregatedMetricsFileBaseName is the base name of the rbe metric file.
	//
	// We typically work with two rbe_metrics files:
	//   rbe_metrics.pb
	//   rbe_metrics.txt
	AggregatedMetricsFileBaseName = "rbe_metrics"
)

Variables

This section is empty.

Functions

func BandwidthStats

func BandwidthStats(s *spb.Stats) (string, string)

BandwidthStats returns the human readable form of download and uplaod bandwidth consumed by reproxy.

func CompletionStats

func CompletionStats(s *spb.Stats) string

CompletionStats returns the human readable form of the number of actions executed by reproxy grouped by their completion status.

func FromSeriesToProto

func FromSeriesToProto(name string, rawValues []int64) *stpb.Stat

FromSeriesToProto creates a Stat proto, and set its statistical properties based on input vals.

func WriteFromRecords

func WriteFromRecords(recs []*lpb.LogRecord, pInfo []*lpb.ProxyInfo, outputDir string)

WriteFromRecords aggregates records, adds tool version and environment variables, and dumps the result to files in both ASCII and binary formats.

func WriteStats

func WriteStats(sPb *spb.Stats, outputdir string) error

WriteStats writes stats to a file.

Types

type ProtoSaver

type ProtoSaver struct {
	*spb.Stats
}

ProtoSaver is an implentation of bigquery.ValueSaver for spb.Stats

func (*ProtoSaver) Save

func (vs *ProtoSaver) Save() (map[string]bigquery.Value, string, error)

Save implements the bigquery.ValueSaver interface.

type Stat

type Stat struct {
	// The number of all the true values for bools, the sum of all the values for ints.
	Count int64

	// For enum stats, the count of each value.
	CountByValue map[string]int64

	// Commands that have the highest values.
	Outlier1, Outlier2 *stpb.Outlier

	Median, Percentile75, Percentile85, Percentile95 int64
	Average                                          float64
	// contains filtered or unexported fields
}

Stat is a collection of aggregated metrics for a single field.

func (*Stat) IsEmpty

func (st *Stat) IsEmpty() bool

IsEmpty returns whether the Stat has any non-0 values.

type StatCollector

type StatCollector interface {
	AddRecord(lr *lpb.LogRecord)
	FinalizeAggregate(pInfos []*lpb.ProxyInfo)
	ToProto() *spb.Stats
}

StatCollector is the interface for the Stats type for testing.

type Stats

type Stats struct {
	NumRecords int64

	Stats map[string]*Stat

	ProxyInfos []*lpb.ProxyInfo
	// contains filtered or unexported fields
}

Stats is a collection of Stat by field name.

func New

func New() *Stats

New creates a new empty Stats object.

func NewFromRecords

func NewFromRecords(recs []*lpb.LogRecord, pInfos []*lpb.ProxyInfo) *Stats

NewFromRecords creates a new Stats from the given Records.

func (*Stats) AddRecord

func (s *Stats) AddRecord(r *lpb.LogRecord)

AddRecord adds the log record to the statTree. It is not thread safe.

func (*Stats) FinalizeAggregate

func (s *Stats) FinalizeAggregate(pInfos []*lpb.ProxyInfo)

FinalizeAggregate aggregates and finalizes all Stats.

func (*Stats) ToProto

func (s *Stats) ToProto() *spb.Stats

ToProto returns the proto representation of the Stats.

Jump to

Keyboard shortcuts

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