Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Collectors/CommandCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Illuminate\Console\Events\CommandStarting;
use Illuminate\Support\Facades\Log;
use Nipwaayoni\Events\Transaction;
use Throwable;

/**
* Collects info about ran commands.
Expand Down Expand Up @@ -75,7 +74,7 @@ protected function send($event): void
$this->agent->send();
} catch (ClientException $exception) {
Log::error($exception, ['api_response' => (string) $exception->getResponse()->getBody()]);
} catch (Throwable $t) {
} catch (\Throwable $t) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looked better before -- is this why the linter complained? Very, very weird.

Copy link
Owner Author

@arkaitzgarro arkaitzgarro Nov 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we were a few versions behind and looks like they changed the default a couple of weeks ago.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They didn't much of an explanation after I followed the thread to this comment. Must be a Symfony thing.

Log::error($t->getMessage());
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Collectors/DBQueryCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace AG\ElasticApmLaravel\Collectors;

use AG\ElasticApmLaravel\Contracts\DataCollector;
use Exception;
use Illuminate\Database\Events\QueryExecuted;
use Jasny\DB\MySQL\QuerySplitter;

Expand Down Expand Up @@ -73,7 +72,7 @@ private function getQueryName(string $sql): string
}

return $fallback;
} catch (Exception $e) {
} catch (\Exception $e) {
return $fallback;
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Collectors/JobCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Illuminate\Queue\Jobs\SyncJob;
use Illuminate\Support\Facades\Log;
use Nipwaayoni\Events\Transaction;
use Throwable;

/**
* Collects info about the job process.
Expand Down Expand Up @@ -114,7 +113,7 @@ protected function send(Job $job): void
}
} catch (ClientException $exception) {
Log::error($exception, ['api_response' => (string) $exception->getResponse()->getBody()]);
} catch (Throwable $t) {
} catch (\Throwable $t) {
Log::error($t->getMessage());
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/Collectors/ScheduledTaskCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
use Illuminate\Console\Events\ScheduledTaskFinished;
use Illuminate\Console\Events\ScheduledTaskSkipped;
use Illuminate\Console\Events\ScheduledTaskStarting;
use Illuminate\Console\Scheduling\CallbackEvent;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Log;
use Nipwaayoni\Events\Transaction;
use Throwable;

/**
* Collects info about scheduled tasks.
Expand Down Expand Up @@ -79,7 +79,7 @@ protected function send($event): void
$this->agent->send();
} catch (ClientException $exception) {
Log::error($exception, ['api_response' => (string) $exception->getResponse()->getBody()]);
} catch (Throwable $t) {
} catch (\Throwable $t) {
Log::error($t->getMessage());
}
}
Expand All @@ -91,7 +91,9 @@ protected function send($event): void
*/
protected function getTransactionName($event): string
{
$transaction_name = $event->task->command;
$transaction_name = $event->task instanceof CallbackEvent
? $event->task->getSummaryForDisplay()
: $event->task->command;

return $this->shouldIgnoreTransaction($transaction_name) ? '' : $transaction_name;
}
Expand Down
6 changes: 2 additions & 4 deletions src/Middleware/RecordTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@

use AG\ElasticApmLaravel\Agent;
use AG\ElasticApmLaravel\Collectors\RequestStartTime;
use Closure;
use Illuminate\Config\Repository as Config;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
use Illuminate\Support\Facades\Log;
use Nipwaayoni\Events\Transaction;
use Symfony\Component\HttpFoundation\Response;
use Throwable;

/**
* This middleware will record a transaction from the moment the request hits the server, until the response is sent to the client.
Expand Down Expand Up @@ -42,7 +40,7 @@ public function __construct(Agent $agent, Config $config, RequestStartTime $star
*
* @return mixed
*/
public function handle(Request $request, Closure $next)
public function handle(Request $request, \Closure $next)
{
$transaction_name = $this->getTransactionName($request);

Expand Down Expand Up @@ -99,7 +97,7 @@ public function terminate(Request $request): void
// Stop the transaction and measure the time
$this->agent->stopTransaction($transaction_name);
$this->agent->collectEvents($transaction_name);
} catch (Throwable $t) {
} catch (\Throwable $t) {
Log::error($t->getMessage());
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Services/ApmCollectorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Foundation\Application;
use Nipwaayoni\Events\Transaction;
use Throwable;

class ApmCollectorService
{
Expand Down Expand Up @@ -83,7 +82,7 @@ public function addCollector(string $collector_class): void
);
}

public function captureThrowable(Throwable $thrown, array $context = [], ?Transaction $parent = null)
public function captureThrowable(\Throwable $thrown, array $context = [], ?Transaction $parent = null)
{
if ($this->is_agent_disabled) {
return;
Expand Down