Skip to content

Commit

Permalink
[chore][receiver/cloudfoundry] Use ReportStatus instead of ReportFata…
Browse files Browse the repository at this point in the history
…lError (open-telemetry#30613)

Remove use of deprecated host.ReportFatalError

Linked to open-telemetry#30501
Resolves open-telemetry#30588
  • Loading branch information
crobert-1 committed Jan 16, 2024
1 parent ac716d0 commit e5b8f44
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions receiver/cloudfoundryreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}()

Expand All @@ -120,16 +120,15 @@ 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)
envelopes := stream()
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
Expand Down

0 comments on commit e5b8f44

Please sign in to comment.