如何在 Sentry 中 Cron 作业日志 laravel
How to Cron Job Logs in Sentry laravel
我需要使用 laravel
来 cron job log in sentry
调用哨兵日志方法:
$this->sentryCronJobLog([
'affected_rows'=> $affectedRows,
'status' => 'success'
]);
登录哨兵的方法:
public function sentryCronJobLog($data){
if (app()->bound('sentry')) {
\Sentry\configureScope(function (Scope $scope)use ($data): void {
$scope->setTag('status', $data['status']);
$scope->setTag('affected_rows', $data['affected_rows']);
$scope->setTag('time',\Carbon\Carbon::now()->format('Y-m-d h:i a'));
});
}
}
这样,我就无法创建登录哨兵性能了。
只需在 sentryCronJobLog() 函数中添加一行
$transactionContext = new \Sentry\Tracing\TransactionContext();
$transactionContext->setName('Cron job -'.$data['command_name']);
$transactionContext->setOp('command.run');
$transaction = \Sentry\startTransaction($transactionContext);
$transaction->finish();
对我有用
public function sentryCronJobLog($data){
if (app()->bound('sentry')) {
\Sentry\configureScope(function (Scope $scope)use ($data): void {
$scope->setTag('status', $data['status']);
$scope->setTag('affected_rows', $data['affected_rows']);
$scope->setTag('time',\Carbon\Carbon::now()->format('Y-m-d h:i a'));
$transactionContext = new \Sentry\Tracing\TransactionContext();
$transactionContext->setName('Cron job - .$data['command_name']);
$transactionContext->setOp('command.run');
$transaction = \Sentry\startTransaction($transactionContext);
$transaction->finish();
});
}
}
我需要使用 laravel
来 cron job log in sentry调用哨兵日志方法:
$this->sentryCronJobLog([
'affected_rows'=> $affectedRows,
'status' => 'success'
]);
登录哨兵的方法:
public function sentryCronJobLog($data){
if (app()->bound('sentry')) {
\Sentry\configureScope(function (Scope $scope)use ($data): void {
$scope->setTag('status', $data['status']);
$scope->setTag('affected_rows', $data['affected_rows']);
$scope->setTag('time',\Carbon\Carbon::now()->format('Y-m-d h:i a'));
});
}
}
这样,我就无法创建登录哨兵性能了。
只需在 sentryCronJobLog() 函数中添加一行
$transactionContext = new \Sentry\Tracing\TransactionContext();
$transactionContext->setName('Cron job -'.$data['command_name']);
$transactionContext->setOp('command.run');
$transaction = \Sentry\startTransaction($transactionContext);
$transaction->finish();
对我有用
public function sentryCronJobLog($data){
if (app()->bound('sentry')) {
\Sentry\configureScope(function (Scope $scope)use ($data): void {
$scope->setTag('status', $data['status']);
$scope->setTag('affected_rows', $data['affected_rows']);
$scope->setTag('time',\Carbon\Carbon::now()->format('Y-m-d h:i a'));
$transactionContext = new \Sentry\Tracing\TransactionContext();
$transactionContext->setName('Cron job - .$data['command_name']);
$transactionContext->setOp('command.run');
$transaction = \Sentry\startTransaction($transactionContext);
$transaction->finish();
});
}
}