Laavel에서 sentry:test 실행 시 "Plaease check if your DSN..."발생 시 조사 방법

6462 단어 LaravelSentrytech

개요


Laavel에 Sentry를 추가할 때 로컬 환경에서 동작을 확인할 수 있지만 AWS 환경에서 동작하지 않는 문제가 있습니다.
나는 디버깅처의 실례가 옛 실례이기 때문에 통상적으로 같은 원인으로 오류가 발생하지 않을 것이라고 생각한다sentry:test 출력의 오류는 이해하기 어려울 것 같아 조사 방법을 미리 적어 두었다.

컨디션


OS: Amazon Linux2 (amzn2-ami-hvm-2.0.20190618-x86_64.xfs.gpt)
Laravel: 5.8.38
sentry/sdk: 3.0.0

잘못된 내용


디버깅 후 동작을 확인하기 위해 php artisan sentry:test를 실행했지만 Please check if your DSN is set properly in your config ...의 오류가 발생하여 자세한 상황을 알 수 없습니다.
[ec2-user current]$ php artisan sentry:test
[Sentry] DSN discovered!
[Sentry] Generating test Event
[Sentry] Sending test Event
[Sentry] There was an error sending the test event.
[Sentry] Please check if your DSN is set properly in your config or `.env` as `SENTRY_LARAVEL_DSN`

조사 방법


참조Error "Please check if your DSN is set properly" when sending a test event on a self-hosted sentry instance는 AppServiceProvider에 다음 기술을 추가하여 추가 로그를 출력할 수 있습니다.
$this->app->extend(\Sentry\ClientBuilderInterface::class, function (\Sentry\ClientBuilderInterface $builder) {
    $builder->setLogger(new class extends \Psr\Log\AbstractLogger {
        public function log($level, $message, array $context = [])
        {
            error_log("[sentry-laravel] {$level}: {$message} | " . json_encode($context));
        }
    });

    return $builder;
});

이번 이유와 대처법


상기 상태를 추가한 후 다시 확인하면 로그에 다음과 같은 정보가 출력됩니다.
[sentry-laravel] error: Failed to send the event to Sentry. Reason: "SSL certificate problem: certificate has expired for "https://XXXXXXX.ingest.sentry.io/api/XXXXXXX/store/".".
OS의 루트 인증서가 만료된 것이 문제입니다.
이런 상황에서 처리 자체는 다음과 같은 부분에서 해결할 수 있다.
sudo yum update ca-certificates

결과를 확인하다


[ec2-user current]$ php artisan sentry:test
[Sentry] DSN discovered!
[Sentry] Generating test Event
[Sentry] Sending test Event
[Sentry] Transaction sent: XXXXXXXXXX
[Sentry] Event sent with ID: XXXXXXXXXXX

좋은 웹페이지 즐겨찾기