Skip to content

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

Merged
merged 5 commits into from
Mar 5, 2019
Merged

Conversation

Jean85
Copy link
Contributor

@Jean85 Jean85 commented Feb 26, 2019

This should resolve #186. I preferred to approach this with a separate listener, which seems a much cleaner solution.

@Jean85 Jean85 added this to the 3.0 (Sentry client 2.0) milestone Feb 26, 2019
@Jean85 Jean85 self-assigned this Feb 26, 2019
@Jean85 Jean85 requested a review from stayallive February 26, 2019 16:46
@Jean85
Copy link
Contributor Author

Jean85 commented Feb 26, 2019

I would like a review from @ste93cry too.

return;
}

Hub::getCurrent()->pushScope();
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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,

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor

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

@mcfedr
Copy link
Contributor

mcfedr commented Feb 27, 2019

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.

@Jean85
Copy link
Contributor Author

Jean85 commented Feb 27, 2019

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.

@mcfedr
Copy link
Contributor

mcfedr commented Feb 27, 2019

You make good points, I take back my comments :)

Copy link
Collaborator

@stayallive stayallive left a 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 👍

Copy link
Member

@HazAT HazAT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look goooood 👌

@Jean85 Jean85 merged commit aa0182c into master Mar 5, 2019
@Jean85 Jean85 deleted the track-subrequests-with-scopes branch March 5, 2019 20:18
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.

Use Scope to track subrequests info correctly
5 participants