test: Added assertSegmentDuration and missing segment duration tests#3875
Draft
amychisholm03 wants to merge 1 commit intonewrelic:mainfrom
Draft
test: Added assertSegmentDuration and missing segment duration tests#3875amychisholm03 wants to merge 1 commit intonewrelic:mainfrom
assertSegmentDuration and missing segment duration tests#3875amychisholm03 wants to merge 1 commit intonewrelic:mainfrom
Conversation
bizob2828
reviewed
Apr 9, 2026
Member
bizob2828
left a comment
There was a problem hiding this comment.
i see the CI failed and the actual duration vs record durations seem off like our timing is wrong
39495ba to
46c9bca
Compare
065269b to
0e14911
Compare
Contributor
Author
Yeah, there are some large time differences. However, the failures are different packages every time, so I don't think it has to deal with how we are timing the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
WIP: Not ready for full review yet, just testing CI.
As we migrate our instrumentation to use the tracing channel subscribers, we need a way to be able to check if our segment durations are expected (e.g. not ending immediately). However, previous attempts have been extremely flaky because our CI has much more constrained environments vs our PCs running locally.
This PR adds a new custom assertion,
assertSegmentDurationand adds it to tests whose packages we have migrated over and need segment duration timing tests (packages likemysql2with "easy" way to assert time likesleep(2)were excluded). In an attempt to combat flakiness,getDefaultThresholdinassert-segment-duration.jscomes up with a percentage threshold (as a float) based on the number of CPU cores available. The numbers are basically arbitrary but seem okay enough to consistently pass.Some tests, like
memcached.test.js, are really really flaky so they have a high threshold supplied instead of using the default.How to Test
Related Issues
Closes #3862