Documentation ¶
Overview ¶
Package stats provides primitives for recording metrics across the query path. Statistics are passed through the query context. To start a new query statistics context use:
statsCtx, ctx := stats.NewContext(ctx)
Then you can update statistics by mutating data by using:
statsCtx.Add...(1)
To get the statistic from the current context you can use:
statsCtx := stats.FromContext(ctx)
Finally to get a snapshot of the current query statistic use
statsCtx.Result(time.Since(start))
Index ¶
- Variables
- func ConvertSecondsToNanoseconds(seconds float64) time.Duration
- func JoinIngesters(ctx context.Context, inc Ingester)
- func JoinResults(ctx context.Context, res Result)
- type Chunk
- func (*Chunk) Descriptor() ([]byte, []int)
- func (this *Chunk) Equal(that interface{}) bool
- func (m *Chunk) GetCompressedBytes() int64
- func (m *Chunk) GetDecompressedBytes() int64
- func (m *Chunk) GetDecompressedLines() int64
- func (m *Chunk) GetHeadChunkBytes() int64
- func (m *Chunk) GetHeadChunkLines() int64
- func (m *Chunk) GetTotalDuplicates() int64
- func (this *Chunk) GoString() string
- func (m *Chunk) Marshal() (dAtA []byte, err error)
- func (m *Chunk) MarshalTo(dAtA []byte) (int, error)
- func (m *Chunk) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Chunk) ProtoMessage()
- func (m *Chunk) Reset()
- func (m *Chunk) Size() (n int)
- func (this *Chunk) String() string
- func (m *Chunk) Unmarshal(dAtA []byte) error
- func (m *Chunk) XXX_DiscardUnknown()
- func (m *Chunk) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Chunk) XXX_Merge(src proto.Message)
- func (m *Chunk) XXX_Size() int
- func (m *Chunk) XXX_Unmarshal(b []byte) error
- type Component
- type Context
- func (c *Context) AddChunksDownloadTime(i time.Duration)
- func (c *Context) AddChunksDownloaded(i int64)
- func (c *Context) AddChunksRef(i int64)
- func (c *Context) AddCompressedBytes(i int64)
- func (c *Context) AddDecompressedBytes(i int64)
- func (c *Context) AddDecompressedLines(i int64)
- func (c *Context) AddDuplicates(i int64)
- func (c *Context) AddHeadChunkBytes(i int64)
- func (c *Context) AddHeadChunkLines(i int64)
- func (c *Context) AddIngesterBatch(size int64)
- func (c *Context) AddIngesterReached(i int32)
- func (c *Context) AddIngesterTotalChunkMatched(i int64)
- func (c *Context) Ingester() Ingester
- func (c *Context) Reset()
- func (c *Context) Result(execTime time.Duration, queueTime time.Duration) Result
- type Ingester
- func (*Ingester) Descriptor() ([]byte, []int)
- func (this *Ingester) Equal(that interface{}) bool
- func (m *Ingester) GetStore() Store
- func (m *Ingester) GetTotalBatches() int64
- func (m *Ingester) GetTotalChunksMatched() int64
- func (m *Ingester) GetTotalLinesSent() int64
- func (m *Ingester) GetTotalReached() int32
- func (this *Ingester) GoString() string
- func (m *Ingester) Marshal() (dAtA []byte, err error)
- func (m *Ingester) MarshalTo(dAtA []byte) (int, error)
- func (m *Ingester) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (i *Ingester) Merge(m Ingester)
- func (*Ingester) ProtoMessage()
- func (m *Ingester) Reset()
- func (m *Ingester) Size() (n int)
- func (this *Ingester) String() string
- func (m *Ingester) Unmarshal(dAtA []byte) error
- func (m *Ingester) XXX_DiscardUnknown()
- func (m *Ingester) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Ingester) XXX_Merge(src proto.Message)
- func (m *Ingester) XXX_Size() int
- func (m *Ingester) XXX_Unmarshal(b []byte) error
- type Querier
- func (*Querier) Descriptor() ([]byte, []int)
- func (this *Querier) Equal(that interface{}) bool
- func (m *Querier) GetStore() Store
- func (this *Querier) GoString() string
- func (m *Querier) Marshal() (dAtA []byte, err error)
- func (m *Querier) MarshalTo(dAtA []byte) (int, error)
- func (m *Querier) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (q *Querier) Merge(m Querier)
- func (*Querier) ProtoMessage()
- func (m *Querier) Reset()
- func (m *Querier) Size() (n int)
- func (this *Querier) String() string
- func (m *Querier) Unmarshal(dAtA []byte) error
- func (m *Querier) XXX_DiscardUnknown()
- func (m *Querier) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Querier) XXX_Merge(src proto.Message)
- func (m *Querier) XXX_Size() int
- func (m *Querier) XXX_Unmarshal(b []byte) error
- type Result
- func (r Result) ChunksDownloadTime() time.Duration
- func (r *Result) ComputeSummary(execTime time.Duration, queueTime time.Duration)
- func (*Result) Descriptor() ([]byte, []int)
- func (this *Result) Equal(that interface{}) bool
- func (m *Result) GetIngester() Ingester
- func (m *Result) GetQuerier() Querier
- func (m *Result) GetSummary() Summary
- func (this *Result) GoString() string
- func (r Result) Log(log log.Logger)
- func (m *Result) Marshal() (dAtA []byte, err error)
- func (m *Result) MarshalTo(dAtA []byte) (int, error)
- func (m *Result) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (r *Result) Merge(m Result)
- func (*Result) ProtoMessage()
- func (m *Result) Reset()
- func (m *Result) Size() (n int)
- func (this *Result) String() string
- func (r Result) TotalChunksDownloaded() int64
- func (r Result) TotalChunksRef() int64
- func (r Result) TotalDecompressedBytes() int64
- func (r Result) TotalDecompressedLines() int64
- func (r Result) TotalDuplicates() int64
- func (m *Result) Unmarshal(dAtA []byte) error
- func (m *Result) XXX_DiscardUnknown()
- func (m *Result) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Result) XXX_Merge(src proto.Message)
- func (m *Result) XXX_Size() int
- func (m *Result) XXX_Unmarshal(b []byte) error
- type Store
- func (*Store) Descriptor() ([]byte, []int)
- func (this *Store) Equal(that interface{}) bool
- func (m *Store) GetChunk() Chunk
- func (m *Store) GetChunksDownloadTime() int64
- func (m *Store) GetTotalChunksDownloaded() int64
- func (m *Store) GetTotalChunksRef() int64
- func (this *Store) GoString() string
- func (m *Store) Marshal() (dAtA []byte, err error)
- func (m *Store) MarshalTo(dAtA []byte) (int, error)
- func (m *Store) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (s *Store) Merge(m Store)
- func (*Store) ProtoMessage()
- func (m *Store) Reset()
- func (m *Store) Size() (n int)
- func (this *Store) String() string
- func (m *Store) Unmarshal(dAtA []byte) error
- func (m *Store) XXX_DiscardUnknown()
- func (m *Store) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Store) XXX_Merge(src proto.Message)
- func (m *Store) XXX_Size() int
- func (m *Store) XXX_Unmarshal(b []byte) error
- type Summary
- func (*Summary) Descriptor() ([]byte, []int)
- func (this *Summary) Equal(that interface{}) bool
- func (m *Summary) GetBytesProcessedPerSecond() int64
- func (m *Summary) GetExecTime() float64
- func (m *Summary) GetLinesProcessedPerSecond() int64
- func (m *Summary) GetQueueTime() float64
- func (m *Summary) GetTotalBytesProcessed() int64
- func (m *Summary) GetTotalLinesProcessed() int64
- func (this *Summary) GoString() string
- func (s Summary) Log(log log.Logger)
- func (m *Summary) Marshal() (dAtA []byte, err error)
- func (m *Summary) MarshalTo(dAtA []byte) (int, error)
- func (m *Summary) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Summary) ProtoMessage()
- func (m *Summary) Reset()
- func (m *Summary) Size() (n int)
- func (this *Summary) String() string
- func (m *Summary) Unmarshal(dAtA []byte) error
- func (m *Summary) XXX_DiscardUnknown()
- func (m *Summary) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Summary) XXX_Merge(src proto.Message)
- func (m *Summary) XXX_Size() int
- func (m *Summary) XXX_Unmarshal(b []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLengthStats = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowStats = fmt.Errorf("proto: integer overflow") )
Functions ¶
func ConvertSecondsToNanoseconds ¶
ConvertSecondsToNanoseconds converts time.Duration representation of seconds (float64) into time.Duration representation of nanoseconds (int64)
func JoinIngesters ¶
JoinIngesterResult joins the ingester result statistics in a concurrency-safe manner.
func JoinResults ¶
JoinResults merges a Result with the embedded Result in a context in a concurrency-safe manner.
Types ¶
type Chunk ¶
type Chunk struct { // Total bytes processed but was already in memory. (found in the headchunk) HeadChunkBytes int64 `protobuf:"varint,4,opt,name=headChunkBytes,proto3" json:"headChunkBytes"` // Total lines processed but was already in memory. (found in the headchunk) HeadChunkLines int64 `protobuf:"varint,5,opt,name=headChunkLines,proto3" json:"headChunkLines"` // Total bytes decompressed and processed from chunks. DecompressedBytes int64 `protobuf:"varint,6,opt,name=decompressedBytes,proto3" json:"decompressedBytes"` // Total lines decompressed and processed from chunks. DecompressedLines int64 `protobuf:"varint,7,opt,name=decompressedLines,proto3" json:"decompressedLines"` // Total bytes of compressed chunks (blocks) processed. CompressedBytes int64 `protobuf:"varint,8,opt,name=compressedBytes,proto3" json:"compressedBytes"` // Total duplicates found while processing. TotalDuplicates int64 `protobuf:"varint,9,opt,name=totalDuplicates,proto3" json:"totalDuplicates"` }
func (*Chunk) Descriptor ¶
func (*Chunk) GetCompressedBytes ¶
func (*Chunk) GetDecompressedBytes ¶
func (*Chunk) GetDecompressedLines ¶
func (*Chunk) GetHeadChunkBytes ¶
func (*Chunk) GetHeadChunkLines ¶
func (*Chunk) GetTotalDuplicates ¶
func (*Chunk) ProtoMessage ¶
func (*Chunk) ProtoMessage()
func (*Chunk) XXX_DiscardUnknown ¶
func (m *Chunk) XXX_DiscardUnknown()
func (*Chunk) XXX_Marshal ¶
func (*Chunk) XXX_Unmarshal ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is the statistics context. It is passed through the query path and accumulates statistics.
func FromContext ¶
FromContext returns the statistics context.
func NewContext ¶
NewContext creates a new statistics context
func (*Context) AddChunksDownloadTime ¶
func (*Context) AddChunksDownloaded ¶
func (*Context) AddChunksRef ¶
func (*Context) AddCompressedBytes ¶
func (*Context) AddDecompressedBytes ¶
func (*Context) AddDecompressedLines ¶
func (*Context) AddDuplicates ¶
func (*Context) AddHeadChunkBytes ¶
func (*Context) AddHeadChunkLines ¶
func (*Context) AddIngesterBatch ¶
func (*Context) AddIngesterReached ¶
func (*Context) AddIngesterTotalChunkMatched ¶
type Ingester ¶
type Ingester struct { // Total ingester reached for this query. TotalReached int32 `protobuf:"varint,1,opt,name=totalReached,proto3" json:"totalReached"` // Total of chunks matched by the query from ingesters TotalChunksMatched int64 `protobuf:"varint,2,opt,name=totalChunksMatched,proto3" json:"totalChunksMatched"` // Total of batches sent from ingesters. TotalBatches int64 `protobuf:"varint,3,opt,name=totalBatches,proto3" json:"totalBatches"` // Total lines sent by ingesters. TotalLinesSent int64 `protobuf:"varint,4,opt,name=totalLinesSent,proto3" json:"totalLinesSent"` Store Store `protobuf:"bytes,5,opt,name=store,proto3" json:"store"` }
func (*Ingester) Descriptor ¶
func (*Ingester) GetTotalBatches ¶
func (*Ingester) GetTotalChunksMatched ¶
func (*Ingester) GetTotalLinesSent ¶
func (*Ingester) GetTotalReached ¶
func (*Ingester) MarshalToSizedBuffer ¶
func (*Ingester) ProtoMessage ¶
func (*Ingester) ProtoMessage()
func (*Ingester) XXX_DiscardUnknown ¶
func (m *Ingester) XXX_DiscardUnknown()
func (*Ingester) XXX_Marshal ¶
func (*Ingester) XXX_Unmarshal ¶
type Querier ¶
type Querier struct {
Store Store `protobuf:"bytes,1,opt,name=store,proto3" json:"store"`
}
func (*Querier) Descriptor ¶
func (*Querier) MarshalToSizedBuffer ¶
func (*Querier) ProtoMessage ¶
func (*Querier) ProtoMessage()
func (*Querier) XXX_DiscardUnknown ¶
func (m *Querier) XXX_DiscardUnknown()
func (*Querier) XXX_Marshal ¶
func (*Querier) XXX_Unmarshal ¶
type Result ¶
type Result struct { Summary Summary `protobuf:"bytes,1,opt,name=summary,proto3" json:"summary"` Querier Querier `protobuf:"bytes,2,opt,name=querier,proto3" json:"querier"` Ingester Ingester `protobuf:"bytes,3,opt,name=ingester,proto3" json:"ingester"` }
Result contains LogQL query statistics.
func (Result) ChunksDownloadTime ¶
func (*Result) ComputeSummary ¶
ComputeSummary compute the summary of the statistics.
func (*Result) Descriptor ¶
func (*Result) GetIngester ¶
func (*Result) GetQuerier ¶
func (*Result) GetSummary ¶
func (*Result) MarshalToSizedBuffer ¶
func (*Result) ProtoMessage ¶
func (*Result) ProtoMessage()
func (Result) TotalChunksDownloaded ¶
func (Result) TotalChunksRef ¶
func (Result) TotalDecompressedBytes ¶
func (Result) TotalDecompressedLines ¶
func (Result) TotalDuplicates ¶
func (*Result) XXX_DiscardUnknown ¶
func (m *Result) XXX_DiscardUnknown()
func (*Result) XXX_Marshal ¶
func (*Result) XXX_Unmarshal ¶
type Store ¶
type Store struct { // The total of chunk reference fetched from index. TotalChunksRef int64 `protobuf:"varint,1,opt,name=totalChunksRef,proto3" json:"totalChunksRef"` // Total number of chunks fetched. TotalChunksDownloaded int64 `protobuf:"varint,2,opt,name=totalChunksDownloaded,proto3" json:"totalChunksDownloaded"` // Time spent fetching chunks in nanoseconds. ChunksDownloadTime int64 `protobuf:"varint,3,opt,name=chunksDownloadTime,proto3" json:"chunksDownloadTime"` Chunk Chunk `protobuf:"bytes,4,opt,name=chunk,proto3" json:"chunk"` }
func (*Store) Descriptor ¶
func (*Store) GetChunksDownloadTime ¶
func (*Store) GetTotalChunksDownloaded ¶
func (*Store) GetTotalChunksRef ¶
func (*Store) ProtoMessage ¶
func (*Store) ProtoMessage()
func (*Store) XXX_DiscardUnknown ¶
func (m *Store) XXX_DiscardUnknown()
func (*Store) XXX_Marshal ¶
func (*Store) XXX_Unmarshal ¶
type Summary ¶
type Summary struct { // Total bytes processed per second. BytesProcessedPerSecond int64 `protobuf:"varint,1,opt,name=bytesProcessedPerSecond,proto3" json:"bytesProcessedPerSecond"` // Total lines processed per second. LinesProcessedPerSecond int64 `protobuf:"varint,2,opt,name=linesProcessedPerSecond,proto3" json:"linesProcessedPerSecond"` // Total bytes processed. TotalBytesProcessed int64 `protobuf:"varint,3,opt,name=totalBytesProcessed,proto3" json:"totalBytesProcessed"` // Total lines processed. TotalLinesProcessed int64 `protobuf:"varint,4,opt,name=totalLinesProcessed,proto3" json:"totalLinesProcessed"` // Execution time in seconds. // In addition to internal calculations this is also returned by the HTTP API. // Grafana expects time values to be returned in seconds as float. ExecTime float64 `protobuf:"fixed64,5,opt,name=execTime,proto3" json:"execTime"` // Queue time in seconds. // In addition to internal calculations this is also returned by the HTTP API. // Grafana expects time values to be returned in seconds as float. QueueTime float64 `protobuf:"fixed64,6,opt,name=queueTime,proto3" json:"queueTime"` }
Summary is the summary of a query statistics.
func (*Summary) Descriptor ¶
func (*Summary) GetBytesProcessedPerSecond ¶
func (*Summary) GetExecTime ¶
func (*Summary) GetLinesProcessedPerSecond ¶
func (*Summary) GetQueueTime ¶
func (*Summary) GetTotalBytesProcessed ¶
func (*Summary) GetTotalLinesProcessed ¶
func (*Summary) MarshalToSizedBuffer ¶
func (*Summary) ProtoMessage ¶
func (*Summary) ProtoMessage()
func (*Summary) XXX_DiscardUnknown ¶
func (m *Summary) XXX_DiscardUnknown()