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

fix: do not stop sampling processor when failing to delete trace events #12509

Merged
merged 3 commits into from
Feb 6, 2024
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
11 changes: 11 additions & 0 deletions x-pack/apm-server/sampling/eventstorage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,17 @@ func estimateSize(e *badger.Entry) int64 {
// DeleteTraceEvent deletes the trace event from storage.
func (rw *ReadWriter) DeleteTraceEvent(traceID, id string) error {
key := append(append([]byte(traceID), ':'), id...)
err := rw.txn.Delete(key)
// If the transaction is already too big to accommodate the new entry, flush
// the existing transaction and set the entry on a new one, otherwise,
// returns early.
if err != badger.ErrTxnTooBig {
return err
}
if err := rw.Flush(); err != nil {
return err
}

return rw.txn.Delete(key)
}

Expand Down
4 changes: 2 additions & 2 deletions x-pack/apm-server/sampling/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,11 @@ func (p *Processor) Run() error {
switch event.Type() {
case modelpb.TransactionEventType:
if err := p.eventStore.DeleteTraceEvent(event.Trace.Id, event.Transaction.Id); err != nil {
return errors.Wrap(err, "failed to delete transaction from local storage")
p.logger.With(logp.Error(err)).Warn("failed to delete transaction from local storage")
}
case modelpb.SpanEventType:
if err := p.eventStore.DeleteTraceEvent(event.Trace.Id, event.Span.Id); err != nil {
return errors.Wrap(err, "failed to delete span from local storage")
p.logger.With(logp.Error(err)).Warn("failed to delete span from local storage")
}
}
}
Expand Down