Methods

createShimFromType(params) → {Shim}

Parameters:
NameTypeDescription
paramsobject

input params

Properties
NameTypeDescription
typestring

shim type

agentAgent

instance of agent

moduleNamestring

module name

resolvedNamestring

fully resolved name of module

shimNamestring

name of shim, used to associate multiple shim instances

pkgVersionstring

version of pkg

Returns:

shim instance

Type: 
Shim

Type Definitions

CallbackBindFunction(shim, func, name, segment, args)

Performs segment binding on a callback function. Useful when identifying a callback is more complex than a simple argument offset.

Parameters:
NameTypeDescription
shimShim

The shim this function was passed to.

funcfunction

The function being recorded.

namestring

The name of the function.

segmentTraceSegment

The segment that the callback should be bound to.

argsArray.<*>

The arguments being passed into the function.

ClassWrapSpecParams

Type:
  • object
Properties
NameTypeAttributesDescription
es6boolean<optional>
prefunction<optional>
postfunction<optional>

ConstructorHookFunction(shim, Base, name, args)

Pre/post constructor execution hook for wrapping classes.

Parameters:
NameTypeDescription
shimShim

The shim performing the wrapping/binding.

Basefunction

The class that was wrapped.

namestring

The name of the Base class.

argsArray.<*>

The arguments to the class constructor.

See
  • ClassWrapSpec.pre

DatastoreParametersParams

Type:
  • object
Properties
NameTypeDescription
hoststring

The host of the database server being interacted with. If provided, along with port_path_or_id, then an instance metric will also be generated for this database.

port_path_or_idnumber | string

The port number or path to domain socket used to connect to the database server.

database_namestring

The name of the database being queried or operated on.

collectionstring

The name of the collection or table being queried or operated on.

InContextCallback(segment)

A function that will be invoked in the context of the current segment. Instrumentations that need to perform operations during the invocation of a method that has been instrumented can provide an InContextCallback function to accomplish their needs. The callback is invoked in the same async context as the instrumented function, i.e. concurrent to the execution of the instrumented function, and within the same segment.

Parameters:
NameTypeDescription
segmentTraceSegment

The current segment.

InstrumentationDescriptorParams

Type:
  • object
Properties
NameTypeDescription
absolutePathstring
modulestring
moduleNamestring
shimNamestring
onErrorInstrumentationOnError
onRequireInstrumentationOnRequire
resolvedNamestring
typestring

InstrumentationOnError(error)

Parameters:
NameTypeDescription
errorError | object

The error thrown by onRequire when there was an issue registering the instrumentation.

InstrumentationOnRequire(shim, resolvedNodule, moduleName)

Parameters:
NameTypeDescription
shimShim

The shim instance to use for the instrumentation.

resolvedNoduleobject

The module being instrumented as returned by Node's require function.

moduleNamestring

The simple name of the module, i.e. the value passed to the require function.

Throws:
Error | object

MessageBrokerHeadersFn(inject) → {Array.<object>}

Parameters:
NameTypeDescription
injectfunction

A function with the signature function(headers, useAlternateHeaderNames). The passed in headers object will be updated with distributed trace headers. When the second parameter is true (the default), alternate style (not HTTP style) header names will be used, i.e. names that are safe for non-HTTP transports.

Returns:

An array of objects, wherein each object will be updated with distributed trace headers.

Type: 
Array.<object>

MessageConsumerWrapperFunction(shim, consumer, name, queue) → {function}

Function that is used to wrap message consumer functions. Used alongside the MessageShim#recordSubscribedConsume API method.

Parameters:
NameTypeDescription
shimMessageShim

The shim this function was handed to.

consumerfunction

The message consumer to wrap.

namestring

The name of the consumer method.

queuestring

The name of the queue this consumer is being subscribed to.

Returns:

The consumer method, possibly wrapped.

Type: 
function

MessageFunction(shim, func, name, args) → {specs.MessageSpec}

Used for determining information about a message either being produced or consumed.

Parameters:
NameTypeDescription
shimMessageShim

The shim this function was handed to.

funcfunction

The produce method or message consumer.

namestring

The name of the producer or consumer.

argsArray.<*>

The arguments being passed into the produce method or consumer.

Returns:

The specification for the message being produced or consumed.

Type: 
specs.MessageSpec

