From e5b8f440b08bb78bf35c4f504cbb05e3766d0ae4 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Tue, 16 Jan 2024 10:21:53 -0800 Subject: [PATCH] [chore][receiver/cloudfoundry] Use ReportStatus instead of ReportFatalError (#30613) Remove use of deprecated host.ReportFatalError Linked to https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/30501 Resolves #30588 --- receiver/cloudfoundryreceiver/receiver.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/receiver/cloudfoundryreceiver/receiver.go b/receiver/cloudfoundryreceiver/receiver.go index 32b81d7f3a35..bc9b9cae6eb4 100644 --- a/receiver/cloudfoundryreceiver/receiver.go +++ b/receiver/cloudfoundryreceiver/receiver.go @@ -92,17 +92,17 @@ func (cfr *cloudFoundryReceiver) Start(ctx context.Context, host component.Host) _, tokenErr = tokenProvider.ProvideToken() if tokenErr != nil { - host.ReportFatalError(fmt.Errorf("cloud foundry receiver failed to fetch initial token from UAA: %w", tokenErr)) + cfr.settings.ReportStatus(component.NewFatalErrorEvent(fmt.Errorf("cloud foundry receiver failed to fetch initial token from UAA: %w", tokenErr))) return } envelopeStream, err := streamFactory.CreateStream(innerCtx, cfr.config.RLPGateway.ShardID) if err != nil { - host.ReportFatalError(fmt.Errorf("creating RLP gateway envelope stream: %w", err)) + cfr.settings.ReportStatus(component.NewFatalErrorEvent(fmt.Errorf("creating RLP gateway envelope stream: %w", err))) return } - cfr.streamMetrics(innerCtx, envelopeStream, host) + cfr.streamMetrics(innerCtx, envelopeStream) cfr.settings.Logger.Debug("cloudfoundry metrics streamer stopped") }() @@ -120,8 +120,7 @@ func (cfr *cloudFoundryReceiver) Shutdown(_ context.Context) error { func (cfr *cloudFoundryReceiver) streamMetrics( ctx context.Context, - stream loggregator.EnvelopeStream, - host component.Host) { + stream loggregator.EnvelopeStream) { for { // Blocks until non-empty result or context is cancelled (returns nil in that case) @@ -129,7 +128,7 @@ func (cfr *cloudFoundryReceiver) streamMetrics( if envelopes == nil { // If context has not been cancelled, then nil means the shutdown was due to an error within stream if ctx.Err() == nil { - host.ReportFatalError(errors.New("RLP gateway streamer shut down due to an error")) + cfr.settings.ReportStatus(component.NewFatalErrorEvent(errors.New("RLP gateway streamer shut down due to an error"))) } break