Skip to content

Commit

Permalink
create constant for errors requiring backoff
Browse files Browse the repository at this point in the history
  • Loading branch information
yiquanzhou committed Jan 2, 2025
1 parent 3804d00 commit 79afbda
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion receiver/kafkareceiver/kafka_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"errors"
"fmt"
"slices"
"strconv"
"sync"
"time"
Expand Down Expand Up @@ -38,6 +39,10 @@ const (

var errInvalidInitialOffset = errors.New("invalid initial offset")

var errorsRequiringBackoff = []error{
errors.New("data refused due to high memory usage"), // error returned by memory limiter processor
}

// kafkaTracesConsumer uses sarama to consume and handle messages from kafka.
type kafkaTracesConsumer struct {
config Config
Expand Down Expand Up @@ -628,7 +633,7 @@ func (c *tracesConsumerGroupHandler) ConsumeClaim(session sarama.ConsumerGroupSe
}

func errorRequiresBackoff(err error) bool {
return err.Error() == "data refused due to high memory usage"
return slices.Contains(errorsRequiringBackoff, err)
}

func (c *metricsConsumerGroupHandler) Setup(session sarama.ConsumerGroupSession) error {
Expand Down

0 comments on commit 79afbda

Please sign in to comment.