-
Notifications
You must be signed in to change notification settings - Fork 369
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
Fix bad resource name with Grape::API when used in Grape 1.2.0 #639
Conversation
Given that this is now potentially mounted multiple times, is this change sufficiently differentiating between the two different mounted endpoints? I think the correct fix would be getting the API name + some instance ID (because there may be multiple mounted instances). I commented ruby-grape/grape#1825 (comment) on whether this is needed in Grape proper. |
e379562
to
fd1724d
Compare
@dblock Yeah, maybe an instance ID would be useful. I'm not yet very familiar with the concept of mounted instances in Grape: how do different instances of the same API differ? Is it minor configuration or are there more substantial differences between instances of the same API? |
fd1724d
to
22444b7
Compare
Technically, before we mounted a static module, now we mount instances of an API. Logically you can define Note that there's a case where the path is the same, but the API switches by version. So |
22444b7
to
f82a29e
Compare
@dblock I see, yeah, that could be very significant. We'd probably want to factor in that full path (in your example) to differentiate between the different instances because those represent fundamentally different kinds of operations (e.g. calling between versions 1 and 2.) |
f82a29e
to
f8418f8
Compare
Grape released version 1.2.0 on 11/26/18 which broke our CI builds. In this new version, Grape deprecated the use of
Grape::API
directly.Applications that are still using
Grape::API
after 1.2.0 will not be able to see the class name of the API in their trace resource names. This is because these well-known types are coerced into anonymous classes as noted in this issue. Users who experience this, as a workaround, should upgrade their base class fromGrape::API
toGrape::API::Instance
as described here, e.g.To fix our CI build, we applied this change. To prevent misbehavior of tracing for users who neglect to undertake this upgrade, we hide the class name and tag, so as to avoid meaningless resource names like
#<Class:0xXXXXXX>#success
, in favor of#success
.UPDATE
Although the
Instance
object that's provided is an anonymous class, it turns out it is possible to resolve the name of the original class using thebase
method. I've updated the PR accordingly which means we now get the nice class name in resource for Grape 1.2.0 implementations that still useGrape::API
, giving us backwards compatibility.