luci: Index | Files

package monitor

import ""

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

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


Package Files

acq.go debug.go doc.go fake.go http.go monitor.go nil.go serialize.go


var (
    // ProdxmonScopes is the list of oauth2 scopes needed on the http client
    // given to NewHTTPMonitor.
    ProdxmonScopes = []string{""}

func SerializeCells Uses

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

SerializeCells creates a MetricsCollection message from a slice of cells.

func SerializeDataSet Uses

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 Uses

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

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

type Fake Uses

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

Fake is a fake Monitor.

func (*Fake) ChunkSize Uses

func (m *Fake) ChunkSize() int

ChunkSize returns the fake value.

func (*Fake) Close Uses

func (m *Fake) Close() error

Close always works.

func (*Fake) Send Uses

func (m *Fake) Send(c context.Context, cells []types.Cell) error

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

type Monitor Uses

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(ctx context.Context, cells []types.Cell) 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 Uses

func NewDebugMonitor(path string) Monitor

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

func NewHTTPMonitor Uses

func NewHTTPMonitor(ctx context.Context, client *http.Client, endpoint *url.URL) (Monitor, error)

NewHTTPMonitor creates a new Monitor object that sends metric to an HTTP (or HTTPS) endpoint. The http client should be authenticated as required.

func NewNilMonitor Uses

func NewNilMonitor() Monitor

NewNilMonitor returns a Monitor that does nothing.

Package monitor imports 17 packages (graph) and is imported by 12 packages. Updated 2021-01-21. Refresh now. Tools for package owners.