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

contrib/segmentio/kafka.go.v0: refactor tracing code #2885

Merged
merged 13 commits into from
Oct 16, 2024

Conversation

rarguelloF
Copy link
Contributor

@rarguelloF rarguelloF commented Sep 24, 2024

What does this PR do?

segmentio/kafka-go.v0: Split tracing logic into a separate package that does not import github.com/segmentio/kafka-go so it can be used in orchestrion.

Additionally, it changes the docker image used for kafka tests to confluentinc/confluent-local:7.5.0.

Motivation

orchestrion cannot reuse this contrib package as it is right now because it would case an import cycle. Creating a separate package allows us to reuse this logic.

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

Unsure? Have a question? Request a review!

@github-actions github-actions bot added the apm:ecosystem contrib/* related feature requests or bugs label Sep 24, 2024
@pr-commenter
Copy link

pr-commenter bot commented Sep 24, 2024

Benchmarks

Benchmark execution time: 2024-10-15 11:17:22

Comparing candidate commit ebe1069 in PR branch rarguelloF/APPSEC-53289/refactor-segmentio-kafka with baseline commit 93311db in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 57 metrics, 2 unstable metrics.

@rarguelloF rarguelloF marked this pull request as ready for review September 25, 2024 14:26
@rarguelloF rarguelloF requested review from a team as code owners September 25, 2024 14:26
Comment on lines +217 to +218
require.Len(t, writtenMessages, len(messagesToWrite))
require.Len(t, readMessages, len(messagesToWrite))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why switch from assert to require here? This is the kind of case where assert allows further assertions to run which may provide more context about what's happened that caused this to fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the motivation of the require change here is because later in the test these slices are accessed by index, and if the length is not what we expect we will get a panic, making the test output noisy and confusing.

msg := kafka.Message{
Key: []byte("key1"),
Value: []byte("value1"),
}

b.ResetTimer()
for n := 0; n < b.N; n++ {
r.startSpan(nil, &msg)
tr.StartConsumeSpan(ctx, wrapMessage(&msg))
Copy link
Contributor

Choose a reason for hiding this comment

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

So this isn't your doing; but those functions return a span that is immediately dropped on the floor... and that makes this benchmark susceptible to have the compiler optimize away a bunch of side-effects that are rendered void by this.

Usually, one wants to assign the output to a package-scoped variable so the compiler doesn't do these optimizations. It would also be good form to clean up (read: finish) those spans.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wow thanks, good to know this :)

@rarguelloF rarguelloF merged commit 88722fc into main Oct 16, 2024
145 checks passed
@rarguelloF rarguelloF deleted the rarguelloF/APPSEC-53289/refactor-segmentio-kafka branch October 16, 2024 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:ecosystem contrib/* related feature requests or bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants