Description
We're using this library with our lambda function for creating embedded metrics, and it works fantastically for that use case, but we've been struggling a little bit with getting it all to play smoothly during local development. I'm aware that we can set AWS_EMF_ENVIRONMENT
to Local
at runtime to make the library use stdout, and we've added that to a few of our package.json scripts to make it easier for everyone, but there are still a few cases where there's no simple or easy route to setting this, or somebody does something a little different and forgets to add that environment variable (we work in a large monorepo project, so the number of people contributing who know many detail around EMF is fairly low). This leads to confusing error messages about UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 0.0.0.0:25888
when running in Node 12 - and for anyone who is running in Node 14, it seems to actually just crash the local server.
Looking into the library, it looks like Agent is set up as the default environment, and the Local environment probe
method is intentionally a no-op, which means that the only way to use the library in local environment mode is via this environment variable.
Is there a historical reason why it is this way? Is there no other way to detect if the environment should be Agent
, and thus switch the default environment around, or having some other way to auto-detect if the environment should be Local
(e.g. if NODE_ENV !== 'production'
)?