metrics

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Noop = &Client{}

Noop is a StatsD client that discards all metrics. NewClient("", ...) returns this exact pointer so callers can use `client == metrics.Noop`.

Functions

func EmitGoRuntimeGauges

func EmitGoRuntimeGauges(emit MemStatsGaugeEmitter, m *runtime.MemStats, numGoroutine int)

EmitGoRuntimeGauges emits gh_ost.go_runtime.* gauges (namespace is applied by the client). m and numGoroutine are typically from runtime.ReadMemStats and runtime.NumGoroutine.

func StartGoRuntimeReporter

func StartGoRuntimeReporter(ctx context.Context, client *Client, interval time.Duration)

StartGoRuntimeReporter periodically samples runtime memory and goroutines and emits gauges until ctx is cancelled. It is a no-op when interval <= 0, client is nil, or StatsD is disabled (noop client).

Types

type Client

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

Client wraps a StatsD client with namespace and global tags (from --statsd-tags).

func NewClient

func NewClient(addr string, tags []string, namespace string) (*Client, error)

NewClient connects to addr for StatsD. If addr is empty, returns Noop and nil error. namespace is typically "gh_ost." (metrics are named namespace + short name, e.g. gh_ost.startup). tags are global tags applied to every metric (repeatable --statsd-tags).

func (*Client) Close

func (c *Client) Close() error

Close flushes buffered metrics; safe for Noop.

func (*Client) Count

func (c *Client) Count(name string, value int64, tags ...string)

func (*Client) Gauge

func (c *Client) Gauge(name string, value float64, tags ...string)

type MemStatsGaugeEmitter

type MemStatsGaugeEmitter interface {
	Gauge(name string, value float64, tags ...string)
}

MemStatsGaugeEmitter is implemented by *Client; used for tests without UDP.

Jump to

Keyboard shortcuts

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