Help us shape the future of Go! Take the 2026 Go Developer Survey

stats

package
v1.21.1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthStats = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowStats   = fmt.Errorf("proto: integer overflow")
)

Functions

func IsEnabled added in v1.7.0

func IsEnabled(ctx context.Context) bool

IsEnabled returns whether stats tracking is enabled in the context.

func ShouldTrackHTTPGRPCResponse

func ShouldTrackHTTPGRPCResponse(r *httpgrpc.HTTPResponse) bool

Types

type QueryStats added in v1.15.0

type QueryStats struct {
	Stats
	QueryResponseSeries uint64
	PriorityAssigned    bool
	Priority            int64
	DataSelectMaxTime   int64
	DataSelectMinTime   int64
	SplitInterval       time.Duration
	// contains filtered or unexported fields
}

func ContextWithEmptyStats

func ContextWithEmptyStats(ctx context.Context) (*QueryStats, context.Context)

ContextWithEmptyStats returns a context with empty stats.

func FromContext

func FromContext(ctx context.Context) *QueryStats

FromContext gets the Stats out of the Context. Returns nil if stats have not been initialised in the context.

func (*QueryStats) AddExtraFields added in v1.15.0

func (s *QueryStats) AddExtraFields(fieldsVals ...any)

func (*QueryStats) AddFetchedChunkBytes added in v1.15.0

func (s *QueryStats) AddFetchedChunkBytes(bytes uint64)

func (*QueryStats) AddFetchedChunks added in v1.15.0

func (s *QueryStats) AddFetchedChunks(count uint64)

func (*QueryStats) AddFetchedDataBytes added in v1.15.0

func (s *QueryStats) AddFetchedDataBytes(bytes uint64)

func (*QueryStats) AddFetchedSamples added in v1.15.0

func (s *QueryStats) AddFetchedSamples(count uint64)

func (*QueryStats) AddFetchedSeries added in v1.15.0

func (s *QueryStats) AddFetchedSeries(series uint64)

func (*QueryStats) AddPeakSamples added in v1.19.0

func (s *QueryStats) AddPeakSamples(count uint64)

func (*QueryStats) AddQueryStorageWallTime added in v1.17.0

func (s *QueryStats) AddQueryStorageWallTime(t time.Duration)

AddQueryStorageWallTime adds some time to the counter.

func (*QueryStats) AddResponseSeries added in v1.19.0

func (s *QueryStats) AddResponseSeries(series uint64)

func (*QueryStats) AddScannedSamples added in v1.19.0

func (s *QueryStats) AddScannedSamples(count uint64)

func (*QueryStats) AddSplitQueries added in v1.17.0

func (s *QueryStats) AddSplitQueries(count uint64)

func (*QueryStats) AddStoreGatewayTouchedPostingBytes added in v1.18.0

func (s *QueryStats) AddStoreGatewayTouchedPostingBytes(bytes uint64)

func (*QueryStats) AddStoreGatewayTouchedPostings added in v1.18.0

func (s *QueryStats) AddStoreGatewayTouchedPostings(count uint64)

func (*QueryStats) AddWallTime added in v1.15.0

func (s *QueryStats) AddWallTime(t time.Duration)

AddWallTime adds some time to the counter.

func (*QueryStats) Copy added in v1.20.0

func (s *QueryStats) Copy() *QueryStats

func (*QueryStats) LoadDataSelectMaxTime added in v1.17.0

func (s *QueryStats) LoadDataSelectMaxTime() int64

func (*QueryStats) LoadDataSelectMinTime added in v1.17.0

func (s *QueryStats) LoadDataSelectMinTime() int64

func (*QueryStats) LoadExtraFields added in v1.15.0

func (s *QueryStats) LoadExtraFields() []any

func (*QueryStats) LoadFetchedChunkBytes added in v1.15.0

func (s *QueryStats) LoadFetchedChunkBytes() uint64

func (*QueryStats) LoadFetchedChunks added in v1.15.0

func (s *QueryStats) LoadFetchedChunks() uint64

func (*QueryStats) LoadFetchedDataBytes added in v1.15.0

func (s *QueryStats) LoadFetchedDataBytes() uint64

func (*QueryStats) LoadFetchedSamples added in v1.15.0

func (s *QueryStats) LoadFetchedSamples() uint64

func (*QueryStats) LoadFetchedSeries added in v1.15.0

func (s *QueryStats) LoadFetchedSeries() uint64

