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

Add franz-go #3113

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add franz-go #3113

wants to merge 1 commit into from

Conversation

jontonsoup
Copy link

What does this PR do?

Motivation

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.
  • For internal contributors, a matching PR should be created to the v2-dev branch and reviewed by @DataDog/apm-go.

Unsure? Have a question? Request a review!

@jontonsoup jontonsoup requested review from a team as code owners January 22, 2025 22:03
Copy link
Contributor

@hannahkm hannahkm left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution! I have left a few comments and questions. Let's also add some more tests in franz_test.go for some more coverage. We'd like to test the functions you created in option.go and franz.go, especially the more complex functions like Produce() or PollFetches().


func init() {
telemetry.LoadIntegration(componentName)
tracer.MarkIntegrationImported("github.com/twmb/franz-go")
Copy link
Contributor

Choose a reason for hiding this comment

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

This should also come with a matching line in ddtrace/tracer/option.go so that it can be properly marked as imported.

carrier := NewRecordHeadersCarrier(r.Headers)
if err := tracer.Inject(span.Context(), carrier); err != nil {
// We still want to continue even if injection failed
span.SetTag("error.msg", err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

If you would only like to save the error message, you can use ext.ErrorMsg as the key. But why not use span.SetTag(ext.Error, err)? Setting ext.Error will also set ext.ErrorMsg and other things. Using ext.Error is also typically our preferred method as well.

}
carrier := NewRecordHeadersCarrier(headers)

// Test ForeachKey
Copy link
Contributor

Choose a reason for hiding this comment

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

For testing individual scenarios, use t.Run() to separate them out. This will make it easier to pinpoint what is going wrong if one of them were to fail.

} = (*RecordHeadersCarrier)(nil)

// ForeachKey iterates over every header.
func (c RecordHeadersCarrier) ForeachKey(handler func(key, val string) error) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason why ForeachKey is called on RecordHeadersCarrier instead of a pointer to it (*RecordHeadersCarrier)?

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.

3 participants