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

Do not inherit cancellation in the async sending queue #1930

Merged
merged 2 commits into from
Oct 9, 2020
Merged
Changes from 1 commit
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
21 changes: 21 additions & 0 deletions exporter/exporterhelper/queued_retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package exporterhelper

import (
"context"
"errors"
"fmt"
"time"
Expand All @@ -25,6 +26,22 @@ import (
"go.opentelemetry.io/collector/consumer/consumererror"
)

type noCancellationContext struct {
context.Context
}

func (noCancellationContext) Deadline() (deadline time.Time, ok bool) {
return
}

func (noCancellationContext) Done() <-chan struct{} {
return nil
}

func (noCancellationContext) Err() error {
return nil
}

// QueueSettings defines configuration for queueing batches before sending to the consumerSender.
type QueueSettings struct {
// Enabled indicates whether to not enqueue batches before sending to the consumerSender.
Expand Down Expand Up @@ -110,6 +127,10 @@ func (qrs *queuedRetrySender) send(req request) (int, error) {
return qrs.consumerSender.send(req)
}

// We need to decouple the context we store for async requests from the
// context received by the receiver. The grpc/http based receivers will cancel
bogdandrutu marked this conversation as resolved.
Show resolved Hide resolved
// the request context after this function returns.
req.setContext(noCancellationContext{Context: req.context()})
if !qrs.queue.Produce(req) {
return req.count(), errorRefused
}
Expand Down