Documentation is still in progress and subject to change.

Laravel Spans

Transactions may optionally contain spans, which measure an individual operation within a transaction process.

Contents

Usage

$span = app('tail')->newSpan('fetch-config');
// ...
// ...
$span->finish();

Child spans

Spans may also have child spans of their own

$span = app('tail')->newSpan('fetch-config');
// ...
$childSpan = $span->newChildSpan('process-config`');
// ...
$childSpan->finish();
// ...
$span->finish();

Timing

Similar to transactions, a spans start time is set to when it is created by default, but may be adjusted.

// start time for span set to when newSpan is called
$span = app('tail')->newSpan('fetch-config');

// custom start time, set as unix timestamp in milliseconds
$time = microtime(true) * 1000;
$span->setStartTime($time);

If a span never calls finish on it's own, the end time will be set when the parent transaction is finished. Otherwise a span may call finish or setEndTime which will not be overwritten when the parent transaction is finished.

Metadata

Database

Spans can be marked as "database" calls with specific meta properties

$span = app('tail')->newSpan('fetch-config');
$span->database()
    ->isReadOperation() // or isWriteOperation()
    ->setName('mysql-01')
    ->setQuery('SELECT * FROM config');

Custom metadata

Any key/value pair may be set to pass custom metadata for spans

$span = app('tail')->newSpan('fetch-config');
$span->tags()->set('type', 'json');

© 2020 tail.dev