Skip to content
This repository was archived by the owner on Jun 18, 2021. It is now read-only.

Opt-in hooks and signal by default - #33

Closed
rnchamberlain wants to merge 2 commits into
nodejs:masterfrom
rnchamberlain:default-hooks
Closed

rnchamberlain wants to merge 2 commits into
nodejs:masterfrom
rnchamberlain:default-hooks

Conversation

@rnchamberlain

Copy link
Copy Markdown
Contributor

This changes the default action on require('nodereport') to opt-in to the exception and fatal-error hooks, and to enable the signal handler. So 'node -r nodereport application.js' will get all the nodereport functionality without any application code changes.

For users programming to the API, a separate api-only entry point, require('nodereport/api') is provided. This does not enable the hooks and signal unless and until .setEvents() is called.

Addresses issue #25

This is a follow-on from PR #28

This changes the default action on require('nodereport') to opt-in
to the exception and fatal-error hooks, and to enable the signal
handler. So 'node -r nodereport application.js' will get all the
nodereport functionality without any application code changes.

For users programming to the API, a separate api-only entry point,
require('nodereport/api') is provided. This does not enable the
hooks and signal unless and until .setEvents() is called.
@rnchamberlain

Copy link
Copy Markdown
Contributor Author

@sam-github @richardlau @Fishrock123 this should be the same as the final version in the earlier PR #28 but a quick re-review would be much appreciated - thanks

@sam-github sam-github left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a test, at least a positive one? For example, test-api.js should require ../api to ensure it remains requireable?

Comment thread index.js Outdated
const api = require('./api');

// Process NODEREPORT_EVENTS env var
const options = process.env.NODEREPORT_EVENTS;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify and remove the conditional if you want:

const options = process.env.NODEREPORT_EVENTS || 'exception+fatalerror+signal+apicall';
api.setEvents(options);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, done

@rnchamberlain

rnchamberlain commented Dec 15, 2016 •

Copy link
Copy Markdown
Contributor Author

@sam-github agree, needs a positive test for require('nodereport/api') with a call to nodereport.triggerReport() I'll clone test-api.js as test-api-nohooks.js and then we'll have coverage for both routes.

rnchamberlain added a commit that referenced this pull request Dec 21, 2016
This changes the default action on require('nodereport') to opt-in
to the exception and fatal-error hooks, and to enable the signal
handler. So 'node -r nodereport application.js' will get all the
nodereport functionality without any application code changes.

For users programming to the API, a separate api-only entry point,
require('nodereport/api') is provided. This does not enable the
hooks and signal unless and until .setEvents() is called.

PR-URL: #33
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
@rnchamberlain

Copy link
Copy Markdown
Contributor Author

Landed as 8605e4c

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants