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")
for len(m.c) > 0 {
select {
case rm := <-m.c:
m.calculateDuration(rm)
case <-ctx.Done():
m.stop <- struct{}{} m.stop <- struct{}{}
log.Warn().Msg("Hard Stopped Request Metrics") // Drain remaining metrics
return for len(m.c) > 0 {
} rm := <-m.c
m.calculateDuration(rm)
} }
m.Flush() m.Flush()
m.stop <- struct{}{}
log.Info().Msg("Stopped Request Metrics") log.Info().Msg("Stopped Request Metrics")
} }