Documentation
¶
Index ¶
- Constants
- func ReadAllCounters(metricsVec *prometheus.MetricVec, labels prometheus.Labels) float64
- func ReadCounter(counter prometheus.Counter) float64
- func ReadHistogram(counter prometheus.Histogram) *dto.Metric
- func ReadHistogramSum(histogram prometheus.Histogram) float64
- func WithCommonMetric(ctx context.Context, commonMetric *Common) context.Context
- func WithMetric(ctx context.Context, metrics *Metrics) context.Context
- type Common
- type Metrics
Constants ¶
const ( TableStatePending = "pending" // for the TableCounter labels, below too TableStateImported = "imported" TableStateCompleted = "completed" StateTotalRestore = "total_restore" // total source data bytes needs to restore StateRestored = "restored" // source data bytes restored during restore engine StateRestoreWritten = "written" // kv bytes written during restore engine StateImported = "imported" // kv bytes imported during import engine ProgressPhaseTotal = "total" // total restore progress(not include post-process, like checksum and analyze) ProgressPhaseRestore = "restore" // restore engine progress ProgressPhaseImport = "import" // import engine progress TableResultSuccess = "success" // for the TableCounter labels, below too TableResultFailure = "failure" ChunkStateEstimated = "estimated" // for the ChunkCounter labels, below too ChunkStatePending = "pending" ChunkStateRunning = "running" ChunkStateFinished = "finished" ChunkStateFailed = "failed" SSTProcessSplit = "split" // for the SSTSecondsHistogram labels, below too SSTProcessWrite = "write" SSTProcessIngest = "ingest" BlockDeliverKindIndex = "index" BlockDeliverKindData = "data" )
metric label values.
Variables ¶
This section is empty.
Functions ¶
func ReadAllCounters ¶
func ReadAllCounters(metricsVec *prometheus.MetricVec, labels prometheus.Labels) float64
ReadAllCounters reports the summary value of the counters with given labels.
func ReadCounter ¶
func ReadCounter(counter prometheus.Counter) float64
ReadCounter reports the current value of the counter.
func ReadHistogram ¶
func ReadHistogram(counter prometheus.Histogram) *dto.Metric
ReadHistogram reports the current value of the histogram. for test only.
func ReadHistogramSum ¶
func ReadHistogramSum(histogram prometheus.Histogram) float64
ReadHistogramSum reports the sum of all observed values in the histogram.
func WithCommonMetric ¶
WithCommonMetric returns a new context with the provided common metrics.
Types ¶
type Common ¶
type Common struct {
ChunkCounter *prometheus.CounterVec
// BytesCounter records the total bytes processed.
// it has a state label, values includes:
// - total_restore: total source file bytes needs to restore, it's constant.
// - restored: source file bytes restored, i.e. encoded and sorted.
// - written: kv bytes written during encode & sort.
// - imported: kv bytes imported during import engine(this value don't account for replica).
BytesCounter *prometheus.CounterVec
RowsCounter *prometheus.CounterVec
// RowReadSecondsHistogram records the time spent on reading a batch of rows.
// for each row, the time includes time spend on reading from file,
// decompress if needed, and parsing into row data.
// then sum up all rows in a batch, and record the time.
RowReadSecondsHistogram prometheus.Histogram
// RowEncodeSecondsHistogram records the time spent on encoding a batch of rows.
RowEncodeSecondsHistogram prometheus.Histogram
BlockDeliverSecondsHistogram prometheus.Histogram
BlockDeliverBytesHistogram *prometheus.HistogramVec
BlockDeliverKVPairsHistogram *prometheus.HistogramVec
}
Common contains metrics shared for lightning and import-into. they will have different namespace. metrics here will have an additional task-id const-label when used for import-into.
func GetCommonMetric ¶
GetCommonMetric returns the common metrics stored in the context.
func NewCommon ¶
func NewCommon(factory promutil.Factory, namespace, subsystem string, constLabels prometheus.Labels) *Common
NewCommon returns common metrics instance.
func (*Common) RegisterTo ¶
RegisterTo registers all metrics to the given registry.
func (*Common) UnregisterFrom ¶
UnregisterFrom unregisters all metrics from the given registry.
type Metrics ¶
type Metrics struct {
ImporterEngineCounter *prometheus.CounterVec
IdleWorkersGauge *prometheus.GaugeVec
KvEncoderCounter *prometheus.CounterVec
TableCounter *prometheus.CounterVec
ProcessedEngineCounter *prometheus.CounterVec
ImportSecondsHistogram prometheus.Histogram
ChunkParserReadBlockSecondsHistogram prometheus.Histogram
ApplyWorkerSecondsHistogram *prometheus.HistogramVec
RowKVDeliverSecondsHistogram prometheus.Histogram
// RowReadBytesHistogram records the number of bytes read from data source
// for a batch of rows.
// it's a little duplicate with RowsCounter of state = "restored".
RowReadBytesHistogram prometheus.Histogram
ChecksumSecondsHistogram prometheus.Histogram
SSTSecondsHistogram *prometheus.HistogramVec
LocalStorageUsageBytesGauge *prometheus.GaugeVec
ProgressGauge *prometheus.GaugeVec
*Common
}
Metrics contains all metrics used by lightning.
func FromContext ¶
FromContext returns the metrics stored in the context.
func NewMetrics ¶
NewMetrics creates a new empty metrics.
func (*Metrics) RecordEngineCount ¶
RecordEngineCount records the number of engines processed.
func (*Metrics) RecordTableCount ¶
RecordTableCount records the number of tables processed.
func (*Metrics) RegisterTo ¶
RegisterTo registers all metrics to the given registry.
func (*Metrics) UnregisterFrom ¶
UnregisterFrom unregisters all metrics from the given registry.