-
Notifications
You must be signed in to change notification settings - Fork 375
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
Add exception_controller option to Rails #320
Conversation
e3896e0
to
bc97825
Compare
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.
@delner can you also update the documentation here? https://github.com/DataDog/dd-trace-rb/blob/bc978254a6c6e1e66b48d5ca64c236693f108fa9/docs/GettingStarted.md#ruby-on-rails
I would say to not give details about the false
case.
f8c856c
to
42d54e4
Compare
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.
one question and a nitpick, otherwise it looks good to me!
controller <= exception_controller_class | ||
# Else if no exception controller class has been set, | ||
# guess whether this is an exception controller from the headers. | ||
elsif exception_controller_class.nil? |
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's just "cosmetic", but this is the base case because most of developers don't set exception_controller
, so would be great having it as a first if
condition.
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.
Alright, I can rearrange this.
@@ -150,8 +150,13 @@ def process_action_with_datadog(*args) | |||
# signals; it propagates the request span so that it can be finished | |||
# no matter what | |||
payload = { | |||
controller: self.class.name, | |||
controller: self.class, |
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.
can you provide more details about this change?
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 was only passing a string of the class name before. We need the actual constant now, so we can actually do type checking.
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.
changing that doesn't have any side effect for the rest of the code, 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.
Nope, it was being used to tag the name on the span. Since "#{class}"
is the same thing as class.name
, it has no change.
42d54e4
to
c675606
Compare
Feedback addressed @palazzem ! |
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.
Good to me! thank you very much!
If a Rails app has a custom error controller defined via
config.exceptions_app=
for the purpose of rendering errors, the name of this custom error controller and action will supersede the name of the controller that originally raised the exception for the trace. This is because the errors controller runs afterwards, and replaces the name on the parent span, no matter what. Ultimately, it results in all error traces being listed under "ErrorsController#internal_server_error" or similarly named resource, which isn't a great experience.This pull request introduces the
exception_class
option to Rails configuration, which allows a user to specify a class or module to identify a custom exception controller with. Spans for any controller that matches this definition will not override the parent span's resource name.If you do not specify this option, the tracer will "guess" if the controller is an error controller, by looking for the presence and value of an
action_dispatch.exception
header, which is typically provided to error controllers in Rails. Most users should see improved behavior without any additional configuration.In practice:
OR
And a resulting trace with improved resource name: