forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[exporter/kafka] Allow configuring the acknowledgement behaviour (ope…
…n-telemetry#6301) * feat(exporter/kafka): allow configuring the acknowledgement behaviour * doc(exporter/kafka): add additional context to the RequiredAcks parameter * chore(exporter/kafka): validate RequiredAcks option * chore(container.image.name): add changelog entry
- Loading branch information
Showing
7 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,9 @@ The following settings can be optionally configured: | |
User should calculate this as `num_seconds * requests_per_second` where: | ||
- `num_seconds` is the number of seconds to buffer in case of a backend outage | ||
- `requests_per_second` is the average number of requests per seconds. | ||
- `producer` | ||
- `max_message_bytes` (default = 1000000) the maximum permitted size of a message in bytes | ||
- `required_acks` (default = 1) controls when a message is regarded as transmitted. https://pkg.go.dev/github.com/Shopify/[email protected]#RequiredAcks | ||
|
||
Example configuration: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,10 @@ | |
package kafkaexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/kafkaexporter" | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/Shopify/sarama" | ||
"go.opentelemetry.io/collector/config" | ||
"go.opentelemetry.io/collector/exporter/exporterhelper" | ||
) | ||
|
@@ -67,6 +69,14 @@ type Metadata struct { | |
type Producer struct { | ||
// Maximum message bytes the producer will accept to produce. | ||
MaxMessageBytes int `mapstructure:"max_message_bytes"` | ||
|
||
// RequiredAcks Number of acknowledgements required to assume that a message has been sent. | ||
// https://pkg.go.dev/github.com/Shopify/[email protected]#RequiredAcks | ||
// The options are: | ||
// 0 -> NoResponse. doesn't send any response | ||
// 1 -> WaitForLocal. waits for only the local commit to succeed before responding ( default ) | ||
// -1 -> WaitForAll. waits for all in-sync replicas to commit before responding. | ||
RequiredAcks sarama.RequiredAcks `mapstructure:"required_acks"` | ||
} | ||
|
||
// MetadataRetry defines retry configuration for Metadata. | ||
|
@@ -83,5 +93,8 @@ var _ config.Exporter = (*Config)(nil) | |
|
||
// Validate checks if the exporter configuration is valid | ||
func (cfg *Config) Validate() error { | ||
if cfg.Producer.RequiredAcks < -1 || cfg.Producer.RequiredAcks > 1 { | ||
return fmt.Errorf("producer.required_acks has to be between -1 and 1. configured value %v", cfg.Producer.RequiredAcks) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters