grafana / pyroscope-nodejs

Pyroscope NodeJS integration
Apache License 2.0
25 stars 18 forks source link

Log errors to stdout/err #29

Open eh-am opened 1 year ago

eh-am commented 1 year ago

When first starting the

Pyroscope.init({
  serverAddress: 'https://pyroscope.cloud',
  appName: 'nodejs-test',
})

Pyroscope.start()

And error was thrown:

throw 'Pyroscope is not configured. Please call init() first.';

But I was calling init, which is confusing.

By setting the DEBUG environment variable, the error message is shown:

 DEBUG='pyroscope*' node main.js
  pyroscope Pyroscope is running on a cloud server, but no authToken was provided. Pyroscope will not be able to ingest data. +1ms

Therefore we should just log that message to stdout/err instead of hiding behind an env var.

GeoffreyPlitt commented 3 months ago

Another symptom of the same issue: We got our token wrong, but we had no idea at first. No errors or warnings on STDOUT. Finally after turning on debug logging, we found pyroscope { status: 'error', error: 'authentication error: invalid token' }. Errors like this should not be swallowed in DEBUG logs.