Skip to content

Commit

Permalink
Change memorylimiter and queue full errors to carry time-after inform…
Browse files Browse the repository at this point in the history
…ation

Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu committed Feb 12, 2025
1 parent b2612a9 commit 4afe9ab
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
18 changes: 16 additions & 2 deletions exporter/exporterqueue/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ package exporterqueue // import "go.opentelemetry.io/collector/exporter/exporter

import (
"context"
"errors"
"time"

"google.golang.org/genproto/googleapis/rpc/errdetails"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/durationpb"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/exporter"
Expand All @@ -16,7 +21,16 @@ import (
// not block.
// Experimental: This API is at the early stage of development and may change without backward compatibility
// until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.
var ErrQueueIsFull = errors.New("sending queue is full")
var ErrQueueIsFull = func() error {
st := status.New(codes.ResourceExhausted, "sending queue is full")
dt, err := st.WithDetails(&errdetails.RetryInfo{
RetryDelay: durationpb.New(1 * time.Second),
})
if err != nil {
panic(err)

Check warning on line 30 in exporter/exporterqueue/queue.go

View check run for this annotation

Codecov / codecov/patch

exporter/exporterqueue/queue.go#L30

Added line #L30 was not covered by tests
}
return dt.Err()
}()

// Done represents the callback that will be called when the read request is completely processed by the
// downstream components.
Expand Down
15 changes: 14 additions & 1 deletion internal/memorylimiter/memorylimiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import (
"time"

"go.uber.org/zap"
"google.golang.org/genproto/googleapis/rpc/errdetails"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/durationpb"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/internal/memorylimiter/iruntime"
Expand All @@ -29,7 +33,16 @@ const (
var (
// ErrDataRefused will be returned to callers of ConsumeTraceData to indicate
// that data is being refused due to high memory usage.
ErrDataRefused = errors.New("data refused due to high memory usage")
ErrDataRefused = func() error {
st := status.New(codes.ResourceExhausted, "data refused due to high memory usage")
dt, err := st.WithDetails(&errdetails.RetryInfo{
RetryDelay: durationpb.New(1 * time.Second),
})
if err != nil {
panic(err)

Check warning on line 42 in internal/memorylimiter/memorylimiter.go

View check run for this annotation

Codecov / codecov/patch

internal/memorylimiter/memorylimiter.go#L42

Added line #L42 was not covered by tests
}
return dt.Err()
}()

// ErrShutdownNotStarted indicates no memorylimiter has not start when shutdown
ErrShutdownNotStarted = errors.New("no existing monitoring routine is running")
Expand Down

0 comments on commit 4afe9ab

Please sign in to comment.