func (*QueryStats) LoadPeakSamples added in v1.19.0

func (s *QueryStats) LoadPeakSamples() uint64

func (*QueryStats) LoadPriority added in v1.17.0

func (s *QueryStats) LoadPriority() (int64, bool)

func (*QueryStats) LoadQueryStorageWallTime added in v1.17.0

func (s *QueryStats) LoadQueryStorageWallTime() time.Duration

LoadQueryStorageWallTime returns current query storage wall time.

func (*QueryStats) LoadResponseSeries added in v1.19.0

func (s *QueryStats) LoadResponseSeries() uint64

func (*QueryStats) LoadScannedSamples added in v1.19.0

func (s *QueryStats) LoadScannedSamples() uint64

func (*QueryStats) LoadSplitInterval added in v1.20.0

func (s *QueryStats) LoadSplitInterval() time.Duration

func (*QueryStats) LoadSplitQueries added in v1.17.0

func (s *QueryStats) LoadSplitQueries() uint64

func (*QueryStats) LoadStoreGatewayTouchedPostingBytes added in v1.18.0

func (s *QueryStats) LoadStoreGatewayTouchedPostingBytes() uint64

func (*QueryStats) LoadStoreGatewayTouchedPostings added in v1.18.0

func (s *QueryStats) LoadStoreGatewayTouchedPostings() uint64

func (*QueryStats) LoadWallTime added in v1.15.0

func (s *QueryStats) LoadWallTime() time.Duration

LoadWallTime returns current wall time.

func (*QueryStats) Merge added in v1.15.0

func (s *QueryStats) Merge(other *QueryStats)

Merge the provided Stats into this one.

func (*QueryStats) SetDataSelectMaxTime added in v1.17.0

func (s *QueryStats) SetDataSelectMaxTime(dataSelectMaxTime int64)

func (*QueryStats) SetDataSelectMinTime added in v1.17.0

func (s *QueryStats) SetDataSelectMinTime(dataSelectMinTime int64)

func (*QueryStats) SetPeakSamples added in v1.19.0

func (s *QueryStats) SetPeakSamples(count uint64)

func (*QueryStats) SetPriority added in v1.17.0

func (s *QueryStats) SetPriority(priority int64)

type Stats

type Stats struct {
	// The sum of all wall time spent in the querier to execute the query.
	WallTime time.Duration `protobuf:"bytes,1,opt,name=wall_time,json=wallTime,proto3,stdduration" json:"wall_time"`
	// The number of series fetched for the query
	FetchedSeriesCount uint64 `protobuf:"varint,2,opt,name=fetched_series_count,json=fetchedSeriesCount,proto3" json:"fetched_series_count,omitempty"`
	// The number of bytes of the chunks fetched for the query
	FetchedChunkBytes uint64 `protobuf:"varint,3,opt,name=fetched_chunk_bytes,json=fetchedChunkBytes,proto3" json:"fetched_chunk_bytes,omitempty"`
	// The number of bytes of data fetched for the query
	FetchedDataBytes uint64 `protobuf:"varint,4,opt,name=fetched_data_bytes,json=fetchedDataBytes,proto3" json:"fetched_data_bytes,omitempty"`
	// Extra fields to be reported on the stats log
	ExtraFields map[string]string `` /* 182-byte string literal not displayed */
	// The number of chunks fetched for the query
	FetchedChunksCount uint64 `protobuf:"varint,6,opt,name=fetched_chunks_count,json=fetchedChunksCount,proto3" json:"fetched_chunks_count,omitempty"`
	// The number of samples fetched for the query
	FetchedSamplesCount uint64 `protobuf:"varint,7,opt,name=fetched_samples_count,json=fetchedSamplesCount,proto3" json:"fetched_samples_count,omitempty"`
	// The limit hit when executing the query
	LimitHit string `protobuf:"bytes,8,opt,name=limit_hit,json=limitHit,proto3" json:"limit_hit,omitempty"`
	// The total number of split queries sent after going through all the middlewares.
	// It includes the number of requests that might be discarded by the queue.
	SplitQueries uint64 `protobuf:"varint,9,opt,name=split_queries,json=splitQueries,proto3" json:"split_queries,omitempty"`
	// The sum of wall time spent in the querier to fetch and merge data from storage.
	QueryStorageWallTime time.Duration `` /* 128-byte string literal not displayed */
	// The total number of postings touched in store gateway for a specific query.
	// Only successful requests from querier to store gateway are included.
	StoreGatewayTouchedPostingsCount uint64 `` /* 165-byte string literal not displayed */
	// The total size of postings touched in store gateway for a specific query, in bytes.
	// Only successful requests from querier to store gateway are included.
	StoreGatewayTouchedPostingBytes uint64 `` /* 162-byte string literal not displayed */
	// The total number of samples scanned while evaluating a query.
	// Equal to TotalSamples in https://github.com/prometheus/prometheus/blob/main/util/stats/query_stats.go
	ScannedSamples uint64 `protobuf:"varint,13,opt,name=scanned_samples,json=scannedSamples,proto3" json:"scanned_samples,omitempty"`
	// The highest count of samples considered while evaluating a query.
	// Equal to PeakSamples in https://github.com/prometheus/prometheus/blob/main/util/stats/query_stats.go
	PeakSamples uint64 `protobuf:"varint,14,opt,name=peak_samples,json=peakSamples,proto3" json:"peak_samples,omitempty"`
}

