collector

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const IntrinsicScope = "intrinsic"

Variables

This section is empty.

Functions

This section is empty.

Types

type DistinctString

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

func NewDistinctString

func NewDistinctString(maxDataSize int, maxValues uint32, staleValueThreshold uint32) *DistinctString

NewDistinctString with the given maximum data size and max items. MaxDataSize is calculated as the total length of the recorded strings. For ease of use, maxDataSize=0 and maxItems=0 are interpreted as unlimited.

func NewDistinctStringWithDiff

func NewDistinctStringWithDiff(maxDataSize int, maxValues uint32, staleValueThreshold uint32) *DistinctString

NewDistinctStringWithDiff is like NewDistinctString but with diff support enabled. MaxDataSize is calculated as the total length of the recorded strings. For ease of use, maxDataSize=0 and maxItems=0 are interpreted as unlimited.

func (*DistinctString) Collect

func (d *DistinctString) Collect(s string) (added bool)

Collect adds a new value to the distinct string collector and returns a boolean indicating whether the value was successfully added or not. To check if the limit has been reached, you must call the Exceeded method separately.

func (*DistinctString) Diff

func (d *DistinctString) Diff() ([]string, error)

Diff returns all new strings collected since the last time diff was called

func (*DistinctString) Exceeded

func (d *DistinctString) Exceeded() bool

Exceeded indicates if some values were lost because the maximum size limit was met.

func (*DistinctString) Size

func (d *DistinctString) Size() int

Size is the total size of all distinct strings encountered.

func (*DistinctString) StopReason

func (d *DistinctString) StopReason() string

func (*DistinctString) Strings

func (d *DistinctString) Strings() []string

Strings returns the final list of distinct values collected and sorted.

type DistinctValue

type DistinctValue[T comparable] struct {
	// contains filtered or unexported fields
}

func NewDistinctValue

func NewDistinctValue[T comparable](maxDataSize int, maxValues uint32, staleValueThreshold uint32, len func(T) int) *DistinctValue[T]

NewDistinctValue with the given maximum data size and values limited. maxDataSize is calculated as the total length of the recorded strings. staleValueThreshold introduces a stop condition that is triggered when the number of found cache hits overcomes the limit For ease of use, maxDataSize=0 and maxValues are interpreted as unlimited. Use NewDistinctValueWithDiff to enable diff support, but that one is slightly slower.

func NewDistinctValueWithDiff

func NewDistinctValueWithDiff[T comparable](maxDataSize int, maxValues uint32, staleValueThreshold uint32, len func(T) int) *DistinctValue[T]

NewDistinctValueWithDiff is like NewDistinctValue but with diff support enabled.

func (*DistinctValue[T]) Collect

func (d *DistinctValue[T]) Collect(v T) (exceeded bool)

Collect adds a new value to the distinct value collector. return true when it reaches the limits and can't fit more values. callers of return of Collect or call Exceeded to stop early.

func (*DistinctValue[T]) Diff

func (d *DistinctValue[T]) Diff() ([]T, error)

Diff returns all new strings collected since the last time diff was called returns nil if diff is not enabled

func (*DistinctValue[T]) Exceeded

func (d *DistinctValue[T]) Exceeded() bool

Exceeded indicates that we have exceeded the limit can be used to stop early and to avoid collecting further values

func (*DistinctValue[T]) Size

func (d *DistinctValue[T]) Size() int

Size is the total size of all distinct items collected

func (*DistinctValue[T]) StopReason

func (d *DistinctValue[T]) StopReason() string

func (*DistinctValue[T]) Values

func (d *DistinctValue[T]) Values() []T

Values returns the final list of distinct values collected and sorted.

type MetricsCollector

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

MetricsCollector is a thread-safe collector that uses atomic operations to accumulate metrics. We primarily use it to collect the total bytes read from a reader across a request

func NewMetricsCollector

func NewMetricsCollector() *MetricsCollector

func (*MetricsCollector) Add

func (mc *MetricsCollector) Add(value uint64)

Add adds new bytes read to TotalValue. this method is thread safe and satisfies the common.MetricsCallback type so it's used as callback at a lot of places

func (*MetricsCollector) TotalValue

func (mc *MetricsCollector) TotalValue() uint64

TotalValue returns the sum of total values collected by the collector

type ScopedDistinctString

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

func NewScopedDistinctString

func NewScopedDistinctString(maxDataSize int, maxTagsPerScope uint32, staleValueThreshold uint32) *ScopedDistinctString

NewScopedDistinctString collects the tags per scope MaxDataSize is calculated as the total length of the recorded strings. MaxTagsPerScope controls how many tags can be added per scope. The intrinsic scope is unbounded. For ease of use, maxDataSize=0 and maxTagsPerScope=0 are interpreted as unlimited.

func NewScopedDistinctStringWithDiff

func NewScopedDistinctStringWithDiff(maxDataSize int, maxTagsPerScope uint32, staleValueThreshold uint32) *ScopedDistinctString

NewScopedDistinctStringWithDiff collects the tags per scope with diff MaxDataSize is calculated as the total length of the recorded strings. MaxTagsPerScope controls how many tags can be added per scope. The intrinsic scope is unbounded. For ease of use, maxDataSize=0 and maxTagsPerScope=0 are interpreted as unlimited.

func (*ScopedDistinctString) Collect

func (d *ScopedDistinctString) Collect(scope string, val string) (exceeded bool)

Collect adds a new value to the distinct string collector. returns true when it reaches the limits and can't fit more values. can be used to stop early during Collect without calling Exceeded.

func (*ScopedDistinctString) Diff

func (d *ScopedDistinctString) Diff() (map[string][]string, error)

Diff returns all new strings collected since the last time Diff was called

func (*ScopedDistinctString) Exceeded

func (d *ScopedDistinctString) Exceeded() bool

Exceeded indicates if some values were lost because the maximum size limit was met. Or because one of the scopes max tags was reached.

func (*ScopedDistinctString) StopReason

func (d *ScopedDistinctString) StopReason() string

func (*ScopedDistinctString) Strings

func (d *ScopedDistinctString) Strings() map[string][]string

Strings returns the final list of distinct values collected and sorted.

Jump to

Keyboard shortcuts

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