MessageSubscribeSpec

Spec to describe instrumenting a message broker consumer entity, i.e. the thing that reads and processes messages from a message broker.

Constructor

new MessageSubscribeSpec(params)

Parameters:
NameTypeDescription
paramsMessageSubscribeSpecParams

Members

consumer :number|null

Indicates the position in the instrumented consumer function's arguments list that represents the thing that will handle messages.

Type:
  • number | null

functions :Array.<string>|null

Indicates names of functions to be wrapped for message consumption. This must be used in tandem with consumer.

Type:
  • Array.<string> | null
Example
// Wrap the eachMessage method on a consumer
class Consumer() {
 constructor() {}
 async run(consumer) {
   consumer.eachMessage({ message })
 }
}

const spec = new MessageSubscribeSpec({
 name: 'Consumer#run'
 promise: true
 consumer: shim.FIRST,
 functions: ['eachMessage']
})

shim.recordSubscribedConsume(Consumer.prototype, 'run', spec)