-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(cli-storybook): Add telemetry #8803
Conversation
I had to add an empty SIGINT listener for execa to exit and the process.on exit to trigger. I'll need to understand why.
@Josh-Walker-GM I know we tested it locally, but I'm not sure that registering on
Source: https://nodejs.org/dist/latest-v18.x/docs/api/process.html#event-exit. We could call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious why we record attributes twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to record the command name inside the middleware because it might not have been recorded in the handler is if the check had throw an error.
We probably don't need the command: 'storybook'
in the handler recordTelemetryAttributes
since it'll be set by the middleware. I kept it there mainly to just be consistent that all handlers set the command name.
Trade off here. Checks must work but when they do we get no automatic indication on the telemetry that the command failed.
Thanks @jtoar this was definitely something I was coming back to since this PR highlighted the weird SIGINT behaviour. I've read over more of the node docs and this was particularly helpful:
I tested to ensure that the default exit causes by SIGINT does not trigger the process exit event - it does not. Taking a step back and looking at our requirements might be useful. We must have the telemetry shutdown fire before the process exits. This is achieved by having it called on the process exit event. We know now that we must ensure node's other mechanisms of termination trigger the process exit event. It would seem to me then that the best course of action would be to provide listeners on the SIGINT and SIGTERM which call process.on('SIGINT', () => {
if(process.listenerCount('SIGINT') > 1){
return
}
process.exit()
}) That means we're free to have custom behaviour for these events where we need them. If we do this then I can't think of a way in which node exits without a call to There are still some signals where we don't have the power to intervene on like SIGKILL. Lastly, also from the docs:
We'll probably want to include this default exit behaviour for SIGHUP too. Making sure we exit within the roughly 10s grace period windows would give us - likely not a problem. EDIT: Pushed up what I was talking about for an example. |
Okay I think this is ready now @jtoar but I'll take another look over this with fresh eyes tomorrow to check. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested this code, but just reading it it looks good to me
Instruments the storybook command with telemetry. I had forgot about it since it lives in it's own package now. **WIP** I had to add an empty SIGINT listener for execa to exit and the process.on exit to trigger. I'll need to understand why...
Instruments the storybook command with telemetry. I had forgot about it since it lives in it's own package now.
WIP
I had to add an empty SIGINT listener for execa to exit and the process.on exit to trigger. I'll need to understand why...