Fix panic updating metrics when not enabled

This commit is contained in:
James Mills 2022-04-05 16:09:34 +10:00
parent 1a4f4c769c
commit 7d7e34e753
No known key found for this signature in database
GPG Key ID: AC4C014F1440EBD6

View File

@ -600,7 +600,9 @@ func (mb *MessageBus) Subscribe(id, topic string, opts ...SubscribeOption) chan
case ch <- msg:
n++
default:
mb.metrics.Counter("bus", "dropped").Inc()
if mb.metrics != nil {
mb.metrics.Counter("bus", "dropped").Inc()
}
return ErrBufferFull
}
}