MCPcopy Index your code
hub / github.com/subtrace/subtrace / flush

Method flush

tracer/manager.go:184–204  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

182}
183
184func (b *block) flush(ctx context.Context) error {
185 if os.Getenv("SUBTRACE_TOKEN") == "" {
186 return nil
187 }
188
189 err := b.flushOnce(ctx)
190 if err == nil {
191 return nil
192 }
193
194 rand := rand.New(rand.NewSource(time.Now().UnixNano()))
195 wait := 5000 + time.Duration(rand.Intn(5000))*time.Millisecond
196 slog.Debug("failed to flush block, retrying after backoff wait", "block", b, "err", err, "wait", wait)
197 time.Sleep(wait)
198
199 if err := b.flushOnce(ctx); err != nil {
200 slog.Debug("failed to flush block after retry, dropping all events in block", "block", b, "err", err)
201 return err
202 }
203 return nil
204}
205
206type Manager struct {
207 pool sync.Pool

Callers 1

finalizeMethod · 0.80

Calls 1

flushOnceMethod · 0.95

Tested by

no test coverage detected