-
Notifications
You must be signed in to change notification settings - Fork 179
Track subrequests with scopes #198
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
Conversation
I would like a review from @ste93cry too. |
return; | ||
} | ||
|
||
Hub::getCurrent()->pushScope(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should you not be adding the scope variables, such as route, in the same way as is done in https://github.com/getsentry/sentry-symfony/blob/master/src/EventListener/RequestListener.php#L88
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may depend on what we want to report. The main route is still the one of the master request, and I'm still thinking about if we need to add more data in that scope, or override the previous information.
IMHO, the subrequest info shouldn't override, but I'm not sure if it's in this bundle's scope to add that, or if I should leave it to the end user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I see what you mean, you still want to see the actual request,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. You'll still free to add tags, extra context or whatever to the scope, and if you do it inside the subrequest, it will be popped out and reverted at the end of it.
Does it make sense to you? Do you think it's a good approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, though like you say, would be nice to automatically add something about the subrequest, like $scope->setTag('route', $matchedRoute);
is done for master, maybe just with sub_request_route
or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, for example at work we use subrequests and we add some information to the extra
context such as:
current_request_url
current_request_method
master_request_url
master_request_method
is_master_request
This way we know if an event got generated from a request or a sub request
If you remove the checks for master request in the main RequestListener, haven't you achieved the same thing? without adding another listener into the system that has to be called for every request. |
The performance impact of a listener is negligible thanks to the compiled container, it's just a single method call. Also, removing that check would just override the info, and not revert it back when the subrequest is complete, so the reported info would be wrong. Popping and pushing scopes is a lot more efficient and useful in this respect. |
You make good points, I take back my comments :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For as far as I can judge this it looks good 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look goooood 👌
This should resolve #186. I preferred to approach this with a separate listener, which seems a much cleaner solution.