At the beginning of every APM trace a transaction must be started. There are three types of supported transactions:
request for tracing HTTP requestsjob for tracing background jobscustom for all other tracesThe Laravel integration automatically starts the transaction and sets its type to request by default. In a future release the job type will be set and started for queue jobs, cron jobs, etc. automatically as well.
By default the type is set to request and the name is a representation of METHOD + ROUTE. You may manually adjust the transaction type and name at any point.
use Tail\Apm\Transaction;
app('tail')->transaction()->setType(Transaction::TYPE_JOB);
app('tail')->transaction()->setName('some-job');The start time of a transaction is set to when the transaction is created by default. Similarly the end time is set to the time a transaction is finished and sent.
To set a custom start/end time
// Time should be a unix timestamp in milliseconds
$time = microtime(true) * 1000;
app('tail')->transaction()->setStartTime($time);
app('tail')->transaction()->setEndTime($time);To customize the environment tag on a transaction
app('tail')->transaction()->service()->setEnvironment('production');HTTP metadata is collected by default from the $_SERVER superglobal and Laravel's router, but can be customized as needed
app('tail')->transaction()->http()
->setMethod('PUT')
->setUrl('/some/path/:id')
->setUrlParams(['id' => 22])
->setHeaders(['x-forwarded-for' => 'example.com']);To customize the hostname for a transaction
app('tail')->transaction()->system()->setHostname('host-123');User information can be attached to a transaction when known
app('tail')->transaction()->user()->setId(24);
app('tail')->transaction()->user()->setEmail('user@example.com');Any key/value pair can be set to pass custom metadata for a transaction
app('tail')->transaction()->tags()
->set('version', '2.4')
->set('variation', 'b');