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

Inconsistent instrumentation semantics #1496

Open
jondot opened this issue Sep 21, 2016 · 7 comments
Open

Inconsistent instrumentation semantics #1496

jondot opened this issue Sep 21, 2016 · 7 comments
Labels

Comments

@jondot
Copy link

jondot commented Sep 21, 2016

Hi,

I'd like to point out, and ask, what's the expected behavior when an exception is thrown in a Grape endpoint, towards instrumentation (via AS:N).

When I want to instrument Grape, I subscribe to this notification:

https://github.com/ruby-grape/grape/blob/master/lib/grape/endpoint.rb#L238

What I'm experiencing right now is that endpoint.status is always 200 (as opposed to 500 or default_error), even when an exception was raised in that endpoint.

When an exception is raised, I guess this blows up:

https://github.com/ruby-grape/grape/blob/master/lib/grape/endpoint.rb#L264

But then what happens with the instrumentation block?

When explicitly stating an error inside an endpoint, it works (status code is 500).
In a rescue_all block, or while an endpoint throws it doesn't work (status code is either stale, wasn't set, and is just 200)

@dblock
Copy link
Member

dblock commented Sep 21, 2016

It looks like a bug, would appreciate a spec that reproduces this to start.

@dblock
Copy link
Member

dblock commented Sep 21, 2016

Turn it into a spec, try to fix it.

@jondot
Copy link
Author

jondot commented Sep 21, 2016

I spent some time trying that, but I don't see any existing specs for AS::N that I can learn from in order to build a test in the existing Grape infra, however, tests in vitals would fail.
I'd prefer deprecating Grape support until we can find out if this is even a good use of the Grape AS::N instrumentation feature (which is what I'm asking).
Should we even grab the status from endpoint at that stage?

@dblock
Copy link
Member

dblock commented Sep 22, 2016

@jondot Are you talking about deprecating grape support in vitals? I can't speak to that.

In Grape the error handler sets status, it lives "outside" of the endpoint itself. So the answer I guess is "it depends on how an exception is being handled"?

@dim
Copy link
Contributor

dim commented Mar 16, 2017

I would like to resurrect this issue.

@dblock I understand the reasoning, but shouldn't we then have and additional instrumentation middleware which sits outside of https://github.com/ruby-grape/grape/blob/3959a01f/lib/grape/endpoint.rb#L281. At the moment, there is absolutely no way to monitor the actual status returned by the server

dim added a commit to bsm/datadog-notifications that referenced this issue Mar 16, 2017
@dblock
Copy link
Member

dblock commented Mar 16, 2017

I suppose the answer to having a way to monitor the actual status returned by the server is yes. So I would take a PR for that.

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

No branches or pull requests

3 participants