Documentation
¶
Index ¶
- Constants
- Variables
- func EmitBinlogBacklogGauges(emit Emitter, backlogSize, backlogCapacity int)
- func EmitGoRuntimeGauges(emit Emitter, m *runtime.MemStats, numGoroutine int)
- func EmitLagGauges(emit Emitter, replicationLagSeconds, heartbeatLagSeconds float64, ...)
- func EmitProgressGauges(emit Emitter, rowsCopied, rowsEstimate, dmlEventsApplied int64)
- func EmitThrottleActiveGauge(emit Emitter, active bool)
- func EmitThrottleInterval(emit Emitter, duration time.Duration, reason string)
- func RecordCutOverAttempt(emit Emitter, outcome string)
- func RecordCutOverPhase(emit Emitter, phase string, duration time.Duration, err error)
- func RecordCutOverTotal(emit Emitter, duration time.Duration, err error)
- func RecordQueryDuration(emit Emitter, side string, kind string, duration time.Duration, err error)
- func RecordSleep(emit Emitter, stage string, d time.Duration)
- func StartGoRuntimeReporter(ctx context.Context, client *Client, interval time.Duration)
- type Client
- type Emitter
Constants ¶
const ( CutOverOutcomeSuccess = "success" CutOverOutcomeRetry = "retry" CutOverOutcomeAbort = "abort" CutOverPhaseMagicLock = "magic_lock" CutOverPhaseOriginalTableLock = "original_table_lock" CutOverPhaseMagicRename = "magic_rename" CutOverPhaseUnlock = "unlock" )
Variables ¶
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 EmitBinlogBacklogGauges ¶ added in v1.1.11
EmitBinlogBacklogGauges emits apply-events queue depth gauges (namespace is applied by the client): gh_ost.binlog.backlog_size, gh_ost.binlog.backlog_capacity, gh_ost.binlog.backlog_utilization.
func EmitGoRuntimeGauges ¶
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 EmitLagGauges ¶ added in v1.1.11
func EmitLagGauges(emit Emitter, replicationLagSeconds, heartbeatLagSeconds float64, throttled bool)
EmitLagGauges emits replication and heartbeat lag gauges (namespace is applied by the client): gh_ost.lag.replication_seconds, gh_ost.lag.heartbeat_seconds, each tagged throttled:true|false.
These are point-in-time readings each status tick (not a distribution), so gauges are used rather than histograms; DogStatsD histogram aggregation exposes count/max series that do not match the log line lag values in Prometheus/Grafana.
func EmitProgressGauges ¶ added in v1.1.11
EmitProgressGauges emits row-copy and DML progress gauges (namespace is applied by the client): gh_ost.row_copy.rows_copied, gh_ost.row_copy.rows_estimate, gh_ost.dml.events_applied.
func EmitThrottleActiveGauge ¶ added in v1.1.11
EmitThrottleActiveGauge emits whether throttling is currently active.
func EmitThrottleInterval ¶ added in v1.1.11
EmitThrottleInterval emits one event and one duration sample for a completed throttled interval.
func RecordCutOverAttempt ¶ added in v1.1.11
RecordCutOverAttempt emits gh_ost.cut_over.attempts_total.
func RecordCutOverPhase ¶ added in v1.1.11
RecordCutOverPhase emits gh_ost.cut_over.phase_duration_milliseconds.
func RecordCutOverTotal ¶ added in v1.1.11
RecordCutOverTotal emits gh_ost.cut_over.total_duration_milliseconds for terminal cut-over outcomes.
func RecordQueryDuration ¶ added in v1.1.11
RecordQueryDuration emits gh_ost.query.duration_milliseconds with side/kind/outcome tags.
func RecordSleep ¶ added in v1.1.11
RecordSleep emits per-stage sleep/wait metrics (namespace is applied by the client): gh_ost.sleep.duration_milliseconds and gh_ost.sleep.total_milliseconds, both tagged by stage.
func StartGoRuntimeReporter ¶
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 ¶
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).
type Emitter ¶ added in v1.1.11
type Emitter interface {
Gauge(name string, value float64, tags ...string)
Count(name string, value int64, tags ...string)
Histogram(name string, value float64, tags ...string)
}
Emitter is the unified metrics abstraction implemented by *Client. Helpers in the metrics package take an Emitter so tests can supply spies without UDP.