-
Notifications
You must be signed in to change notification settings - Fork 2.8k
kafkaexporter: Opt-in to use franz-go client #40364
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
kafkaexporter: Opt-in to use franz-go client #40364
Conversation
Adds the option to use the franz-go client in the `kafkaexporter`. The main rationale for this change is to allow users to opt-in to use a more performant Kafka client, as the default Sarama client has been known to have performance issues in high-throughput scenarios. The change _should_ be backward compatible, and significantly increases the production performance of the `kafkaexporter` when in use. ``` $ benchstat sarama.txt franz-go.txt <region:us-east-1> goos: darwin goarch: arm64 pkg: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/kafkaexporter cpu: Apple M2 Pro │ sarama.txt │ franz-go.txt │ │ sec/op │ sec/op vs base │ Logs-12 55.56µ ± 5% 33.40µ ± 4% -39.88% (p=0.000 n=10) Metrics-12 60.69µ ± 6% 39.34µ ± 17% -35.18% (p=0.001 n=10) Traces-12 57.09µ ± 9% 35.71µ ± 13% -37.44% (p=0.000 n=10) geomean 57.74µ 36.07µ -37.53% │ sarama.txt │ franz-go.txt │ │ B/op │ B/op vs base │ Logs-12 5.792Ki ± 0% 2.207Ki ± 1% -61.90% (p=0.000 n=10) Metrics-12 9.545Ki ± 0% 4.339Ki ± 16% -54.54% (p=0.000 n=10) Traces-12 7.329Ki ± 0% 2.967Ki ± 5% -59.52% (p=0.000 n=10) geomean 7.400Ki 3.051Ki -58.76% │ sarama.txt │ franz-go.txt │ │ allocs/op │ allocs/op vs base │ Logs-12 55.00 ± 0% 29.00 ± 0% -47.27% (p=0.000 n=10) Metrics-12 58.00 ± 0% 32.00 ± 0% -44.83% (p=0.000 n=10) Traces-12 55.00 ± 0% 29.00 ± 0% -47.27% (p=0.000 n=10) geomean 55.98 29.97 -46.47% ``` Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
var errs []error | ||
for _, r := range result { | ||
if r.Err != nil { | ||
fmt.Println(r.Err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid calling fmt.Println
since it doesn't adhere to the logging configuration set, you must use the provided logger within the collector defined constructors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I was doing some debugging earlier and forgot to remove it, thanks for the callout
goleak: | ||
ignore: | ||
top: | ||
- github.com/twmb/franz-go/pkg/kfake.(*group).manage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a bug in kfake. I think we could work around it by deleting the consumer groups prior to shutting down the kfake cluster, but this seems OK. Should we open an issue against franz-go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Speaking with @axw there is still a few things that is to be ironed out, so I'll come back once the PR is ready.
My advice for preparing to adopt a new client is:
- Make it easy to review by separating out changes into their own files
- Also provides the ability to exclude them in builds if that is helpful with go build tags
- It also makes it easier to remove the older files once ready
- Use the feature gate for this type of change since we are planning for it to be a one way door since there is an advantage in moving.
- It also gives users the ability to find where to reach out to on a github issue if things have gone wrong.
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
I can address conflicts once the PR is approved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks great for me, @axw has already called out some work but I am not sure if it is blocking.
makeHeader func(key string, value []byte) H, | ||
getHeaders func(M) []H, | ||
setHeadersFunc func(M, []H), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there anyway around needing to pass callback functions here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can refactor this once we permanently remove Sarama to not have this abstraction.
Currently, this ensures the same logic is applied for both adapters. I don't love it but it seems like the best approach to apply this generic flow consistently.
Signed-off-by: Marc Lopez Rubio <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes. I have some more minor questions/suggestions, otherwise LGTM
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you!
Signed-off-by: Marc Lopez Rubio <[email protected]>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Adds the option to use the franz-go client in the `kafkaexporter`. The main rationale for this change is to allow users to opt-in to use a more performant Kafka client, as the default Sarama client has been known to have performance issues in high-throughput scenarios. The change _should_ be backward compatible, and significantly increases the production performance of the `kafkaexporter` when in use. ``` $ benchstat sarama.txt franz-go.txt goos: darwin goarch: arm64 pkg: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/kafkaexporter cpu: Apple M2 Pro │ sarama.txt │ franz-go.txt │ │ sec/op │ sec/op vs base │ Logs-12 55.56µ ± 5% 33.40µ ± 4% -39.88% (p=0.000 n=10) Metrics-12 60.69µ ± 6% 39.34µ ± 17% -35.18% (p=0.001 n=10) Traces-12 57.09µ ± 9% 35.71µ ± 13% -37.44% (p=0.000 n=10) geomean 57.74µ 36.07µ -37.53% │ sarama.txt │ franz-go.txt │ │ B/op │ B/op vs base │ Logs-12 5.792Ki ± 0% 2.207Ki ± 1% -61.90% (p=0.000 n=10) Metrics-12 9.545Ki ± 0% 4.339Ki ± 16% -54.54% (p=0.000 n=10) Traces-12 7.329Ki ± 0% 2.967Ki ± 5% -59.52% (p=0.000 n=10) geomean 7.400Ki 3.051Ki -58.76% │ sarama.txt │ franz-go.txt │ │ allocs/op │ allocs/op vs base │ Logs-12 55.00 ± 0% 29.00 ± 0% -47.27% (p=0.000 n=10) Metrics-12 58.00 ± 0% 32.00 ± 0% -44.83% (p=0.000 n=10) Traces-12 55.00 ± 0% 29.00 ± 0% -47.27% (p=0.000 n=10) geomean 55.98 29.97 -46.47% ``` <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Improves the exporter's production performance. <!--Describe what testing was performed and which tests were added.--> #### Testing Unit tested, benchmarked against a local Kafka broker. <!--Describe the documentation added.--> #### Documentation Updated the Readme. <!--Please delete paragraphs that you did not use before submitting.--> --------- Signed-off-by: Marc Lopez Rubio <[email protected]>
Description
Adds the option to use the franz-go client in the
kafkaexporter
. Themain rationale for this change is to allow users to opt-in to use a
more performant Kafka client, as the default Sarama client has been
known to have performance issues in high-throughput scenarios.
The change should be backward compatible, and significantly increases
the production performance of the
kafkaexporter
when in use.Link to tracking issue
Improves the exporter's production performance.
Testing
Unit tested, benchmarked against a local Kafka broker.
Documentation
Updated the Readme.