Captures async hook stack traces for specific resource types and events.
const capturer = StackCapturer.forAllEvents()
capturer.shouldCapture('init') // => true
const stack = capturer.captureStack()
const processed = capturer.processStack()npm install ah-stack-capturer
Creates StackCapturere instance.
Either shouldCapture OR events with optional types need to be supplied.
Parameters
$0Object configures when a stack should be captured$0.eventsSet<string>? defines on which async hooks events (init|before|after|destroy) a stack should be captured (optional, defaultnull)$0.typesSet<string>? defines for which async hook types a stack should be captured (optional, defaultnull)$0.shouldCapturefunction?function ((event, type, activity)if supplied overrides theshouldCapturemethod entirely (optional, defaultnull)
Returns true|false indicating if a stack should be captured according to the
options passed in the @constructor.
Parameters
eventString the async hook event (init|before|after|destroy)typeString the type of async resource that triggered the event
Returns Boolean true or false indicating if a stack should be captured
Captures the current stack.
Returns String the current stack
Processes the supplied stack by splitting the string into lines and removing those that are part of the async hook execution itself.
This allows the user to focus only on the relevant stack.
Parameters
stackString the captured stack
Returns Array<String> the processed stack
Creates a StackCapturer that captures ALL events for the supplied types.
Parameters
Creates a StackCapturer that captures nothing.
MIT
