Documentation ¶
Overview ¶
Package metrics queries metrics collected by Chrome.
Index ¶
- func ClearHistogramTransferFile() error
- func SaveHistogramsMeanValue(ctx context.Context, pv *perf.Values, histograms []*Histogram, ...) error
- type Histogram
- func DiffHistograms(older, newer []*Histogram) ([]*Histogram, error)
- func GetHistogram(ctx context.Context, tconn *chrome.TestConn, name string) (*Histogram, error)
- func GetHistograms(ctx context.Context, tconn *chrome.TestConn, histogramNames []string) ([]*Histogram, error)
- func Run(ctx context.Context, tconn *chrome.TestConn, f func(ctx context.Context) error, ...) ([]*Histogram, error)
- func RunAndWaitAll(ctx context.Context, tconn *chrome.TestConn, timeout time.Duration, ...) ([]*Histogram, error)
- func RunAndWaitAny(ctx context.Context, tconn *chrome.TestConn, timeout time.Duration, ...) ([]*Histogram, error)
- func WaitForHistogram(ctx context.Context, tconn *chrome.TestConn, name string, ...) (*Histogram, error)
- func WaitForHistogramUpdate(ctx context.Context, tconn *chrome.TestConn, name string, old *Histogram, ...) (*Histogram, error)
- type HistogramBucket
- type Recorder
- func (r *Recorder) Histogram(ctx context.Context, tconn *chrome.TestConn) ([]*Histogram, error)
- func (r *Recorder) WaitAll(ctx context.Context, tconn *chrome.TestConn, timeout time.Duration) ([]*Histogram, error)
- func (r *Recorder) WaitAny(ctx context.Context, tconn *chrome.TestConn, timeout time.Duration) ([]*Histogram, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearHistogramTransferFile ¶
func ClearHistogramTransferFile() error
ClearHistogramTransferFile clears the histogramTransferFile. The histogramTransferFile is how Histograms get from ChromeOS services into Chrome -- ChromeOS services write their updates to the file, and periodicially, Chrome's chromeos::ExternalMetrics services scrapes the file and adds the Histograms to its own internal list which this package queries.
While this system works well in production, it can be a source of unexpected asynchronous changes in Histograms during tests. Tests intending to watch a Histogram which originates in ChromeOS should clear this file before establishing a "before" Histogram. This will avoid having events from previous tests show up as unexpected diffs in the current test.
Types ¶
type Histogram ¶
type Histogram struct { // Name of the histogram. Name string // The sum of the all entries in the histogram. Sum int64 `json:"sum"` // Buckets contains ranges of reported values. // The buckets are disjoint and stored in ascending order. Buckets []HistogramBucket `json:"buckets"` }
Histogram contains data from a single Chrome histogram.
func DiffHistograms ¶
DiffHistograms is a convenience function to diff multiple histograms.
func GetHistogram ¶
GetHistogram returns the current state of a Chrome histogram (e.g. "Tabs.TabCountActiveWindow"). If no samples have been reported for the histogram since Chrome was started, the zero value for Histogram is returned.
func GetHistograms ¶
func GetHistograms(ctx context.Context, tconn *chrome.TestConn, histogramNames []string) ([]*Histogram, error)
GetHistograms is a convenience function to get multiple histograms.
func Run ¶
func Run(ctx context.Context, tconn *chrome.TestConn, f func(ctx context.Context) error, names ...string) ([]*Histogram, error)
Run is a helper to calculate histogram diffs before and after running a given function.
func RunAndWaitAll ¶
func RunAndWaitAll(ctx context.Context, tconn *chrome.TestConn, timeout time.Duration, f func(ctx context.Context) error, names ...string) ([]*Histogram, error)
RunAndWaitAll is a helper to calculate histogram diffs before and after running a given function. It waits for all the histograms before return if there are histograms to wait. Otherwise, it returns immediately like Run.
func RunAndWaitAny ¶
func RunAndWaitAny(ctx context.Context, tconn *chrome.TestConn, timeout time.Duration, f func(ctx context.Context) error, names ...string) ([]*Histogram, error)
RunAndWaitAny is a helper to calculate histogram diffs before and after running a given function. It waits for any one of the histograms before return if there are histograms to wait. Otherwise, it returns immediately like Run.
func WaitForHistogram ¶
func WaitForHistogram(ctx context.Context, tconn *chrome.TestConn, name string, timeout time.Duration) (*Histogram, error)
WaitForHistogram is a convenience function that calls GetHistogram until the requested histogram is available, ctx's deadline is reached, or timeout (if positive) has elapsed.
func WaitForHistogramUpdate ¶
func WaitForHistogramUpdate(ctx context.Context, tconn *chrome.TestConn, name string, old *Histogram, timeout time.Duration) (*Histogram, error)
WaitForHistogramUpdate is a convenience function that calls GetHistogram until the requested histogram contains at least one sample not present in old, an earlier snapshot of the same histogram. A histogram containing the new samples is returned; see Histogram.Diff for details.
func (*Histogram) Diff ¶
Diff returns a histogram containing the additional samples in h that aren't in old, an older version of the same histogram. Buckets that haven't changed are omitted from the returned histogram. old must be an earlier snapshot -- an error is returned if any counts decreased or if old contains buckets not present in h.
func (*Histogram) Mean ¶
Mean calculates the estimated mean of the histogram values. It is an error when there are no data points.
func (*Histogram) String ¶
String contains a human-readable representation of h as "Name: [[0,5):2 [5,10):1 ...]", where each space-separated term is "[<min>,<max>):<count>".
func (*Histogram) TotalCount ¶
TotalCount returns the total number of samples stored across all buckets.
type HistogramBucket ¶
type HistogramBucket struct { // Min contains the minimum value that can be stored in this bucket. Min int64 `json:"min"` // Max contains the exclusive maximum value for this bucket. Max int64 `json:"max"` // Count contains the number of samples that are stored in this bucket. Count int64 `json:"count"` }
HistogramBucket contains a set of reported samples within a fixed range.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder tracks a snapshot to calculate diffs since start or last wait call.
func StartRecorder ¶
StartRecorder captures a snapshot to calculate histograms diffs later.