Skip to content

Commit

Permalink
Add more trace annotations to the queue-retry logic
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu committed Nov 12, 2020
1 parent 0275e52 commit b5f0c15
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions exporter/exporterhelper/queued_retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/cenkalti/backoff"
"github.com/jaegertracing/jaeger/pkg/queue"
"go.opencensus.io/trace"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"

Expand Down Expand Up @@ -123,8 +124,8 @@ func newQueuedRetrySender(qCfg QueueSettings, rCfg RetrySettings, nextSender req
// start is invoked during service startup.
func (qrs *queuedRetrySender) start() {
qrs.queue.StartConsumers(qrs.cfg.NumConsumers, func(item interface{}) {
value := item.(request)
_, _ = qrs.consumerSender.send(value)
req := item.(request)
_, _ = qrs.consumerSender.send(req)
})
}

Expand Down Expand Up @@ -210,7 +211,10 @@ func (rs *retrySender) send(req request) (int, error) {
Clock: backoff.SystemClock,
}
expBackoff.Reset()
span := trace.FromContext(req.context())
retryNum := int64(0)
for {
span.Annotate([]trace.Attribute{trace.Int64Attribute("retry_num", retryNum)}, "Send request")
droppedItems, err := rs.nextSender.send(req)

if err == nil {
Expand Down Expand Up @@ -249,11 +253,19 @@ func (rs *retrySender) send(req request) (int, error) {
backoffDelay = max(backoffDelay, throttleErr.delay)
}

backoffDelayStr := backoffDelay.String()
span.Annotate(
[]trace.Attribute{
trace.StringAttribute("interval", backoffDelayStr),
trace.StringAttribute("error", err.Error()),
},
"Exporting failed. Will retry the request after interval.")
rs.logger.Info(
"Exporting failed. Will retry the request after interval.",
zap.Error(err),
zap.String("interval", backoffDelay.String()),
zap.String("interval", backoffDelayStr),
)
retryNum++

// back-off, but get interrupted when shutting down or request is cancelled or timed out.
select {
Expand Down

0 comments on commit b5f0c15

Please sign in to comment.