MessageHandlerFunction(shim, func, name, args) → {specs.MessageSpec}

A function that is used to extract properties from a consumed message. This method is handed the results of a consume call. If the consume used a callback, then this method will receive the arguments to the callback. If the consume used a promise, then this method will receive the resolved value.

Parameters:
NameTypeDescription
shimMessageShim

The shim this function was handed to.

funcfunction

The produce method or message consumer.

namestring

The name of the producer or consumer.

argsArray | *

Either the arguments for the consumer callback function or the result of the resolved consume promise, depending on the mode of the instrumented method.

Returns:

The extracted properties of the consumed message.

Type: 
specs.MessageSpec

MessageSpecParams

Type:
  • object
Properties
NameTypeAttributesDescription
destinationNamenumber | string<optional>
destinationTypestring | null<optional>
headersObject.<string, string> | null<optional>
messageHeadersMessageBrokerHeadersFn | null<optional>
messageHandlerMessageHandlerFunction | null<optional>
queuenumber | string | null<optional>
routingKeystring | null<optional>

MessageSubscribeSpecParams

Type:
  • object
Properties
NameTypeAttributesDescription
consumernumber | null<optional>

MiddlewareMounterSpecParams

Type:
  • object
Properties
NameTypeAttributesDescription
routeRouteParserFunction | string | number | null<optional>
wrapperMiddlewareWrapperFunction<optional>

MiddlewareSpecParams

Type:
  • object
Properties
NameTypeAttributesDescription
appendPathboolean<optional>
nextnumber | RouteNextFunction<optional>
paramsRouteParameterFunction | null<optional>
reqnumber | RouteRequestFunction<optional>
resnumber<optional>
routenumber | string | null<optional>
typestring<optional>

MiddlewareTypeNames

Type:
  • Object.<string, string>

MiddlewareWrapperFunction(shim, middleware, fnName, routeopt)

Called for each middleware passed to a mounting method. Should perform the wrapping of the middleware.

Parameters:
NameTypeAttributesDefaultDescription
shimWebFrameworkShim

The shim used for instrumentation.

middlewarefunction

The middleware function to wrap.

fnNamestring

The name of the middleware function.

routestring<optional>
null

The route the middleware is mounted on if one was found.

OperationSpecParams

Type:
  • object
Properties
NameTypeAttributesDescription
parametersDatastoreParameters | QueueMessageParameters | null<optional>
recordboolean<optional>

QueryFunction(shim, func, name, args) → {string}

Retrieves the query argument from an array of arguments.

Parameters:
NameTypeDescription
shimShim

The shim this function was passed to.

funcfunction

The function being recorded.

namestring

The name of the function.

argsArray.<*>

The arguments being passed into the function.

Returns:

The query string from the arguments list.

Type: 
string

QueryParserFunction(query) → {ParsedQueryData}

Used to parse queries to extract the basic information about it.

Parameters:
NameTypeDescription
querystring

The query to be parsed.

Returns:

An object containing the basic information about the query.

Type: 
ParsedQueryData

QuerySpecFunction(shim, func, name, args) → {QuerySpec}

Used for determining information about a query when it can not be simply found in the arguments.

Parameters:
NameTypeDescription
shimShim

The shim this function was passed to.

funcfunction

The function being recorded.

namestring

The name of the function.

argsArray.<*>

The arguments being passed into the function.

Returns:

The spec for how this query should be recorded.

Type: 
QuerySpec

QuerySpecParams

Type:
  • object
Properties
NameTypeAttributesDescription
querynumber | string | QueryFunction<optional>

QueueMessageParametersParams

Type:
  • object
Properties
NameTypeAttributesDescription
correlation_idstring<optional>
reply_tostring<optional>
routing_keystring<optional>

RecorderFunction(shim, func, name, args) → {string|RecorderSpec}

A function which is called to compose a segment for recording.

Parameters:
NameTypeDescription
shimShim

The shim this function was passed to.

funcfunction

The function being recorded.

namestring

The name of the function.

argsArray.<*>

The arguments being passed into the function.

Returns:

The desired properties for the new segment.

Type: 
string | RecorderSpec

RecorderSpecParams

Type:
  • object
