Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addBreadcrumb data is getting lost #645

Open
GlauberF opened this issue Feb 3, 2023 · 3 comments
Open

addBreadcrumb data is getting lost #645

GlauberF opened this issue Feb 3, 2023 · 3 comments

Comments

@GlauberF
Copy link

GlauberF commented Feb 3, 2023

Environment

Laravel 9
Php 8.0
sentry-laravel ^2.13

Expected Result

I created a helper function to send a log message and add some Breadcrumbs before that message.

I'm adding according to an array of information, but sometimes some of the data doesn't match what was informed.
since I debugged and the correct information is going, but after checking online, the information does not match.

My Function

class SentryLog {
    /**
     * @param string $message A mensagem de log.
     * @param array|null $context (opcional): O contexto adicional para incluir na mensagem de log.
     * @param string $level (opcional): O nível de log (info, warning, error, etc.).
     */
    public static function send(string $message, ?array $context = [], string $level = 'info', bool $addContextToBreadcrumb = true) {

        $context = array_merge([
            'Horário local' => \Illuminate\Support\Carbon::now()->format(\App\Enums\Timezone\TimezoneTzEnum::W3C)
        ], $context);

        if($context && $addContextToBreadcrumb) {
            \Sentry\configureScope(function (\Sentry\State\Scope $scope) use ($context) {
                foreach ($context as $key => $value) {
                    $scope->addBreadcrumb(new \Sentry\Breadcrumb(
                        \Sentry\Breadcrumb::LEVEL_INFO,
                        \Sentry\Breadcrumb::TYPE_DEFAULT,
                        gettype($key) != 'string' ? json_encode($key) : $key,
                        gettype($value) != 'string' ? json_encode($value) : $value
                    ));
                }
            });
        }

        Log::channel('sentry')->$level("AUDIT LOG | {$message}", !$addContextToBreadcrumb ? ['extra' => $context] : []);
    }
}

Call Funtion

SentryLog::send("message here", [
      'data' => "any", // is going correctly
      'Método' => "lancamento", // it's going wrong
      'Status da nota' => $this->NotasEntrada['sne_status'], // is going correctly
]);

Actual Result

Captura de Tela_selecionar área_20230203170842

@cleptric
Copy link
Member

cleptric commented Feb 6, 2023

Thanks for reporting this.

You mentioned that you already checked what the SDK sends to Sentry and that it happens to look correct. Could you include the full event from the PayloadSeralizer in this issue as well (remove the DSN and other Pii/sensitive data)? Looking at your code, I can't spot an obvious issue, so this might indeed be a problem on the product instead.

I also wanted to point out that we released a new major version of the Laravel SDK a while ago. This won't fix your issue, but I encourage you to upgrade to v3.2.0 as v2.x won't receive any more updates.

@GlauberF
Copy link
Author

GlauberF commented Feb 6, 2023

@cleptric
I think I expressed myself poorly.
I analyzed the payload that I send to the SDK and it's right.
which is what I'm passing in SentryLog::send but it doesn't match what arrives on the online sentry platform, it seems that it gets lost in the scope and takes some information that is being captured by the sentry itself at that moment.
because if you look at Método, it should have taken lancamento but it was a query that if I don't send launch it goes into the sql.query category

@cleptric
Copy link
Member

cleptric commented Feb 6, 2023

Ok, this makes more sense. I'll take a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants