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

Fix: router and http2 #3012

Closed
wants to merge 8 commits into from
Closed

Fix: router and http2 #3012

wants to merge 8 commits into from

Conversation

shahmirn
Copy link

@shahmirn shahmirn commented Apr 17, 2023

What does this PR do?

We recently experimented with switching our express server to http2, and noticed that we weren't seeing a breakdown of the express requests under APM > Services anymore.

Dug into the code, and it looks like it's simply because the router plugin wasn't listening for the http2 server's requests finishing?

This PR should hopefully fix that issue?

Motivation

Plugin Checklist

Additional Notes

@shahmirn shahmirn requested a review from a team as a code owner April 17, 2023 16:01
@shahmirn shahmirn changed the title Maybe fix: router and http2 Fix: router and http2 Apr 17, 2023
Copy link
Contributor

@Qard Qard left a comment

Choose a reason for hiding this comment

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

Good catch. Do you think you could add a test to confirm this solves the issue?

@shahmirn
Copy link
Author

Good catch. Do you think you could add a test to confirm this solves the issue?

Done. Updated PR to add tests.

Took quite bit of time to figure out that the http2 plugin wasn't getting instrumented, and then another incorrect rabbit hole of creating an http2 agent before realizing that wasn't needed.

It should all be working now though.

@shahmirn shahmirn requested a review from Qard April 18, 2023 15:56
@@ -0,0 +1,167 @@
'use strict'
Copy link
Member

Choose a reason for hiding this comment

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

Can both tests be merged with just a parameter of which HTTP module to use? Otherwise this is a lot of duplication.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, should be able to do something like:

const tests = [
{ name: 'http', createServer () { /* ... / } },
{ name: 'http2', createServer () { /
... */ } },
]

for (const { name, createServer } of tests) {
describe(name, () => {
// use createServer wherever needed, and add the tests...
})
}

Copy link
Author

@shahmirn shahmirn Apr 27, 2023

Choose a reason for hiding this comment

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

I don't think this is a good idea.

The actual implementation of the tests are slightly different, so there'd end up being if statements in 'em anyways.

For http2, fetch-h2 is being used as the client, as axios doesn't support http2. And the URLs being passed to fetch-h2 start with http2://, so that it knows we're dealing with a http2 clearText request

so even though the test names are the same, and the expectations are similar, how the data is fetched is different.

Copy link
Member

Choose a reason for hiding this comment

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

Why not just use an HTTP client that supports both? Then this becomes a non-issue and both tests can be merged.

@tlhunter tlhunter requested a review from a team as a code owner August 15, 2023 22:07
@tlhunter tlhunter requested review from jbertran and removed request for a team August 15, 2023 22:07
@tlhunter
Copy link
Member

@shahmirn is this PR something you're still interested in working on? If not I can close it for now.

@shahmirn
Copy link
Author

@tlhunter Nope; closing it out.

@shahmirn shahmirn closed this Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants