Transaction API

edit

A transaction groups multiple spans in a logical group.

To get a Transaction object, you need to call apm.startTransaction().

To see an example of using custom transactions, see the Custom Transactions in Node.js article.

transaction.name

edit
  • Type: String
  • Default: unnamed

The name of the transaction.

Can be used to set or overwrite the name of the transaction (visible in the performance monitoring breakdown). If you don’t have access to the current transaction, you can also set the name using apm.setTransactionName().

Transactions with the same name and type are grouped together.

transaction.type

edit
  • Type: String
  • Default: custom

The type of the transaction.

There’s a special type called request which is used by the agent for the transactions automatically created when an incoming HTTP request is detected.

transaction.result

edit
  • Type: Number
  • Default: 200

The transaction result.

Think of the transaction result as equivalent to the status code of an HTTP response.

transaction.end([result])

edit
transaction.end([result])

Ends the transaction and truncates all un-ended child spans. If the transaction has already ended, nothing happens.

Alternatively you can call apm.endTransaction() to end the active transaction.

A value may be provided to set as a result.