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

Scope manager and exporter integration tests #1224

Closed
wants to merge 5 commits into from

Conversation

bengl
Copy link
Collaborator

@bengl bengl commented Jan 26, 2021

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.

@bengl bengl requested a review from a team as a code owner January 26, 2021 18:45
@bengl bengl changed the title Scope manager integration tests Scope manager and exporter integration tests Jan 26, 2021
@@ -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')
Copy link
Member

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?

Copy link
Collaborator Author

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.

Copy link
Member

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.

readline.on('line', line => {
try {
const { traces } = JSON.parse(line)
if (traces) proc.emit('logMessage', { log: traces })
Copy link
Member

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.

Copy link
Collaborator Author

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')
Copy link
Member

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.

Copy link
Collaborator Author

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?

Copy link
Member

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.

@rochdev rochdev mentioned this pull request Feb 9, 2021
@tlhunter tlhunter marked this pull request as draft February 21, 2023 23:02
@tlhunter
Copy link
Member

@bengl is this PR still relevant? Since it's been opened a few conflicts have happened and I see some unresolved queries from Roch.

@tlhunter
Copy link
Member

I'll close this PR for now but we can consider reopening it in the future.

@tlhunter tlhunter closed this Jan 12, 2024
@tlhunter tlhunter deleted the bengl/scopemanagerintegrationtests branch January 19, 2024 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants