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) {
|
func (m *Metrics) Stop(ctx context.Context) {
|
||||||
log.Info().Msg("Stopping Request Metrics")
|
log.Info().Msg("Stopping Request Metrics")
|
||||||
|
m.stop <- struct{}{}
|
||||||
|
// Drain remaining metrics
|
||||||
for len(m.c) > 0 {
|
for len(m.c) > 0 {
|
||||||
select {
|
rm := <-m.c
|
||||||
case rm := <-m.c:
|
m.calculateDuration(rm)
|
||||||
m.calculateDuration(rm)
|
|
||||||
case <-ctx.Done():
|
|
||||||
m.stop <- struct{}{}
|
|
||||||
log.Warn().Msg("Hard Stopped Request Metrics")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
m.Flush()
|
m.Flush()
|
||||||
m.stop <- struct{}{}
|
|
||||||
log.Info().Msg("Stopped Request Metrics")
|
log.Info().Msg("Stopped Request Metrics")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user