-
Notifications
You must be signed in to change notification settings - Fork 373
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
[rails] Rails action_controller is part of the rack request #112
Conversation
b8886da
to
86bb860
Compare
1f1b560
to
be958e5
Compare
ea0d4c0
to
ba6686b
Compare
…are span; now it is not the root request
Even though Integration tests are said to be 25% slower, they run through Rake's middleware stack, which we might leverage in order to improve the error capturing capabilities.
ActiveSupport's instrumentation doesn't provide a lot of information about an error that might have been raised, so introducing a piece of middleware seems to be the best way of getting full control. Other similar gems also adopt this approach.
…re_stack and configures the Rack middleware
This reverts commit 751267346472001cc9beb310e4b0b9c3ffa49e8a.
… only if the parent is available
be958e5
to
cb18a45
Compare
@@ -58,8 +58,9 @@ of the Datadog tracer, you can override the following defaults: | |||
auto_instrument: false, | |||
auto_instrument_redis: false, | |||
default_service: 'rails-app', | |||
default_database_service: 'postgresql', | |||
default_controller_service: 'rails-controller', |
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.
👍
raise e | ||
ensure | ||
# we must close all active spans and set span fields if not already set | ||
request_span.finish() |
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.
Don't we have a risk to flush/write this before the tags are set? I mean, today's code path might not make this possible, but generally speaking, I tend to think .finish()
should be the last call.
@@ -21,12 +21,9 @@ class TracingControllerTest < ActionController::TestCase | |||
assert_equal(spans.length, 2) | |||
|
|||
span = spans[1] | |||
assert_equal(span.name, 'rails.request') | |||
assert_equal(span.name, 'rails.action_controller') | |||
assert_equal(span.span_type, 'http') | |||
assert_equal(span.resource, 'TracingController#index') |
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.
So, as I understand it, all this http metadata has been bounced to rack, which is actually handling the protocol and should carry the now missing info in its spans, right?
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, all http-related tags are handled in the Rack middleware. I think this is the right approach, especially because a middleware can still change the status_code
when the middleware stack is executed "backward" (in the sense of code after the @app.call()
).
@@ -84,9 +85,10 @@ Available settings are: | |||
* ``auto_instrument_redis``: if set to ``true`` Redis calls will be traced as such. Calls to Redis cache may be | |||
still instrumented but you will not have the detail of low-level Redis calls. | |||
* ``default_service``: set the service name used when tracing application requests. Defaults to ``rails-app`` | |||
* ``default_controller_service``: set the service name used when tracing a Rails action controller. Defaults to ``rails-controller`` |
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 might need to refer to this in the ChangeLog/release note BTW.
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, that's part of our "breaking change", that basically doesn't break anything, but changes the previous behavior adding this layer in the middle
cb18a45
to
33f79a5
Compare
What it does
Major change about how Rails applications are traced. Now the Rack
TraceMiddleware
is used and so an high overview of the whole request is available. Changes include:TraceMiddleware
is added at initialization time, before the middleware stack is builtrails.request
now becomesrails.action_controller
and is not the root span anymoreTraceMiddleware
is used,rack.request
is the root span for all traces and it includes all http-related tagsrails.request
is now part of therails-controller
service (it's user configurable)process_action.action_controller()
changes therack.request
resource so that it has a meaningful namerack.request
keeps the default resource name likeGET 200
orGET 404