-
Notifications
You must be signed in to change notification settings - Fork 373
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
[net/http] Allow overriding service name. #430
Conversation
@delner It looks like only unrelated tests are failing. Other than that this PR is ready for review. |
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.
A minor thing and a possible bug, but otherwise this looks good!
@@ -514,8 +514,10 @@ Where `options` is an optional `Hash` that accepts the following parameters: | |||
|
|||
| Key | Description | Default | | |||
| --- | --- | --- | | |||
| ``service_name`` | Service name used for `http` instrumentation | http | | |||
| ``service_name`` | Service name used for `http` instrumentation | net/http | |
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'm glad you're making this correction in the documentation, but this coincidentally highlights maybe a poor name here (which includes a /
.) Probably outside the scope of this PR, but we should probably revisit what this default name is in the future.
Rakefile
Outdated
@@ -232,11 +232,13 @@ task :ci do | |||
sh 'rvm $MRI_VERSIONS --verbose do appraisal contrib rake spec:graphql' | |||
sh 'rvm $MRI_VERSIONS --verbose do appraisal contrib rake spec:racecar' | |||
sh 'rvm $MRI_VERSIONS --verbose do appraisal contrib rake spec:redis' | |||
sh 'rvm $MRI_VERSIONS --verbose do appraisal contrib rake spec:http' |
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.
Minor, but can you put this in alphabetical order with the other contrib names?
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.
fixed
lib/ddtrace/contrib/http/patcher.rb
Outdated
service = Datadog.configuration[:http][:service_name] | ||
tracer = Datadog.configuration[:http][:tracer] | ||
|
||
pin = Datadog::Pin.new(service, app: APP, app_type: Datadog::Ext::AppTypes::WEB, tracer: tracer) |
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.
So the following is a really nuanced thing, related to a bug I stumbled upon in our Sequel integration...
It's possible that an Net::HTTP
object is initialized before Datadog is patched/configured, in which case, the object in question will not trace properly. To avoid this scenario, I would suggest refactoring this pin initialization into its own def datadog_pin
function, which lazily initializes the pin.
The other benefit you'd get is that you can remove the #initialize
patching altogether from this, making the patch less invasive.
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.
yup lazy initialization seems to work. Thanks for suggesting it, it made the code much cleaner
@delner I've addressed your comments, this PR should be ready for round two |
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.
Love it! Nice work, @pawelchcki ! 💯
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 wait, have to fix the tests first. But pending that, I'm happy with this.
0e09ccc
to
f82706a
Compare
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.
👍
As mentioned in #407 our documentation stated that
service_name
can be overridden fornet/http
integration. However that was not the case.In addition the documentation wrongly stated default
service_name
ashttp
.This PR adds ability to override
service_name
and aligns documentation with actual default service name.