feat: Make Agent.flush() return a Promise if no callback is passed as param - #3167
Conversation
|
💚 CLA has been signed |
|
Hi @adamyeats. Nice. This is still "draft", so I'm not sure if you wanted review on it yet. The implementation looks perfect to me.
|
|
Hey @trentm, great to make contact with you! 👋 As you noticed, I haven't added tests yet thus it was still in draft, but thank you for the review on what was already there.
Quick question: is there anywhere in the documentation that will need to be edited? If so, can you point me in the right direction? |
Yah, look for "apm.flush" in https://github.com/elastic/apm-agent-nodejs/blob/main/docs/agent-api.asciidoc |
|
@trentm This should now be ready for review, thanks! |
trentm
left a comment
There was a problem hiding this comment.
@adamyeats This is great, thanks! One nit, and one thing in the test. I'm guessing the test with node v8 will fail. We shall see. I'm "approving" because, IIRC, our Jenkins CI guards require an approval before running contributed code.
| }).finally(function () { | ||
| agent.destroy() | ||
| t.end() | ||
| }) |
There was a problem hiding this comment.
Unfortunately we still support and test with node v8, which doesn't support Promise.finally. I think it would be fine to put the agent.destroy(); t.end() in the .then(...) handler and call it a day.
There was a problem hiding this comment.
Ah yes, those were the days! Agreed, tweaked this in 6a6afea.
Co-authored-by: Trent Mick <trentm@gmail.com>
|
@elasticmachine, run elasticsearch-ci/docs |
|
Parfait. Thanks very much! |
* upstream/main: (44 commits) action: abort builds when new commit (elastic#3196) docs: note that 3.40.0 was bad release (elastic#3194) chore(deps-dev): bump @babel/cli from 7.20.7 to 7.21.0 (elastic#3170) chore(deps-dev): bump @babel/core from 7.20.2 to 7.21.0 (elastic#3169) ci: drop max-parallel for GH actions (elastic#3191) test: correct sense of test message (elastic#3186) 3.43.0 (elastic#3184) test, ci: some small changes (elastic#3183) ci: limit parallel GH Action test runs to try to avoid 429 errors on checkout (elastic#3180) fix: transaction name for Next.js API routes in next@13.2 was broken (elastic#3178) mongodb@5 support (elastic#3177) chore(deps-dev): bump body-parser from 1.20.1 to 1.20.2 (elastic#3171) chore(deps-dev): bump restify from 11.0.0 to 11.1.0 (elastic#3172) docs: minor fix in README for Azure Functions example (elastic#3175) feat: Make Agent.flush() return a Promise if no callback is passed as param (elastic#3167) chore(deps-dev): bump @types/node from 18.11.9 to 18.14.0 (elastic#3165) chore(deps-dev): bump @hapi/hapi from 21.2.1 to 21.3.0 (elastic#3166) chore(deps-dev): bump undici from 5.19.1 to 5.20.0 (elastic#3164) chore(deps-dev): bump fastify from 4.12.0 to 4.13.0 (elastic#3154) Use composite action for updatecli workflow (elastic#3162) ...
… param (elastic#3167) This PR modifies `Agent.flush()` to return a `Promise` if no `callback` parameter is supplied to the function. This allows the method to be usable with the `await` keyword. Closes elastic#2857
Fixes #2857.
This PR modifies
Agent.flush()to return aPromiseif nocallbackparameter is supplied to the function. This allows the method to be usable with theawaitkeyword.Checklist