func (*Stats) Descriptor

func (*Stats) Descriptor() ([]byte, []int)

func (*Stats) Equal

func (this *Stats) Equal(that interface{}) bool

func (*Stats) GetExtraFields added in v1.15.0

func (m *Stats) GetExtraFields() map[string]string

func (*Stats) GetFetchedChunkBytes added in v1.11.0

func (m *Stats) GetFetchedChunkBytes() uint64

func (*Stats) GetFetchedChunksCount added in v1.15.0

func (m *Stats) GetFetchedChunksCount() uint64

func (*Stats) GetFetchedDataBytes added in v1.14.0

func (m *Stats) GetFetchedDataBytes() uint64

func (*Stats) GetFetchedSamplesCount added in v1.15.0

func (m *Stats) GetFetchedSamplesCount() uint64

func (*Stats) GetFetchedSeriesCount added in v1.11.0

func (m *Stats) GetFetchedSeriesCount() uint64

func (*Stats) GetLimitHit added in v1.16.0

func (m *Stats) GetLimitHit() string

func (*Stats) GetPeakSamples added in v1.19.0

func (m *Stats) GetPeakSamples() uint64

func (*Stats) GetQueryStorageWallTime added in v1.17.0

func (m *Stats) GetQueryStorageWallTime() time.Duration

func (*Stats) GetScannedSamples added in v1.19.0

func (m *Stats) GetScannedSamples() uint64

func (*Stats) GetSplitQueries added in v1.17.0

func (m *Stats) GetSplitQueries() uint64

func (*Stats) GetStoreGatewayTouchedPostingBytes added in v1.18.0

func (m *Stats) GetStoreGatewayTouchedPostingBytes() uint64

func (*Stats) GetStoreGatewayTouchedPostingsCount added in v1.18.0

func (m *Stats) GetStoreGatewayTouchedPostingsCount() uint64

func (*Stats) GetWallTime

func (m *Stats) GetWallTime() time.Duration

func (*Stats) GoString

func (this *Stats) GoString() string

func (*Stats) Marshal

func (m *Stats) Marshal() (dAtA []byte, err error)

func (*Stats) MarshalTo

func (m *Stats) MarshalTo(dAtA []byte) (int, error)

func (*Stats) MarshalToSizedBuffer

func (m *Stats) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Stats) ProtoMessage

func (*Stats) ProtoMessage()

func (*Stats) Reset

func (m *Stats) Reset()

func (*Stats) Size

func (m *Stats) Size() (n int)

func (*Stats) String

func (this *Stats) String() string

func (*Stats) Unmarshal

func (m *Stats) Unmarshal(dAtA []byte) error

func (*Stats) XXX_DiscardUnknown

func (m *Stats) XXX_DiscardUnknown()

func (*Stats) XXX_Marshal

func (m *Stats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Stats) XXX_Merge

func (m *Stats) XXX_Merge(src proto.Message)

func (*Stats) XXX_Size

func (m *Stats) XXX_Size() int

func (*Stats) XXX_Unmarshal

func (m *Stats) XXX_Unmarshal(b []byte) error

type WallTimeMiddleware

type WallTimeMiddleware struct{}

WallTimeMiddleware tracks the wall time.

func NewWallTimeMiddleware

func NewWallTimeMiddleware() WallTimeMiddleware

NewWallTimeMiddleware makes a new WallTimeMiddleware.

func (WallTimeMiddleware) Wrap

Wrap implements middleware.Interface.

Jump to

Keyboard shortcuts

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