-
Notifications
You must be signed in to change notification settings - Fork 39
feat: added support for express v5 #1654
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
Conversation
| ]; | ||
| expect(spanNames).to.have.members(expectedSpanNames); | ||
| expect(spans.length).to.eql(7); | ||
| expect(spanNames).to.eql(spans.map(s => s.data.operation)); |
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.
Addressed here: https://github.com/instana/nodejs/pull/1249/files#r1709329147
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.
The OpenTelemetry sampler runs on Express v5 because our local dependencies include Express v5, and the @opentelemetry/auto-instrumentations-node package indirectly depends on the express package.
@opentelemetry/auto-instrumentations-node is a meta-package that bundles multiple auto-instrumentation libraries, including @opentelemetry/instrumentation-express.
Rather than overriding it with Express v4 and updating to v5 later, we can adapt the tests to v5 now. Changes have been made accordingly.
kirrg001
left a comment
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.
This is not a feature.
Where is the express v5 test? Could you add a comment please? THanks
The link does not open for me. Could you pls add a comment on the target test? Thanks! |
packages/core/src/tracing/instrumentation/frameworks/express.js
Outdated
Show resolved
Hide resolved
c7bbcdf to
7da5e32
Compare
…na initialization
7da5e32 to
e921c1b
Compare
| ]; | ||
| expect(spanNames).to.have.members(expectedSpanNames); | ||
| expect(spans.length).to.eql(7); | ||
| expect(spanNames).to.eql(spans.map(s => s.data.operation)); |
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.
The OpenTelemetry sampler runs on Express v5 because our local dependencies include Express v5, and the @opentelemetry/auto-instrumentations-node package indirectly depends on the express package.
@opentelemetry/auto-instrumentations-node is a meta-package that bundles multiple auto-instrumentation libraries, including @opentelemetry/instrumentation-express.
Rather than overriding it with Express v4 and updating to v5 later, we can adapt the tests to v5 now. Changes have been made accordingly.
| ]; | ||
| expect(spanNames).to.have.members(expectedSpanNames); | ||
| expect(resp.spans.length).to.be.gte(7); | ||
| // NOTE: middleware spans are not collected when migrating to express v5 because: |
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.
The OpenTelemetry sampler runs on Express v5 because our local dependencies include Express v5, and the @opentelemetry/auto-instrumentations-node package indirectly depends on the express package.
@opentelemetry/auto-instrumentations-node is a meta-package that bundles multiple auto-instrumentation libraries, including @opentelemetry/instrumentation-express.
Rather than overriding it with Express v4 and updating to v5 later, we can adapt the tests to v5 now. Changes have been made accordingly.
| // EXIT www.example.com | ||
| // 2 x express middleware, 1 x request handler | ||
| // 1 x tlc connect, 1 x tls connect | ||
| expectExactlyNMatching(spans, 6, [ |
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.
The OpenTelemetry exporter runs on Express v5 because our local dependencies include Express v5, and the @opentelemetry/auto-instrumentations-node package indirectly depends on the express package.
@opentelemetry/auto-instrumentations-node is a meta-package that bundles multiple auto-instrumentation libraries, including @opentelemetry/instrumentation-express.
Rather than overriding it with Express v4 and updating to v5 later, we can adapt the tests to v5 now. Changes have been made accordingly.
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.
Why did the request handler disappear?
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.
Why don't we use the loadExpressV4 mock for now?
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.
Why did the request handler disappear?
I beleive it is also because of some changes in the v5. I have no resources to point to at this moment. will update.
Why don't we use the loadExpressV4 mock for now?
Already discussed. #1654 (comment)
| } | ||
|
|
||
| latestVersion = utils.getLatestVersion(currency.name, installedVersion); | ||
| latestVersion = utils.getLatestVersion({ |
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 no longer need this. Express is latest now
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 removed the beta flag for Express but kept this logic for general use cases, even though we don't have any at the moment!
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.
Okay. Could you pls extract these from this PR and create a new PR? Thanks
| }); | ||
|
|
||
| require('./mockVersion'); | ||
| require('@instana/core/test/test_util/load_express_v4'); |
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.
This seems wrong
require('./mockVersion');
require('@instana/core/test/test_util/load_express_v4');
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.
Thanks. Corrected!
| process.exit(0); | ||
| }); | ||
|
|
||
| require('@instana/core/test/test_util/load_express_v4'); |
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.
TODO: This test needs to run against v4 and v5. You can copy the iteration from the official express test and just just a local mock version file.
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.
Done
| sendToParent: require('./sendToParent'), | ||
| stringifyItems: require('./stringifyItems'), | ||
| mockRequire: require('./mockRequire'), | ||
| load_express_v4: require('./load_express_v4'), |
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.
Camelcase vs underscore consistency.
|
|
||
| requireHook.init({ logger: testUtils.createFakeLogger() }); | ||
| const pattern = requireHook.buildFileNamePattern(['node_modules', 'express', 'lib', 'router', 'route.js']); | ||
| // Adapt express v5: it has some changes in the folder structure |
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.
Could you please update this comment and put v4 and v5 latest version links to the file on github? Thanks
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.
Done
| } | ||
|
|
||
| require('./tracing'); | ||
|
|
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.
Same here: Why don't we use the loadExpressV4 mock for now?
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.
Even with the mock, this will run on Express v5 because:
-
@opentelemetry/auto-instrumentations-node is a dependency in our package.
-
It depends on @opentelemetry/instrumentation-express, which in turn depends on express.
-
AFAIK, this dependency resolves to our local node_modules since we already have express in our root dependencies.
So, it will run on v5 regardless, which aligns with our need to use v5.
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.
NPM should load express v4, because @opentelemetry/instrumentation-express depends on v4.
:( But it does not
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. @opentelemetry/instrumentation-express has no peer or prod dependency on express. Thats why
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.
Can't we use overrides for 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.
Yes I think so.
But do we need it ? Because we want to anyway update to v5.
If we override this, then we will have to revert it back in the v5 test update
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 ship the exporter with a specific pinned version for Otel
"@instana/serverless": "4.9.0","@opentelemetry/api": "1.4.1",
"@opentelemetry/core": "1.17.1"
As long as we still test against the right conditions, I am fine with leaving it as it is.
If customers can use Express v5 with these ^ versions, then we an update the test.
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.
Sorry I don't completely understand this.
Are you suggesting that we use the override here to use v4 or just leave it as it is (v5) ?
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 long as we still test against the right conditions, I am fine with leaving it as it is.
Conditions: The pinned production versions for the Otel exporter.
|
@abhilash-sivan Please link the currency express ticket to Q2 currency epic. Thanks |
|
|
||
| beforeEach(async () => { | ||
| await agentControls.waitUntilAppIsCompletelyInitialized(expressControls.getPid()); | ||
| ['latest', 'v4'].forEach(version => { |
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.
Just wrapped inside the version iterator and added version in application start calls
|
|
||
| mochaSuiteFn('http with proxy', function () { | ||
| this.timeout(config.getTestTimeout()); | ||
| ['latest', 'v4'].forEach(version => { |
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.
Here also, only wrapped the tests in versions iterator and updated the server start commands with env variable
kirrg001
left a comment
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.
LGTM
refs INSTA-12542
This PR sets the new express v5(tagged
nextmajor release) as latest version for express in our SDK.The plan is to adapt v5 for the tests upon release. So till then we will keep the tests to run against express v4.
Express released 5.1.0:
github: https://github.com/expressjs/express/releases/tag/v5.1.0
see npm: https://www.npmjs.com/package/express?activeTab=versions