-
Notifications
You must be signed in to change notification settings - Fork 682
feat: Expose new kafka receiver/exporter knobs after upgrade to v0.158.0 #6868
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
base: main
Are you sure you want to change the base?
Changes from all commits
44ba568
38f1698
d4afe85
f85e815
dc597e3
c817f68
b011e15
a5c62fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -175,6 +175,11 @@ type Producer struct { | |
| // Maximum message bytes the producer will accept to produce. | ||
| MaxMessageBytes int `alloy:"max_message_bytes,attr,optional"` | ||
|
|
||
| // MaxBrokerWriteBytes is the maximum bytes the producer will write to a broker | ||
| // in a single request. Must be greater than or equal to max_message_bytes, and | ||
| // at least 100 MiB | ||
|
Comment on lines
+178
to
+180
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The wording on here is a bit awkward, checking upstream I think it's suggesting this value needs to be changed when max_message_bytes goes above 100MiB which is the default value here https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/kafkaexporter/README.md
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, we could just simplify it to this maybe there is a minimum value for
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ugh how annoying, from a purely practical standpoint maybe we mirror the upstream documentation for now? Edit: It;s a code comment that's accurate for the code so probably fine. |
||
| MaxBrokerWriteBytes int `alloy:"max_broker_write_bytes,attr,optional"` | ||
|
|
||
| // RequiredAcks Number of acknowledgements required to assume that a message has been sent. | ||
| // https://docs.confluent.io/platform/current/installation/configuration/producer-configs.html#acks | ||
| // The options are: | ||
|
|
@@ -198,17 +203,23 @@ type Producer struct { | |
|
|
||
| // Whether or not to allow automatic topic creation. | ||
| AllowAutoTopicCreation bool `alloy:"allow_auto_topic_creation,attr,optional"` | ||
|
|
||
| // Linger is how long individual topic partitions wait for more records before | ||
| // a request is built. Set to "0s" to send records as soon as they arrive. | ||
| Linger time.Duration `alloy:"linger,attr,optional"` | ||
| } | ||
|
|
||
| // Convert converts args into the upstream type. | ||
| func (args Producer) Convert() configkafka.ProducerConfig { | ||
| cfg := configkafka.NewDefaultProducerConfig() | ||
| cfg.MaxMessageBytes = args.MaxMessageBytes | ||
| cfg.MaxBrokerWriteBytes = args.MaxBrokerWriteBytes | ||
| cfg.RequiredAcks = configkafka.RequiredAcks(args.RequiredAcks) | ||
| cfg.Compression = args.Compression | ||
| cfg.CompressionParams = args.CompressionParams.Convert() | ||
| cfg.FlushMaxMessages = args.FlushMaxMessages | ||
| cfg.AllowAutoTopicCreation = args.AllowAutoTopicCreation | ||
| cfg.Linger = args.Linger | ||
| return cfg | ||
| } | ||
|
|
||
|
|
@@ -230,6 +241,8 @@ var ( | |
|
|
||
| // SetToDefault implements syntax.Defaulter. | ||
| func (args *Arguments) SetToDefault() { | ||
| producerDefaults := configkafka.NewDefaultProducerConfig() | ||
|
|
||
| *args = Arguments{ | ||
| Brokers: []string{"localhost:9092"}, | ||
| ClientID: "otel-collector", | ||
|
|
@@ -244,14 +257,16 @@ func (args *Arguments) SetToDefault() { | |
| }, | ||
| }, | ||
| Producer: Producer{ | ||
| MaxMessageBytes: 1000000, | ||
| RequiredAcks: 1, | ||
| Compression: "none", | ||
| MaxMessageBytes: 1000000, | ||
| MaxBrokerWriteBytes: producerDefaults.MaxBrokerWriteBytes, | ||
| RequiredAcks: 1, | ||
| Compression: "none", | ||
| CompressionParams: CompressionParams{ | ||
| Level: 0, // Default compression level | ||
| }, | ||
| FlushMaxMessages: 10000, | ||
| AllowAutoTopicCreation: true, | ||
| Linger: producerDefaults.Linger, | ||
| }, | ||
| RecordPartitioner: &RecordPartitionerConfig{ | ||
| StickyKey: &StickyKeyPartitionerConfig{Hasher: "sarama_compat"}, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,15 +58,16 @@ type Arguments struct { | |
| HeaderExtraction HeaderExtraction `alloy:"header_extraction,block,optional"` | ||
| TLS *otelcol.TLSClientArguments `alloy:"tls,block,optional"` | ||
|
|
||
| MinFetchSize int32 `alloy:"min_fetch_size,attr,optional"` | ||
| MaxFetchSize int32 `alloy:"max_fetch_size,attr,optional"` | ||
| MaxPartitionFetchSize int32 `alloy:"max_partition_fetch_size,attr,optional"` | ||
| MaxFetchWait time.Duration `alloy:"max_fetch_wait,attr,optional"` | ||
| GroupRebalanceStrategy string `alloy:"group_rebalance_strategy,attr,optional"` | ||
| GroupInstanceID string `alloy:"group_instance_id,attr,optional"` | ||
| RackID string `alloy:"rack_id,attr,optional"` | ||
| UseLeaderEpoch bool `alloy:"use_leader_epoch,attr,optional"` | ||
| ConnIdleTimeout time.Duration `alloy:"conn_idle_timeout,attr,optional"` | ||
| MinFetchSize int32 `alloy:"min_fetch_size,attr,optional"` | ||
| MaxFetchSize int32 `alloy:"max_fetch_size,attr,optional"` | ||
| MaxPartitionFetchSize int32 `alloy:"max_partition_fetch_size,attr,optional"` | ||
| MaxFetchWait time.Duration `alloy:"max_fetch_wait,attr,optional"` | ||
| GroupRebalanceStrategy string `alloy:"group_rebalance_strategy,attr,optional"` | ||
| GroupRebalanceStrategies []string `alloy:"group_rebalance_strategies,attr,optional"` | ||
| GroupInstanceID string `alloy:"group_instance_id,attr,optional"` | ||
| RackID string `alloy:"rack_id,attr,optional"` | ||
| UseLeaderEpoch bool `alloy:"use_leader_epoch,attr,optional"` | ||
| ConnIdleTimeout time.Duration `alloy:"conn_idle_timeout,attr,optional"` | ||
|
|
||
| ErrorBackOff ErrorBackOffArguments `alloy:"error_backoff,block,optional"` | ||
|
|
||
|
|
@@ -85,20 +86,19 @@ func (args *Arguments) SetToDefault() { | |
| // We use the defaults from the upstream OpenTelemetry Collector component | ||
| // for compatibility, even though that means using a client and group ID of | ||
| // "otel-collector". | ||
| Brokers: []string{"localhost:9092"}, | ||
| ClientID: "otel-collector", | ||
| GroupID: "otel-collector", | ||
| InitialOffset: "latest", | ||
| SessionTimeout: 10 * time.Second, | ||
| HeartbeatInterval: 3 * time.Second, | ||
| MinFetchSize: 1, | ||
| MaxFetchSize: 1048576, | ||
| MaxPartitionFetchSize: 1048576, | ||
| MaxFetchWait: 250 * time.Millisecond, | ||
| GroupRebalanceStrategy: "range", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this default setting was moved to below so that we can ensure it's only set if |
||
| RackID: "", | ||
| UseLeaderEpoch: true, | ||
| ConnIdleTimeout: 9 * time.Minute, | ||
| Brokers: []string{"localhost:9092"}, | ||
| ClientID: "otel-collector", | ||
| GroupID: "otel-collector", | ||
| InitialOffset: "latest", | ||
| SessionTimeout: 10 * time.Second, | ||
| HeartbeatInterval: 3 * time.Second, | ||
| MinFetchSize: 1, | ||
| MaxFetchSize: 1048576, | ||
| MaxPartitionFetchSize: 1048576, | ||
| MaxFetchWait: 250 * time.Millisecond, | ||
| RackID: "", | ||
| UseLeaderEpoch: true, | ||
| ConnIdleTimeout: 9 * time.Minute, | ||
| Logs: KafkaReceiverTopicEncodingConfig{ | ||
| Topics: []string{"otlp_logs"}, | ||
| Encoding: "otlp_proto", | ||
|
|
@@ -131,13 +131,36 @@ func (args *Arguments) Validate() error { | |
| } | ||
| } | ||
|
|
||
| switch args.GroupRebalanceStrategy { | ||
| // Upstream rejects setting both forms, whatever their values. | ||
| if len(args.GroupRebalanceStrategies) > 0 && args.GroupRebalanceStrategy != "" { | ||
| return fmt.Errorf("group_rebalance_strategy and group_rebalance_strategies are mutually exclusive; group_rebalance_strategy is deprecated, prefer group_rebalance_strategies") | ||
| } | ||
|
|
||
| for _, strategy := range args.GroupRebalanceStrategies { | ||
| if err := validateGroupRebalanceStrategy(strategy); err != nil { | ||
| return err | ||
| } | ||
| } | ||
|
|
||
| // An empty singular means unset; Convert applies the default. | ||
| if args.GroupRebalanceStrategy != "" { | ||
| if err := validateGroupRebalanceStrategy(args.GroupRebalanceStrategy); err != nil { | ||
| return err | ||
| } | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| const defaultGroupRebalanceStrategy = "range" | ||
|
|
||
| func validateGroupRebalanceStrategy(strategy string) error { | ||
| switch strategy { | ||
| case "range", "roundrobin", "sticky", "cooperative-sticky": | ||
| return nil | ||
| default: | ||
| return fmt.Errorf("group_rebalance_strategy must be one of 'range', 'roundrobin', 'sticky', or 'cooperative-sticky'") | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| type KafkaReceiverTopicEncodingConfig struct { | ||
|
|
@@ -232,7 +255,19 @@ func (args Arguments) Convert() (otelcomponent.Config, error) { | |
| result.ConsumerConfig.MaxFetchSize = args.MaxFetchSize | ||
| result.ConsumerConfig.MaxPartitionFetchSize = args.MaxPartitionFetchSize | ||
| result.ConsumerConfig.MaxFetchWait = args.MaxFetchWait | ||
| result.ConsumerConfig.GroupRebalanceStrategy = configkafka.GroupRebalanceStrategy(args.GroupRebalanceStrategy) | ||
| // Upstream rejects both forms being set, so send only the one in use. | ||
| if len(args.GroupRebalanceStrategies) > 0 { | ||
| strategies := make([]configkafka.GroupRebalanceStrategy, 0, len(args.GroupRebalanceStrategies)) | ||
| for _, strategy := range args.GroupRebalanceStrategies { | ||
| strategies = append(strategies, configkafka.GroupRebalanceStrategy(strategy)) | ||
| } | ||
| result.ConsumerConfig.GroupRebalanceStrategies = strategies | ||
| result.ConsumerConfig.GroupRebalanceStrategy = "" | ||
| } else if args.GroupRebalanceStrategy != "" { | ||
| result.ConsumerConfig.GroupRebalanceStrategy = configkafka.GroupRebalanceStrategy(args.GroupRebalanceStrategy) | ||
| } else { | ||
| result.ConsumerConfig.GroupRebalanceStrategy = defaultGroupRebalanceStrategy | ||
| } | ||
| result.ConsumerConfig.GroupInstanceID = args.GroupInstanceID | ||
| result.ClientConfig.RackID = args.RackID | ||
| result.ClientConfig.UseLeaderEpoch = args.UseLeaderEpoch | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.