From 51a1f91f7476a84c0242f7e0a07916ea2852d3c5 Mon Sep 17 00:00:00 2001 From: Aleksandr Razumov Date: Mon, 4 Dec 2023 16:40:32 +0300 Subject: [PATCH] feat(chotel): retry export --- cmd/chotel/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/chotel/main.go b/cmd/chotel/main.go index c26bb04a..725f622d 100644 --- a/cmd/chotel/main.go +++ b/cmd/chotel/main.go @@ -11,6 +11,7 @@ import ( "github.com/ClickHouse/ch-go" "github.com/ClickHouse/ch-go/proto" + "github.com/cenkalti/backoff/v4" "github.com/go-faster/errors" "github.com/go-faster/sdk/app" "github.com/go-faster/sdk/zctx" @@ -264,7 +265,13 @@ func (a *App) send(ctx context.Context, now time.Time) error { }); err != nil { return errors.Wrap(err, "query") } - if err := a.traceExporter.ExportSpans(ctx, batch); err != nil { + eb := backoff.NewExponentialBackOff() + if err := backoff.Retry(func() error { + if err := a.traceExporter.ExportSpans(ctx, batch); err != nil { + return errors.Wrap(err, "export") + } + return nil + }, eb); err != nil { return errors.Wrap(err, "export") } if err := db.Do(ctx, ch.Query{