metrics

package
v0.0.0-...-94d7571 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package metrics exposes VM- and browser-level metrics in the Prometheus text exposition format, intended to be scraped by an external collector and aggregated across VMs. Metrics carry no per-session or per-user labels; instance identity is expected to be attached (and later aggregated away) by the scraper.

Index

Constants

This section is empty.

Variables

View Source
var DefaultUMAHistograms = []UMAHistogram{
	{Name: "PageLoad.PaintTiming.NavigationToFirstContentfulPaint", Bounds: boundsPageLoadMs},
	{Name: "PageLoad.PaintTiming.NavigationToLargestContentfulPaint2", Bounds: boundsPageLoadMs},
	{Name: "PageLoad.DocumentTiming.NavigationToDOMContentLoadedEventFired", Bounds: boundsPageLoadMs},
	{Name: "PageLoad.DocumentTiming.NavigationToLoadEventFired", Bounds: boundsPageLoadMs},
	{Name: "PageLoad.ParseTiming.NavigationToParseStart", Bounds: boundsPageLoadMs},

	{Name: "PageLoad.InteractiveTiming.UserInteractionLatency.HighPercentile2.MaxEventDuration", Bounds: boundsInteractionMs},

	{Name: "PageLoad.InteractiveTiming.FirstInputDelay4", Bounds: boundsInteractionMs},

	{Name: "PageLoad.InteractiveTiming.NumInteractions", Bounds: boundsCount},

	{Name: "PageLoad.LayoutInstability.MaxCumulativeShiftScore.SessionWindow.Gap1000ms.Max5000ms2", Bounds: boundsShiftScore},

	{Name: "PageLoad.Cpu.TotalUsage", Bounds: boundsCPUMs},

	{Name: "Startup.FirstWebContents.NonEmptyPaint3", Bounds: boundsPageLoadMs},

	{Name: "Memory.GPU.PeakMemoryUsage2.Scroll", Bounds: boundsMB},
}

DefaultUMAHistograms is the curated set of Chrome UMA histograms exposed on the metrics endpoint. Units are milliseconds unless noted. Histograms with no samples yet are simply absent from the output.

Only histograms recorded in the browser process are eligible: Browser.getHistograms cannot see renderer/GPU-process histograms (e.g. EventLatency.*, Graphics.Smoothness.*, Blink.*) because those only merge into the browser's recorder when a UMA log is staged or chrome://histograms is opened, neither of which happens on our images.

Functions

func Handler

func Handler(log *slog.Logger, collectors ...Collector) http.Handler

Handler serves GET /metrics. Scrapes are serialized: concurrent requests wait rather than probing Chrome and nvidia-smi in parallel. Each collector writes into its own buffer that is appended only on success, so a failure never leaves a partially written metric family in the response.

Types

type ChromeCollector

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

ChromeCollector reads browser-wide metrics over CDP: UMA histograms via Browser.getHistograms plus the browser version and open page count. All commands are browser-level — nothing attaches to pages or injects into sessions, so scrapes are invisible to automation running in the browser.

func NewChromeCollector

func NewChromeCollector(upstream DevToolsUpstream) *ChromeCollector

func (*ChromeCollector) Collect

func (c *ChromeCollector) Collect(ctx context.Context, w *Writer) error

func (*ChromeCollector) Name

func (c *ChromeCollector) Name() string

type Collector

type Collector interface {
	// Name identifies the collector in error logs.
	Name() string
	// Collect appends samples to w. On error the collector's entire
	// output is discarded — partially written metric families never reach
	// the scraper — and the other collectors' output is still served.
	Collect(ctx context.Context, w *Writer) error
}

Collector renders one group of metrics for a single scrape.

type DevToolsUpstream

type DevToolsUpstream interface {
	Current() string
}

DevToolsUpstream reports the current browser-level DevTools WebSocket URL. Satisfied by devtoolsproxy.UpstreamManager.

type GPUCollector

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

GPUCollector reports GPU presence and, when a GPU is attached, vGPU license state and utilization read from nvidia-smi. On VMs without the NVIDIA driver it emits only kernel_gpu_present 0.

func NewGPUCollector

func NewGPUCollector() *GPUCollector

func (*GPUCollector) Collect

func (c *GPUCollector) Collect(ctx context.Context, w *Writer) error

func (*GPUCollector) Name

func (c *GPUCollector) Name() string

type Label

type Label struct {
	Name  string
	Value string
}

Label is a single Prometheus label pair.

type OTLPCollector

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

OTLPCollector reports OTLP export health: records dropped under backpressure, failed export requests, and records successfully exported. All are process-lifetime counters with no labels; the scraper attaches instance identity.

func NewOTLPCollector

func NewOTLPCollector(src OTLPSource) *OTLPCollector

func (*OTLPCollector) Collect

func (c *OTLPCollector) Collect(_ context.Context, w *Writer) error

func (*OTLPCollector) Name

func (c *OTLPCollector) Name() string

type OTLPSource

type OTLPSource interface {
	Dropped() uint64
	Failures() uint64
	Exported() uint64
}

OTLPSource exposes the OTLP export sink's lifetime counters. Implemented by *events.OTLPMetrics.

type SystemCollector

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

SystemCollector reports VM-level resource metrics from /proc plus aggregate stats for the Chromium process tree.

func NewSystemCollector

func NewSystemCollector() *SystemCollector

func (*SystemCollector) Collect

func (c *SystemCollector) Collect(ctx context.Context, w *Writer) error

func (*SystemCollector) Name

func (c *SystemCollector) Name() string

type UMAHistogram

type UMAHistogram struct {
	Name   string
	Bounds []int64
}

UMAHistogram is one curated Chrome histogram plus the fixed bucket boundaries it is re-bucketed onto for exposition.

type Writer

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

Writer accumulates Prometheus text-format output.

func (*Writer) Bytes

func (w *Writer) Bytes() []byte

func (*Writer) Metric

func (w *Writer) Metric(name, help, typ string)

Metric writes the HELP and TYPE header lines for a metric family.

func (*Writer) Sample

func (w *Writer) Sample(name string, labels []Label, value float64)

Sample writes one sample line. name may carry a family suffix such as _bucket, _sum, or _count for histogram families.

Jump to

Keyboard shortcuts

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