fix(auto-instrumentations-node): make SIGTERM shutdown test more reliable #2667
+22
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which problem is this PR solving?
The test
shuts down the NodeSDK when SIGTERM is received
is flaky due to making HTTP requests toexample.com
:Short description of the changes
The key improvements are:
Controlled Environment: Instead of depending on
example.com
(which could be slow/unreachable), we use a local server that responds immediately.Better Event Handling: Changed from using
req.on('close')
tores.on('end')
which is more reliable for confirming the request completed.Proper Cleanup: Added
server.close()
to the SIGTERM handler to ensure clean shutdown.Fixed Timing: The local server responds immediately, reducing the chance of hitting the test's 1500ms timeout.
The main issue was likely that requests to
example.com
were taking too long or failing, causing the test to hit its timeout before seeing theFinished request
message. By using a local server, we make the test much more deterministic and faster.