feat(instr-runtime-node): add configurable gcDurationBuckets option#3328
feat(instr-runtime-node): add configurable gcDurationBuckets option#3328lukeramsden wants to merge 2 commits intoopen-telemetry:mainfrom
Conversation
Allow users to customize the histogram bucket boundaries for the v8js.gc.duration metric via the gcDurationBuckets configuration option, similar to how monitoringPrecision is configurable.
3e6cee2 to
c627f76
Compare
maryliag
left a comment
There was a problem hiding this comment.
Thank you for your contribution.
You will need to add a changelog and tests to this PR before we can merge it.
@maryliag This gets me and I have to check again almost everytime. The core repo requires PRs to explicitly include a CHANGELOG.md entry. The contrib repo does not, because the release process automatically adds changelog entries based on the commit titles. |
df45353 to
4490d1d
Compare
this is what I get for having a bunch of tabs open to review and not checking the repo 🤦 |
4490d1d to
696905d
Compare
|
I have pushed some tests for the GC collection, which pass locally. Will leave the changelog alone then 😄 |
Add tests verifying that the GC duration histogram is created correctly with both default and custom bucket boundaries.
696905d to
b0c20ee
Compare
|
I've pushed a fix for prettier lint but the test failures don't make sense to me - no test files found? |
| "compile:with-dependencies": "nx run-many -t compile -p @opentelemetry/instrumentation-runtime-node", | ||
| "prepublishOnly": "npm run compile", | ||
| "test": "nyc --no-clean mocha 'test/**/*.test.ts'", | ||
| "test": "nyc --no-clean mocha --expose-gc 'test/**/*.test.ts'", |
There was a problem hiding this comment.
the test failures might be related to this change, what this parameter does? does it need some extra info to find specific files?
There was a problem hiding this comment.
This exposes the ability to trigger GC which is what the test uses.
There was a problem hiding this comment.
I don't see how it would be possible to test this instrumentation collector without this flag which is I assume why there were no tests in the first place
I believe that v18 and v20 of Node that your CI tests with do not have this flag and therefore I do not know how one would test this collector on those versions. Up to you how to proceed, we could:
- Not test this collector (which is the current state of the codebase and my change does not make particularly any worse) and therefore delete my tests
- Disable these tests in certain CI matrix formations where we use older Node.js versions
- Find an alternative way to do this on those versions, however I do not know of a way to do that
There was a problem hiding this comment.
There is a script that can be used to skip tests given a certain major version (only major). A possible solution is to:
- have a test script without the flag (works for all versions)
- have a test script with the flag and skip for nodejs versions lower than 22
- refactor the new tests to skip if the
global.gc()method is not avaiable
Example of how the scripts would look like.
"test": "npm run test:nogc && npm run test:gc",
"test:nogc": "nyc --no-clean mocha 'test/**/*.test.ts'",
"test:gc": "SKIP_TEST_IF_NODE_OLDER_THAN=22 nyc --no-clean mocha --require '../../scripts/skip-test-if.js' --expose-gc 'test/**/*.ts'",
WDYT?
|
Silly question: is this not what the |
Does that work if the view buckets are more granular or have larger ranges than the underlying histogram? I've never heard of views and no idea how they work internally (and docs aren't clear) |
Yes. The underlying mechanism the same for |
|
@lukeramsden did you have time to review the latest comments? |
Which problem is this PR solving?
Monitoring precision being configurable but not the bucket boundary for GC duration seems like an oversight in this package. I'd like to add 2s and 5s boundaries in my application.
Short description of the changes
Allow users to customize the histogram bucket boundaries for the v8js.gc.duration metric via the gcDurationBuckets configuration option, similar to how monitoringPrecision is configurable.