-
Notifications
You must be signed in to change notification settings - Fork 309
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
[http] Add connection establishment tracing. #299
Conversation
Didn’t see a |
@rochdev Seems like on Node v4 & v6 the I see that in the past you had added a way to tell the agent how many traces to expect before invoking the callback, but subsequently removed it again. (Although you forgot to remove the counts, e.g. here.) However, that wouldn’t have worked here either, because I’m really not expecting a specific number of traces to be flushed at once, so in 11c6491 I made it possible to tell the agent to wait a bit before considering work done. Do you have a better idea? |
I should add that the current implementation on |
The idea is that this was very prone to errors since you had to know exactly how many traces to expect, which in some cases didn't work well. It was also very heavy since we had to clean the entire cache and reset the agent after every single test. The idea by removing it is that it will keep trying if it receives an invalid trace, meaning that leaks are simply ignored. This is similar to how Nock works. At some point I'd like to be able to completely remove the need for cleaning the cache.
As mentioned above, this is by design and any previously leaked trace should not impact the current test.
I think supporting multiple calls to What do you think? |
So that’s the thing, I don’t really expect it to be called any number of times. That it is invoked twice on Node v4 and v6 seems to me (naively) mostly an implementation detail that I don’t really care about in this test. While I do know it will take 2 times, it would mean I’d have to add something like Maybe if you feel strongly about specifying specific numbers, do you have any insights into why this is being broken up into 2 invocations on these older Node versions? That way I can maybe better reason about the solution. |
Got it 👍 |
@@ -43,7 +43,17 @@ function patch (http, methodName, tracer, config) { | |||
|
|||
const req = request.call(this, options, callback) | |||
|
|||
req.on('socket', () => { | |||
req.on('socket', socket => { | |||
socket.once(socket.encrypted ? 'secureConnect' : 'connect', () => { |
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.
If the socket never connects and is reused for other requests, won't this created a leak?
Superseded by #406 |
Ace, thanks! |
This is helpful in order to know how much time you're spending on creating connections and determine if you should use keep-alive.
I also slightly refactored the tests to always sort spans before yielding them to the tests. There didn’t appear to be any test that cared about the unordered spans, but an option to not sort should be easy enough to add in the future, if that’s ever needed.