MCPcopy
hub / github.com/grafana/tempo / NewDistinctValue

Function NewDistinctValue

pkg/collector/distinct_value_collector.go:32–41  ·  view source on GitHub ↗

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 m

(maxDataSize int, maxValues uint32, staleValueThreshold uint32, len func(T) int)

Source from the content-addressed store, hash-verified

30// For ease of use, maxDataSize=0 and maxValues are interpreted as unlimited.
31// Use NewDistinctValueWithDiff to enable diff support, but that one is slightly slower.
32func NewDistinctValue[T comparable](maxDataSize int, maxValues uint32, staleValueThreshold uint32, len func(T) int) *DistinctValue[T] {
33 return &DistinctValue[T]{
34 values: make(map[T]struct{}),
35 maxDataSize: maxDataSize,
36 diffEnabled: false, // disable diff to make it faster
37 len: len,
38 maxValues: maxValues,
39 maxCacheHits: staleValueThreshold,
40 }
41}
42
43// NewDistinctValueWithDiff is like NewDistinctValue but with diff support enabled.
44func NewDistinctValueWithDiff[T comparable](maxDataSize int, maxValues uint32, staleValueThreshold uint32, len func(T) int) *DistinctValue[T] {

Callers 15

SearchTagValuesV2Method · 0.92
tagValuesRunnerFunction · 0.92
TestFetchTagValuesFunction · 0.92
BenchmarkFetchTagValuesFunction · 0.92
TestFetchTagValuesFunction · 0.92
BenchmarkFetchTagValuesFunction · 0.92
TestFetchTagValuesFunction · 0.92
BenchmarkFetchTagValuesFunction · 0.92

Calls

no outgoing calls

Tested by 15

tagValuesRunnerFunction · 0.74
TestFetchTagValuesFunction · 0.74
BenchmarkFetchTagValuesFunction · 0.74
TestFetchTagValuesFunction · 0.74
BenchmarkFetchTagValuesFunction · 0.74
TestFetchTagValuesFunction · 0.74
BenchmarkFetchTagValuesFunction · 0.74
TestExecuteTagValuesFunction · 0.74