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

Send context data passed to LoggerInterface to Sentry #96

Closed
t-heuser opened this issue Jun 16, 2022 · 0 comments · Fixed by #97
Closed

Send context data passed to LoggerInterface to Sentry #96

t-heuser opened this issue Jun 16, 2022 · 0 comments · Fixed by #97

Comments

@t-heuser
Copy link
Contributor

Do you want to request a feature or report a bug?

Feature request

Feature: What is your use case for such a feature?

I want to be able to send context data to Sentry, concrete I want the data passed to $context in all the functions from the Psr\LoggerInterface to be shown in Sentry.
That is useful so that I can send additional context, for example product information, to Sentry when an error occured.

At the moment I can only add custom_tags as seen here:

if (true === isset($context['custom_tags']) && false === empty($context['custom_tags'])) {

Feature: What is your proposed configuration entry? The new option to add? What is the behavior?

No extra configuration would be needed, it would be a simple function call which must be added here:

\Sentry\configureScope(
function (SentryScope $scope) use ($customTags): void {
$this->setTags($scope, $customTags);
$this->setUser($scope);
}
);

The function setContext() from $scope must be called as seen in the Sentry documentation: https://docs.sentry.io/platforms/php/enriching-events/context/

This would be a very useful feature for us as we need to enrich errors even further (especially when error are occuring in cronjobs and we don't have any url, etc.). At the moment the data passed to $context from the LoggerInterface is only written to the log and never send to Sentry.

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 a pull request may close this issue.

1 participant