census-instrumentation / opencensus-node

A stats collection and distributed tracing framework
https://opencensus.io
Apache License 2.0
273 stars 97 forks source link

fix: prevent unhandled promise rejections #1083

Closed chrisjarman closed 8 months ago

chrisjarman commented 1 year ago

Return the Promise from createTimeSeries in the export method. This allows any thrown exceptions to be to be caught correctly in start's setInterval callback. This allows consumers of this library to handle errors via the onMetricUploadError without their process being taken down by an unhandled Promise rejection.

N.B. This change does not solve the problem of metrics being delivered more frequently than Stackdriver can handle. The use of setInterval is inappropriate. I would recommend using setTimeout instead - waiting for the upload to be complete before scheduling the next attempt.

google-cla[bot] commented 1 year ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.