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/net/http: cause the default config to set the analytics rate in spanOpts #564

Merged
merged 6 commits into from
Jan 13, 2020

Conversation

knusbaum
Copy link
Contributor

WrapHandler fails to set the EventSampleRate tag as ServeMux.ServeHTTP does.
Rather than relying on ServeMux.ServeHTTP and WrapHandler to individually set
the tag, we will have the defaults function set the tag in the config if the global analytics
rate is not NaN.

…in spanOpts

WrapHandler fails to set the EventSampleRate tag as ServeMux.ServeHTTP does.
Rather than relying on ServeMux.ServeHTTP and WrapHandler to individually set
the tag, we will have the defaults function set the tag in the config if the global analytics
rate is not NaN.
@knusbaum knusbaum added this to the 1.21.0 milestone Jan 10, 2020
@knusbaum knusbaum requested a review from gbbr January 10, 2020 20:32
Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

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

This is good. Can we please add a regression test and fix CI?

@knusbaum
Copy link
Contributor Author

Fixed the tests, added testing for regression that I have confirmed fails without this patch.

contrib/net/http/http_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

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

You’re right. This gives better coverage, but can we tidy up a bit more?

assert.Len(t, spans, 1)
s := spans[0]
assert.Equal(t, rate, s.Tag(ext.EventSampleRate))
asserts := []func(t *testing.T, mt mocktracer.Tracer, rate interface{}, opts ...Option){
Copy link
Contributor

Choose a reason for hiding this comment

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

Would a map with a string key help be more descriptive?

t.Run("defaults", func(t *testing.T) {
mt := mocktracer.Start()
defer mt.Stop()
for assert := range asserts {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we are overusing and shadowing this name “assert”. It’s a test, maybe “test” is better? You could use the suggested map’s key string as the name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. There are too many things called "assert." I think a map with a string name is better.

Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

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

Really nice work Kyle.

@knusbaum
Copy link
Contributor Author

The tests are failing due to a grpc library issue. I'll leave this here for now and address that issue in a separate PR.

@knusbaum
Copy link
Contributor Author

The issue was fixed upstream. See: #566

@knusbaum knusbaum merged commit 1efe3a4 into v1 Jan 13, 2020
@knusbaum knusbaum deleted the knusbaum/fix-contrib-http branch January 14, 2020 22:26
mingrammer pushed a commit to mingrammer/dd-trace-go that referenced this pull request Dec 22, 2020
…in spanOpts (DataDog#564)

WrapHandler fails to set the EventSampleRate tag as ServeMux.ServeHTTP does.
Rather than relying on ServeMux.ServeHTTP and WrapHandler to individually set
the tag, we will have the defaults function set the tag in the config if the global analytics
rate is not NaN.
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.

None yet

2 participants