fix metrics not stopping correctly, deadlocking the whole shutdown process

This commit is contained in:
2026-06-08 22:43:30 +02:00
parent 4ebc95b9d8
commit 01c73819c0

View File

@@ -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")
} }