From 99e4ffc220de11dd77f02b969b4ede53545b5bcb Mon Sep 17 00:00:00 2001 From: Joshua MacDonald Date: Thu, 9 Nov 2023 13:39:46 -0800 Subject: [PATCH] Do not fatal for ordinary consume errors (#66) ## What is the current behavior? The collector will exit because of a transient failure. ## What is the new behavior? It will log the failure. ## Pull request checklist Please check if your PR fulfills the following requirements: - [x] Tests(`make test`) for the changes have been added (for bug fixes / features) and pass - [ ] Docs have been reviewed and added / updated if needed (for bug fixes / features) - [x] Lint (`make lint`) has passed locally and any fixes were made for failures ## Pull request type Please check the type of change your PR introduces: - [x] Bugfix - [ ] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] Documentation content changes - [ ] Other (please describe): ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information The process fails in a difficult to diagnose way! It exits with status 0 and the log explaining why is nowhere near the bottom. --- generatorreceiver/generator_receiver.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/generatorreceiver/generator_receiver.go b/generatorreceiver/generator_receiver.go index a22c6fe..c4cc243 100644 --- a/generatorreceiver/generator_receiver.go +++ b/generatorreceiver/generator_receiver.go @@ -134,7 +134,11 @@ func (g generatorReceiver) Start(ctx context.Context, host component.Host) error case <-traceTicker.C: if rootRoute.ShouldGenerate() { traces := traceGen.Generate(time.Now().UnixNano()) - _ = g.traceConsumer.ConsumeTraces(context.Background(), *traces) + err := g.traceConsumer.ConsumeTraces(context.Background(), *traces) + if err != nil { + g.logger.Error("consume error", zap.Error(err)) + } + } } } @@ -157,7 +161,7 @@ func (g *generatorReceiver) startMetricGenerator(ctx context.Context, host compo if metrics, report := metricGen.Generate(&m, serviceName); report { err := g.metricConsumer.ConsumeMetrics(ctx, metrics) if err != nil { - host.ReportFatalError(err) + g.logger.Error("consume error", zap.Error(err)) } } }