Skip to content

Commit

Permalink
Merge pull request #30 from easyops-cn/chj/kafka_max_message
Browse files Browse the repository at this point in the history
feat(opentelemetry-collector): kafka-exporter增加maxmessagebytes参数 refs…
  • Loading branch information
hzhaop authored Dec 29, 2023
2 parents 055a746 + 6e1ab94 commit 1300bed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions exporter/kafkaexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ type Config struct {
// The name of the kafka topic to export to (default otlp_spans for traces, otlp_metrics for metrics)
Topic string `mapstructure:"topic"`

// The maximum permitted size of a message (defaults to 1000000). Should be
// set equal to or smaller than the broker's `message.max.bytes`.
MaxMessageBytes int `mapstructure:"max_message_bytes"`

// message key in order to partition
MessageKey string `mapstructure:"message_key"`

Expand Down
3 changes: 3 additions & 0 deletions exporter/kafkaexporter/kafka_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ func newSaramaProducer(config Config) (sarama.SyncProducer, error) {
}
c.Version = version
}
if config.MaxMessageBytes > 0 {
c.Producer.MaxMessageBytes = config.MaxMessageBytes
}
if err := ConfigureAuthentication(config.Authentication, c); err != nil {
return nil, err
}
Expand Down

0 comments on commit 1300bed

Please sign in to comment.