monitor

package
v0.0.0-...-d3e053c Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 18 Imported by: 12

Documentation

Overview

Package monitor contains the code for sending metric data to monitoring endpoints.

Package monitor contains the code for sending metric data to monitoring endpoints.

Index

Constants

View Source
const (
	// MetricNamePrefix is the prefix for all tsmon metrics.
	MetricNamePrefix = "/chrome/infra/"
	// ProdXMonScope is an OAuth2 scope required by ProdX Mon API.
	ProdXMonScope = "https://www.googleapis.com/auth/prodxmon"
)

Variables

This section is empty.

Functions

func SerializeCells

func SerializeCells(cells []types.Cell, now time.Time) []*pb.MetricsCollection

SerializeCells creates a MetricsCollection message from a slice of cells.

func SerializeDataSet

func SerializeDataSet(c types.Cell) *pb.MetricsDataSet

SerializeDataSet creates a new MetricsDataSet without any data, but just with the metric metadata fields populated.

func SerializeValue

func SerializeValue(c types.Cell, now time.Time) *pb.MetricsData

SerializeValue creates a new MetricsData representing this cell's value.

Types

type Fake

type Fake struct {
	CS      int
	Cells   [][]types.Cell
	SendErr error
}

Fake is a fake Monitor.

func (*Fake) ChunkSize

func (m *Fake) ChunkSize() int

ChunkSize returns the fake value.

func (*Fake) Close

func (m *Fake) Close() error

Close always works.

func (*Fake) Send

func (m *Fake) Send(ctx context.Context, cells []types.Cell, now time.Time) error

Send appends the cells to Cells, unless SendErr is set.

type Monitor

type Monitor interface {
	// ChunkSize returns the maximum number of metrics this Monitor can Send in
	// one go.
	//
	// If there are more metrics, they will be broken up into chunks and Send will
	// be called multiple times. A ChunkSize of 0 disables chunking.
	ChunkSize() int

	// Send uploads a chunk of cells to the backend.
	//
	// Can be called concurrently with other Send calls.
	Send(ctx context.Context, cells []types.Cell, now time.Time) error

	// Close closes any resources held by the monitor.
	//
	// Close need not be called at program exit.
	Close() error
}

A Monitor can send a collection of metrics somewhere.

func NewDebugMonitor

func NewDebugMonitor(path string) Monitor

NewDebugMonitor returns a Monitor that outputs metrics to a log, and optionally a file on disk.

func NewGRPCMonitor

func NewGRPCMonitor(ctx context.Context, chunkSize int, conn *grpc.ClientConn) Monitor

NewGRPCMonitor creates a new Monitor that sends metric by gRPC with a given chunk size.

func NewNilMonitor

func NewNilMonitor() Monitor

NewNilMonitor returns a Monitor that does nothing.

Jump to

Keyboard shortcuts

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