Atlas › Test

TestWindowedDigest_Empty

Exact test identity: go.temporal.io/server/common/stats/TestWindowedDigest_Empty

Package
go.temporal.io/server/common/stats
Suite / test hierarchy
TestWindowedDigest_Empty
Test
TestWindowedDigest_Empty
Introduced at
windowed_tdigest.go ×1 Frontier kind: Joint frontier
Covered ranges
10
Covered lines
28
Covered files
1

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/common/stats/windowed_tdigest.go 28 covered LOC · 10 ranges

Open complete file

72 // So, if you want 300 seconds of history on an event that records 1k counts/sec, 3 10-second windows
73 // is fine.
74 > func NewWindowedTDigest(cfg WindowConfig) (TimeWindowedStats, error) { windowed_tdigest.go
75 > if cfg.WindowCount <= 0 {
76 return nil, errors.New("windowCount must be non-negative")
77 }
78 > if cfg.WindowSize.Milliseconds() <= 50 { windowed_tdigest.go
79 return nil, errors.New("probable misconfiguration detected: windowSize is too small, consider increasing it to at least 50ms")
80 }
81 > return &timeWindowedTDigest{ windowed_tdigest.go
82 > windows: make([]timedWindow, cfg.WindowCount),
83 > cfg: cfg,
84 > // mu and head both empty
85 > }, nil
86 }
87
105 }
106
107 > func (w *timeWindowedTDigest) Quantile(q float64) float64 { windowed_tdigest.go
108 > merged := w.getMergedWindows()
109 > if merged == nil || merged.Count() == 0 {
110 > return 0 windowed_tdigest.go
111 > }
112
113 return merged.Quantile(q)
114 }
115
116 > func (w *timeWindowedTDigest) TrimmedMean(lowerQuantile, upperQuantile float64) float64 { windowed_tdigest.go
117 > merged := w.getMergedWindows()
118 > if merged == nil || merged.Count() == 0 {
119 > return 0 windowed_tdigest.go
120 > }
121
122 return merged.TrimmedMean(lowerQuantile, upperQuantile)
123 }
124
125 > func (w *timeWindowedTDigest) getMergedWindows() *tdigest.TDigest { windowed_tdigest.go
126 > w.mu.Lock()
127 > defer w.mu.Unlock()
128 >
129 > var merged *tdigest.TDigest
130 > for idx := range w.windows {
131 > td := w.windows[idx].tdigest
132 > if td == nil {
133 > continue windowed_tdigest.go
134 }
135