Skip to content

Commit

Permalink
Merge pull request #9 from Vinelab/config
Browse files Browse the repository at this point in the history
Allow to configure error tagging behavior
  • Loading branch information
adiachenko authored Oct 24, 2019
2 parents 3a714c2 + e2b360b commit e0bdcec
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
13 changes: 13 additions & 0 deletions config/tracing.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@
],
],

/*
|--------------------------------------------------------------------------
| Errors
|--------------------------------------------------------------------------
|
| Whether you want to automatically tag span with error=true
| to denote the operation represented by the Span has failed
| when error message was logged
|
*/

'errors' => true,

/*
|--------------------------------------------------------------------------
| Zipkin
Expand Down
4 changes: 4 additions & 0 deletions src/Listeners/TraceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ protected function shouldTraceCommand(string $command): bool
/** @var Command $command */
$command = Arr::get($this->artisan->all(), $command);

if (!$command) {
return false;
}

$interfaces = class_implements($command);

return isset($interfaces[ShouldBeTraced::class]);
Expand Down
12 changes: 7 additions & 5 deletions src/TracingServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ public function boot()

$this->app['events']->listen(CommandStarting::class, TraceCommand::class);

$this->app['events']->listen(MessageLogged::class, function (MessageLogged $event) {
if ($event->level == 'error') {
optional(Trace::getRootSpan())->tag('error', 'true');
}
});
if ($this->app['config']['tracing.errors']) {
$this->app['events']->listen(MessageLogged::class, function (MessageLogged $event) {
if ($event->level == 'error') {
optional(Trace::getRootSpan())->tag('error', 'true');
}
});
}

$this->app->terminating(function () {
optional(Trace::getRootSpan())->finish();
Expand Down

0 comments on commit e0bdcec

Please sign in to comment.