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

Add event processor that adds exception context to event #457

Merged
merged 1 commit into from
Mar 6, 2021

Conversation

stayallive
Copy link
Collaborator

@stayallive stayallive commented Mar 3, 2021

Since (very) recently Laravel added the implicit contract the the public context method on an exception class returns some extra context information that is added to the logs.

We like to also relay this information to Sentry.

Example (from the Laravel docs):

<?php

namespace App\Exceptions;

use Exception;

class InvalidOrderException extends Exception
{
    // ...

    /**
     * Get the exception's context information.
     *
     * @return array
     */
    public function context()
    {
        return ['order_id' => $this->orderId];
    }
}

https://laravel.com/docs/8.x/errors#exception-log-context

Laravel adds this information to the logs and Sentry adds this information to the exception_context key in the extra data.

This looks like this in the Sentry interface:

image

@olivernybroe
Copy link

Nice 👍 Simple and simple.

Is there any limits to the amount of nesting which can happen on the additional data that people have to be aware of?

@stayallive
Copy link
Collaborator Author

Yes, the default amount is 3 in the SDK and the Sentry server also enforces a limit on which it collapses or truncates the data (not sure what the exact limit is there).

But I would generally advice to keep this to a minimum and not add too much (nested) data if you can help it.

@stayallive stayallive merged commit 91a47ea into master Mar 6, 2021
@stayallive stayallive deleted the feature/read-context-from-exception branch March 6, 2021 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants