Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop Distributor on fatal error #1887

Merged
merged 2 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## main / unreleased
* [BUGFIX] Stop distributors on Otel receiver fatal error[#1887](https://github.com/grafana/tempo/pull/1887) (@rdooley)
* [CHANGE] **BREAKING CHANGE** Use snake case on Azure Storage config [#1879](https://github.com/grafana/tempo/issues/1879) (@faustodavid)
Example of using snake case on Azure Storage config:
```
Expand Down
15 changes: 14 additions & 1 deletion modules/distributor/receiver/shim.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type receiversShim struct {
pusher TracesPusher
logger *log.RateLimitedLogger
metricViews []*view.View
fatal chan error
}

func (r *receiversShim) Capabilities() consumer.Capabilities {
Expand All @@ -94,6 +95,7 @@ func New(receiverCfg map[string]interface{}, pusher TracesPusher, middleware Mid
shim := &receiversShim{
pusher: pusher,
logger: log.NewRateLimitedLogger(logsPerSecond, level.Error(log.Logger)),
fatal: make(chan error),
}

// shim otel observability
Expand Down Expand Up @@ -217,10 +219,20 @@ func New(receiverCfg map[string]interface{}, pusher TracesPusher, middleware Mid
shim.receivers = append(shim.receivers, receiver)
}

shim.Service = services.NewIdleService(shim.starting, shim.stopping)
shim.Service = services.NewBasicService(shim.starting, shim.running, shim.stopping)

return shim, nil
}

func (r *receiversShim) running(ctx context.Context) error {
select {
case err := <-r.fatal:
return err
case <-ctx.Done():
return ctx.Err()
}
}

func (r *receiversShim) starting(ctx context.Context) error {
for _, receiver := range r.receivers {
err := receiver.Start(ctx, r)
Expand Down Expand Up @@ -279,6 +291,7 @@ func (r *receiversShim) ConsumeTraces(ctx context.Context, td ptrace.Traces) err
// ReportFatalError implements component.Host
func (r *receiversShim) ReportFatalError(err error) {
_ = level.Error(log.Logger).Log("msg", "fatal error reported", "err", err)
r.fatal <- err
}

// GetFactory implements component.Host
Expand Down