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.
This PR includes the following fixes:
Conditionally access the
window
object for push gateway exporterThe push gateway exporter has a reference to window, which won't be defined for serverless functions. I added a check to make sure
window
was defined before adding/removing event listeners to it.Do not pass
MAX_SAFE_INTEGER
as an interval valueThe push gateway and otlp-http exporters both used
Number.MAX_SAFE_INTEGER
for thePeriodicExportingMetricReader
export interval. Because this value is ultimately passed tosetInterval
, we need to use a smaller value instead.This is because setInterval and setTimeout represent the timeout value as a 32bit unsigned integer. So,
MAX_SAFE_INTEGER
will cause wrapping, leading to some funkiness. (See: MDN docs)Wrap
Deno.cwd()
in a try/catchIt's possible for
Deno.cwd
to be defined (and even return"function"
when passed totypeof
), but if the Deno script was not given permissions to access the filesystem, then callingDeno.cwd()
will throw an error. I uncovered this is in Supabase/Deno Deploy.So, I added a try-catch there... as well as for
process.cwd
, just to be defensive (could remove that upon request)