Finch-API / finch-api-node

Apache License 2.0
5 stars 1 forks source link

Cannot log Request Id's when using the Auto-Pagination pattern #305

Closed johnMorone closed 7 months ago

johnMorone commented 7 months ago

Hello, I'm trying to reconcile the suggested auto pagination pattern in the docs with the recommendation from the Production Readiness Checklist to log request id's for all transactions, not just errors.

Logging errors with this pattern works fine as long as it is wrapped in a try ... catch block, where the catch can log the error. However, it appears there is no way to log non-erroring requests with this pattern, as it can't be used along with the withResponse method.

Am I understanding this correctly? Is it OK to not log these instances if so? Or is there some undocumented method to log using this pattern either currently available or upcoming?

Thank you!

yjp20 commented 7 months ago

Hey, thanks for raising this issue! The best way to do this will be to pass in a custom fetch into the Finch client. See https://github.com/Finch-API/finch-api-node#customizing-the-fetch-client. We'll improve the docs story here around logging.

johnMorone commented 7 months ago

Thank you @yjp20 ! This works fantastically! If I was more careful with the documentation, I think I could have found this - sorry for not seeing it. I do think a few small doc updates could streamline the dev experience nicely here: linking from the auto pagination pattern section as well as calling out in the Customizing the fetch client section that this is a recommended way to have consistent logging as mentioned in the Production Readiness Checklist.

Thank you again - I'll close this out as I'm good to go here!