From cd78cde0be847448701311bf2d85809e77bdc290 Mon Sep 17 00:00:00 2001 From: Alex Senger Date: Thu, 19 Sep 2024 12:15:07 +0200 Subject: [PATCH] #204 fix error handling for prometheus in client instantiation --- consumer.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/consumer.go b/consumer.go index 041da9c..7c6f6c9 100644 --- a/consumer.go +++ b/consumer.go @@ -66,12 +66,12 @@ func New(streamName string, opts ...Option) (*Consumer, error) { } if c.metricRegistry != nil { - var err error - errors.Join(err, c.metricRegistry.Register(collectorMillisBehindLatest)) - errors.Join(err, c.metricRegistry.Register(counterEventsConsumed)) - errors.Join(err, c.metricRegistry.Register(counterCheckpointsWritten)) - if err != nil { - return nil, err + var errs error + errs = errors.Join(errs, c.metricRegistry.Register(collectorMillisBehindLatest)) + errs = errors.Join(errs, c.metricRegistry.Register(counterEventsConsumed)) + errs = errors.Join(errs, c.metricRegistry.Register(counterCheckpointsWritten)) + if errs != nil { + return nil, errs } }