Skip to content

Commit

Permalink
ddtrace/tracer: reset payload after every transport attempt (#319)
Browse files Browse the repository at this point in the history
Previously, we were attempting to save the payload as long as the size
allows it in order to attempt and send it again on subsequent retries to
minimize the loss of traces.

This has proven to be a bad approach because there were cases were the
trace agent did only partial reads from the payload before failing,
leaving the payload in a state where it was impossible to decode using
msgpack (part of the buffer was already read).

This fix is an intermediary easy solution to the problem (we have
experimented with different approaches too, see #275). We can experiment
later on with retry policies.
  • Loading branch information
gbbr committed Aug 23, 2018
1 parent 1f24f8b commit cea9c1d
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions ddtrace/tracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,16 +300,10 @@ func (t *tracer) flushTraces() {
log.Printf("Sending payload: size: %d traces: %d\n", size, count)
}
err := t.config.transport.send(t.payload)
if err != nil && size > payloadMaxLimit {
// we couldn't send the payload and it is getting too big to be
// accepted by the agent, we have to drop it.
t.payload.reset()
if err != nil {
t.pushError(&dataLossError{context: err, count: count})
}
if err == nil {
// send succeeded
t.payload.reset()
}
t.payload.reset()
}

// flushErrors will process log messages that were queued
Expand Down

0 comments on commit cea9c1d

Please sign in to comment.