RecorderSpec

A specialized case of SegmentSpec. A RecorderSpec is typically used with Shim.record. It defines the parameters of segment creation and segment lifetime.

Constructor

new RecorderSpec(params)

Parameters:
NameTypeDescription
paramsRecorderSpecParams

Members

after :SpecAfterFunction

callback :number|CallbackBindFunction

If a number, then the number indicates the position in the instrumented function's arguments list that represents the callback function. Otherwise, it should be the function to used in conjunction with the instrumented function.

Type:
Examples
Using a number
const spec = new RecorderSpec({ callback: -1 })
// elsewhere
const cb = Array.from(arguments).at(spec.callback)
Using a function
const spec = new RecorderSpec({ callback: () => {
  console.log('hello')
})
// elsewhere
instrumentedFunction('foo', spec.callback)

callbackRequired :boolean

When true, a recorded method must be called with a callback for a segment to be created. Does not apply if a custom callback method has been assigned via callback.

Type:
  • boolean

promise :boolean|null

Indicates if the instrumented function is expected to return a promise. When true, the segment recording will be extended until the promise has settled.

Type:
  • boolean | null

rowCallback :number|CallbackBindFunction

Like callback, this identifies a callback function in the instrumented function's arguments list. The difference is that the default behavior for row callbacks is to only create one segment for all calls to the callback. This is mostly useful for functions which will be called repeatedly, such as once for each item in a result set.

Type:

stream :boolean|string|null

Indicates if the instrumented function is expected to return a stream. When true, the segment recording will be extended until the end event of the stream. If the value is a string, it is assumed to be the name of an event to measure; a segment will be created to record emissions of the named event.

Type:
  • boolean | string | null