fix metrics not stopping correctly, deadlocking the whole shutdown process
This commit is contained in:
@@ -136,17 +136,12 @@ func (m *Metrics) Flush() {
|
||||
|
||||
func (m *Metrics) Stop(ctx context.Context) {
|
||||
log.Info().Msg("Stopping Request Metrics")
|
||||
for len(m.c) > 0 {
|
||||
select {
|
||||
case rm := <-m.c:
|
||||
m.calculateDuration(rm)
|
||||
case <-ctx.Done():
|
||||
m.stop <- struct{}{}
|
||||
log.Warn().Msg("Hard Stopped Request Metrics")
|
||||
return
|
||||
}
|
||||
// Drain remaining metrics
|
||||
for len(m.c) > 0 {
|
||||
rm := <-m.c
|
||||
m.calculateDuration(rm)
|
||||
}
|
||||
m.Flush()
|
||||
m.stop <- struct{}{}
|
||||
log.Info().Msg("Stopped Request Metrics")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user