Properties
NameTypeAttributesDescription
afterSpecAfterFunction<optional>
callbacknumber | CallbackBindFunction<optional>
callbackRequiredboolean<optional>
promiseboolean<optional>
rowCallbacknumber | CallbackBindFunction<optional>
streamboolean | string<optional>

RenderSpecParams

Type:
  • object
Properties
NameTypeAttributesDescription
viewnumber<optional>

RouteNextFunction(shim, fn, fnName, args) → {object}

Used to wrap functions that users can call to continue to the next middleware.

Parameters:
NameTypeDescription
shimWebFrameworkShim

The shim used for instrumentation.

fnfunction

The middleware function.

fnNamestring

The name of the middleware function.

argsArray

The arguments to the middleware function.

Returns:

The request object.

Type: 
object

RouteParameterFunction(shim, fn, fnName, args) → {object}

Extracts the route parameters from the arguments to the middleware function.

Parameters:
NameTypeDescription
shimWebFrameworkShim

The shim used for instrumentation.

fnfunction

The middleware function.

fnNamestring

The name of the middleware function.

argsArray

The arguments to the middleware function.

Returns:

A map of route parameter names to values.

Type: 
object

RouteParserFunction(shim, fn, fnName, route) → {string|RegExp}

Called whenever new middleware are mounted using the instrumented framework, this method should pull out a representation of the mounted path.

Parameters:
NameTypeDescription
shimWebFrameworkShim

The shim in use for this instrumentation.

fnfunction

The function which received this route string/RegExp.

fnNamestring

The name of the function to which this route was given.

routestring | RegExp

The route that was given to the function.

Returns:

The mount point from the given route.

Type: 
string | RegExp

RouteRequestFunction(shim, fn, fnName, args) → {object}

Extracts the request object from the arguments to the middleware function.

Parameters:
NameTypeDescription
shimWebFrameworkShim

The shim used for instrumentation.

fnfunction

The middleware function.

fnNamestring

The name of the middleware function.

argsArray

The arguments to the middleware function.

Returns:

The request object.

Type: 
object

SegmentFunction(shim, func, name, args) → {string|SegmentSpec}

A function which is called to compose a segment.

Parameters:
NameTypeDescription
shimShim

The shim this function was passed to.

funcfunction

The function the segment is created for.

namestring

The name of the function.

argsArray.<*>

The arguments being passed into the function.

Returns:

The desired properties for the new segment.

Type: 
string | SegmentSpec

SegmentSpecParams

Type:
  • object
Properties
NameTypeAttributesDescription
inContextInContextCallback<optional>
internalboolean<optional>
namestring<optional>
opaqueboolean<optional>
parametersObject.<string, *><optional>
parentTraceSegment<optional>
recorderMetricFunction<optional>

SpecAfterFunction(params)

A callback invoked after an instrumented function has completed its work. The instrumented function must have been invoked synchronously.

Parameters:
NameTypeDescription
paramsObject

params to function

Properties
NameTypeAttributesDescription
shimobject

The shim used to instrument the external library.

fnfunction

The function/method from the external library being instrumented.

namestring

The name of the current function.

errorError | null<optional>

If the instrumented function threw an error, this will be that error. In the case of a callback this will be omitted.

argsArray<optional>

arguments passed to a callback function getting instrumented.

result*<optional>

The result returned by the instrumented function. In the case of a wrapped callback, the data needed is in params.args.

segmentTraceSegment

The segment used while instrumenting the function.

TransactionSpecParams

Type:
  • object
Properties
NameTypeAttributesDescription
nestboolean<optional>
typestring<optional>

WrapFunction(shim, original, name) → {*}

A function which performs the actual wrapping logic.

If the return value of this function is not original then the return value will be marked as a wrapper.

Parameters:
NameTypeDescription
shimShim

The shim this function was passed to.

originalobject | function

The item which needs wrapping. Most of the time this will be a function.

namestring

The name of original if it can be determined, otherwise '<anonymous>'.

Returns:

The wrapper for the original, or the original value itself.

Type: 
*

WrapSpecParams

Type:
  • object
Properties
NameTypeAttributesDescription
matchArityboolean<optional>
wrapperfunction<optional>

startSegmentCallback(cb) → {Promise}

Parameters:
NameTypeDescription
cbfunction

The function to time with the created segment.

Returns:

Returns a promise if cb returns a promise.

Type: 
Promise