-
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
Scope manager and exporter integration tests #1224
Conversation
@@ -20,6 +20,7 @@ const semver = require('semver') | |||
const emitter = new EventEmitter() | |||
|
|||
const hasSupportedAsyncLocalStorage = semver.satisfies(process.versions.node, '>=14.5 || ^12.19.0') | |||
const hasSupportedAsyncResource = semver.satisfies(process.versions.node, '>= 14 || ^13.9.0 || ^12.19.0') |
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.
Shouldn't these be the exact same versions as AsyncLocalStorage
?
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.
No, because executionAsyncResource was added before AsyncLocalStorage was.
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.
It's not really about when it was added, but more about when the bugs affecting us were fixed, which was in nodejs/node#33801 which affected both AsyncLocalStorage
and executionAsyncResource
and landed in 14.5.0.
integration-tests/helpers.js
Outdated
readline.on('line', line => { | ||
try { | ||
const { traces } = JSON.parse(line) | ||
if (traces) proc.emit('logMessage', { log: traces }) |
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 we somehow make this more robust? What if we test for example that a custom JSON logger is used by the tracer when configured? How can we validate that the JSON is actually traces? I'm also not sure that this is the right place for this parsing in any case.
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.
Right, I'm thinking the correct thing to do is just send log lines as events, and have any parsing be done in test code. That should be better for clarity and make it more adaptable for plugin tests or alternative logger tests later on.
await new Promise(resolve => { | ||
resolve() | ||
}).then(() => { | ||
res.end('hello, world\n') |
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 plugin attaches the span to the request object and doesn't use the scope manager, so this doesn't actually end up testing it.
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.
Would adding a tag to the active span suffice here then?
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.
What is this actually testing? If it's testing the scope manager maybe it should just be used directly.
@bengl is this PR still relevant? Since it's been opened a few conflicts have happened and I see some unresolved queries from Roch. |
I'll close this PR for now but we can consider reopening it in the future. |
What does this PR do?
Tests that scope managers work correctly through various async operations,
re-using existing integration tests to save time.
Similarly for log exporter (agent exporter is already being tested everywhere).
Motivation
We should have integration tests for each scope manager.