Skip to content
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

feat: add support for github.com/confluentinc/confluent-kafka-go/kafka (& its v2 counterpart) #273

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

darccio
Copy link
Member

@darccio darccio commented Sep 12, 2024

Adds support for instrumenting github.com/confluentinc/confluent-kafka-go/kafka and github.com/confluentinc/confluent-kafka-go/v2/kafka.

Tests for v2 library are commented because both libraries cannot coexist in the same package. An upcoming PR from @rarguelloF will separate the tests in a way that will keep them apart, so we'll be able to run both test suites. The v2 tests have been tested locally successfully.

@darccio darccio requested a review from a team as a code owner September 12, 2024 13:18
Comment on lines +50 to +52
if err != nil {
t.Skipf("Failed to start kafka test container: %v\n", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if err != nil {
t.Skipf("Failed to start kafka test container: %v\n", err)
}
utils.AssertTestContainersError(t, err)

this function already exists to check whether the error should mark the test as skipped or not

Comment on lines +50 to +52
if err != nil {
t.Skipf("Failed to start kafka test container: %v\n", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if err != nil {
t.Skipf("Failed to start kafka test container: %v\n", err)
}
utils.AssertTestContainersError(t, err)

same here

kafkatrace: gopkg.in/DataDog/dd-trace-go.v1/contrib/confluentinc/confluent-kafka-go/kafka.v2
kafka: github.com/confluentinc/confluent-kafka-go/v2/kafka
template: |-
func(p *kafka.Producer, err error) (*kafkatrace.Producer, error) {
Copy link
Contributor

@rarguelloF rarguelloF Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a safe replacement to do, as we originally have a *kafka.Producer and we return a *kafkatrace.Producer

if the user has code like this, it would break:

var (
	producer *kafka.Producer
	err error
)

producer, err = kafka.NewProducer() // replacement happens here

Also, if there are any type assertions in the users code, these would break as well.

I think the only safe approach here is to instrument the library code itself, similar as I did here: #266

cc @RomainMuller @eliottness please confirm if this is correct 🙇

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm. There is the same issue with gorilla/mux

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct - Actually, assignment to a struct field is more likely to be where the problem is than an explicitly typed var, but same thing really.

github-merge-queue bot pushed a commit that referenced this pull request Sep 18, 2024
Change the behavior of the code generation from `_integration-tests` to
generate individual test files in each test package.

This speeds up significantly when running only one test suite, which is
particularly useful when developing a new integration.

Also, this change is required for
#273, where we are testing
both `confluent-kafka-go` v1 and v2. Since both of them depend on CGO
`librdkafka`, they cannot coexist in the same package.
Copy link

codecov bot commented Sep 23, 2024

Codecov Report

Attention: Patch coverage is 0% with 206 lines in your changes missing coverage. Please review.

Project coverage is 71.25%. Comparing base (7dac678) to head (15f4783).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
.../tests/confluentinc_confluent-kafka-go.v2/kafka.go 0.00% 103 Missing ⚠️
...sts/tests/confluentinc_confluent-kafka-go/kafka.go 0.00% 103 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #273      +/-   ##
==========================================
- Coverage   78.53%   71.25%   -7.28%     
==========================================
  Files         140      144       +4     
  Lines        6359     7780    +1421     
==========================================
+ Hits         4994     5544     +550     
- Misses        955     1828     +873     
+ Partials      410      408       -2     
Components Coverage Δ
Generators 77.07% <ø> (-2.26%) ⬇️
Instruments 88.05% <ø> (ø)
Go Driver 72.81% <ø> (-7.44%) ⬇️
Toolexec Driver 66.56% <ø> (-3.35%) ⬇️
Aspects 71.79% <ø> (-7.36%) ⬇️
Injector 73.24% <ø> (-5.33%) ⬇️
Job Server 63.20% <ø> (-5.63%) ⬇️
Integration Test Suite 80.47% <0.00%> (-11.87%) ⬇️
Other 71.25% <0.00%> (-7.28%) ⬇️
Files with missing lines Coverage Δ
.../tests/confluentinc_confluent-kafka-go.v2/kafka.go 0.00% <0.00%> (ø)
...sts/tests/confluentinc_confluent-kafka-go/kafka.go 0.00% <0.00%> (ø)

... and 124 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants