Skip to content

Commit

Permalink
FIX logic better
Browse files Browse the repository at this point in the history
  • Loading branch information
yomek33 committed Aug 2, 2024
1 parent 045bfd5 commit eaed89f
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions metrics/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ func handleGradualChangeMode(metricCount, metricLength, metricCycle, seriesCycle
}

func handleSpikeMode(metricCount, metricLength, metricCycle, seriesCycle int, labelKeys, labelValues []string, currentSeriesCount *int, spikeMultiplier float64, changeSeriesChan <-chan time.Time, updateNotify chan struct{}) {
inSpike := false
initialSeriesCount := *currentSeriesCount
for tick := range changeSeriesChan {
metricsMux.Lock()
Expand All @@ -208,14 +207,12 @@ func handleSpikeMode(metricCount, metricLength, metricCycle, seriesCycle int, la
cycleValues(labelKeys, labelValues, *currentSeriesCount, seriesCycle)
metricsMux.Unlock()

if inSpike {
inSpike = false
if *currentSeriesCount > initialSeriesCount {
*currentSeriesCount = initialSeriesCount
} else {
inSpike = true
*currentSeriesCount = int(float64(initialSeriesCount) * spikeMultiplier)
}

fmt.Printf("%v: Adjusting series count. New count: %d\n", tick, *currentSeriesCount)

select {
Expand Down

0 comments on commit eaed89f

Please sign in to comment.