-
Notifications
You must be signed in to change notification settings - Fork 375
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 instrumentation for HTTP.rb #853
Conversation
return super(request) unless tracer_enabled? | ||
|
||
tracer = datadog_configuration[:tracer] | ||
datadog_span = tracer.active_span |
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.
Question for @delner: what's our way to ensuring that tracer.active_span
is the trace we expect in integrations like these (with separate start and end events)?
It seems like it would find the correct one no child integration "leaks", but I'm not sure how confident we are in this.
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 think this is a good observation @marcotc; I don't think this is a safe operation because although in theory, if everything else is working as intended it should be no problem. If a span is opened (but not closed) between wrap_request
and wrap_response
, this would return the wrong span.
If there's a better way to 'track' the span without leaking, we should do that instead. Using tracer.trace
with a block is the most reliable way. I think Marco suggested the use of ActiveSupport notifications elsewhere, for which we already have a module that serves as a reliable means of doing this work for you: so we might want to consider that.
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.
per latest comments, refactored to monkeypatching + wrapping with .trace
, rather than AS approach
…le and appraisals
…, webmocks causing issues with when it intercepts requests
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.
idk why this keeps starting a review every time i want to make a one comment reply 😭
… error, wip tests for connection erroor
As its currently implemented, does instrumentation for HTTP.rb apply out of the box when you set |
merge master
merge master
…it tagging into request and response related tags
very sorry for the long delay here folks. My bandwidth has been stretched thinner than i'd like. Finally had a free day so was able to get to this. After reviewing the feedback here from @delner : #853 (comment) I decided to do a rewrite of the httprb instrumentation using a For context, at first I did attempt to rewrite this to use the Active Support approach suggested by @marcotc here: #853 (comment) However, bc I've tried to bring this back up to a reviewable state, and up to date with master. I think I need to add some tests for analytics + distributed tracing, but given the refactor, wanted to get a review to make sure I'm on the right track. Some notes for reviewer
let me know what you think. I'm sorry again about the long delay here, definitely will make sure to prioritise any feedback to get this over the finish line. |
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.
@ericmustin the implementation looks in line with our existing HTTP client implementations, great job!
One thing that we'll want before we can merge this PR is to add documentation about this integration to our GettingStarted.md
.
@marcotc gotcha, ty for taking a look. ok let me clean this up otw, and will try to review/improve testing suite as well. |
…sts for distributed tracing and sampling
To this end I would recommend looking at the |
…ixes, clean up documentation around split_by_domain
@marcotc @delner Make sense. I've taken a pass at adding multiplexing here for |
Friendly bump? I would love to have this instrumentation in the gem! |
Is this work done? I would love to have it available |
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.
Looks very close to completion!
I notice we are missing an Integration test, similar to: https://github.com/DataDog/dd-trace-rb/blob/master/spec/ddtrace/contrib/rack/integration_spec.rb
There's also a comment regarding documentation.
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` | | ||
| `service_name` | Service name for `httprb` instrumentation. | `'httprb'` | | ||
| `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` | | ||
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.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.
We've removed the tracer
option from integrations in #1079, we can remove it here too.
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.
ah i see, ty. updated, had to clean up the tests and some of the pin
code to account for this as well after bringing this up to date with master. I think it's good now tho
@marcotc thanks for the quick look, I added the integration_spec test suite for this integration and also brought things up to date after noticing some of the deprecation warnings i was seeing after bringing this up to date with master |
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.
🎉
Anything still missing @ericmustin? The current version seems to have a complete implementation, with tests and documentation. (I noticed that this PR is still tagged as |
@marcotc i believe it's good to go, that label was added by brett when the pr was first made, i've updated |
@ericmustin a few conflicts need to be resolved, but we are good to go! |
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.
🚀 🚀 🚀
Basic Instrumentation for http.rb using the features middleware that underlies.
https://github.com/httprb/http/wiki/Logging-and-Instrumentation#instrumentation
https://github.com/httprb/http/pull/499
https://github.com/httprb/http/tree/4-x-stable/lib/http/features
This PR addresses this community card and open issue 529
Essentially httprb offers middleware functionality for wrapping the request and response methods in custom methods, where we inject distributed tracing context , start/stop the spans, and add the relevant span tags metadata.
Submitting this a bit early so I can get some feedback on whether this approach is appropriate here, I think it's much cleaner than trying to overwrite the entire
Http::Client
. This is still pretty rough as I need to make the error handling a bit more defensive and ensure the appropriate params get returned when the tracer is disabled, but getting this in early to see if this approach is appropriate.TODO: