Skip to content

Scope manager and exporter integration tests - #1224

Closed
bengl wants to merge 5 commits into
masterfrom
bengl/scopemanagerintegrationtests
Closed

Scope manager and exporter integration tests#1224
bengl wants to merge 5 commits into
masterfrom
bengl/scopemanagerintegrationtests

Conversation

@bengl

@bengl bengl commented Jan 26, 2021

Copy link
Copy Markdown
Collaborator

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
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread integration-tests/helpers.js Outdated
readline.on('line', line => {
try {
const { traces } = JSON.parse(line)
if (traces) proc.emit('logMessage', { log: traces })

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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