metricnamestats

package
v1.102.16 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StatRecord

type StatRecord struct {
	MetricName    string
	RequestsCount uint64
	LastRequestTs uint64
}

StatRecord defines stat record for given metric name

type StatsResult

type StatsResult struct {
	CollectedSinceTs uint64
	TotalRecords     uint64
	MaxSizeBytes     uint64
	CurrentSizeBytes uint64
	Records          []StatRecord
}

StatsResult defines stats result for GetStats request

func (*StatsResult) DeduplicateMergeRecords

func (sr *StatsResult) DeduplicateMergeRecords()

DeduplicateMergeRecords performs merging duplicate records by metric name

It is usual case for global tenant request at cluster version.

func (*StatsResult) Merge

func (sr *StatsResult) Merge(src *StatsResult)

Merge adds records from given src

It expected src to be sorted by metricName

func (*StatsResult) Sort

func (sr *StatsResult) Sort()

Sort sorts records by metric name and requests count

type Tracker

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

Tracker implements in-memory tracker for timeseries metric names it tracks ingest and query requests for metric names and collects statistics

main purpose of this tracker is to provide insights about metrics that have never been queried

func MustLoadFrom

func MustLoadFrom(loadPath string, maxSizeBytes uint64) *Tracker

MustLoadFrom inits tracker from the given on-disk path

func (*Tracker) GetStats

func (mt *Tracker) GetStats(limit, le int, matchPattern string) StatsResult

GetStats returns stats response for the tracked metrics

DeduplicateMergeRecords must be called at cluster version on returned result.

func (*Tracker) GetStatsForTenant

func (mt *Tracker) GetStatsForTenant(accountID, projectID uint32, limit, le int, matchPattern string) StatsResult

GetStatsForTenant returns stats response for the tracked metrics for given tenant

func (*Tracker) IsEmpty

func (mt *Tracker) IsEmpty() bool

IsEmpty checks if internal state has any records

func (*Tracker) MustClose

func (mt *Tracker) MustClose()

MustClose closes tracker and saves state on disk

func (*Tracker) RegisterIngestRequest

func (mt *Tracker) RegisterIngestRequest(accountID, projectID uint32, metricName []byte)

RegisterIngestRequest tracks metric name ingestion

func (*Tracker) RegisterQueryRequest

func (mt *Tracker) RegisterQueryRequest(accountID, projectID uint32, metricName []byte)

RegisterQueryRequest tracks metric name at query request

func (*Tracker) Reset

func (mt *Tracker) Reset(onReset func())

Reset cleans stats, saves cache state and executes provided func

func (*Tracker) UpdateMetrics

func (mt *Tracker) UpdateMetrics(dst *TrackerMetrics)

UpdateMetrics writes internal metrics to the provided object

type TrackerMetrics

type TrackerMetrics struct {
	CurrentSizeBytes  uint64
	CurrentItemsCount uint64
	MaxSizeBytes      uint64
}

TrackerMetrics holds metrics to report

Jump to

Keyboard shortcuts

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