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

[tracer:stacktrace] fix error stack traces #170

Merged
merged 6 commits into from
Aug 8, 2017
Merged

Conversation

ufoot
Copy link
Contributor

@ufoot ufoot commented Aug 8, 2017

Rails instrumentation does not report correct stack traces (see #110 which also referred to this point). This patch introduces a new way to populate this stack trace (heavily inspired by @Ferdy89 work), not relying on caller any more which, indeed, is not want we want.

@ufoot ufoot added the bug Involves a bug label Aug 8, 2017
@ufoot ufoot added this to the 0.8.1 milestone Aug 8, 2017
@ufoot ufoot requested a review from palazzem August 8, 2017 08:58
lib/ddtrace.rb Outdated

module Datadog
# Railtie class initializes
class Railtie < Rails::Railtie
config.app_middleware.use(Datadog::Contrib::Rails::TraceMiddleware)
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Ouch saw that it's Rails and not Rack. Can we call it ExceptionMiddleware or similar if it's handling only exceptions?

@@ -128,10 +129,6 @@ def call(env)
# unless it has been already set by the underlying framework
if status.to_s.start_with?('5') && request_span.status.zero?
request_span.status = 1
# in any case we don't touch the stacktrace if it has been set
Copy link
Contributor

Choose a reason for hiding this comment

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

so this one sets wrong stack traces and removing it means writing this one for each framework built on top of Rack, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, the code below has been removed because it was only a fallback "in case we don't have the exception" trying to fill the stack trace with something. It appears it was a bad idea, it confuses users, as the stack trace is only about... our code, which provides no insight for users to spot where the problem actually was. If the error was catched by another layer, we just do not have the information any more, period, so rather than report misleading info, report nothing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Totally agree. Let's remove it!

# and it is user code which should be executed no matter what.
# It's not a problem since we re-raise it afterwards so for example a
# SignalException::Interrupt would still bubble up.
rescue Exception => e
Copy link
Contributor

Choose a reason for hiding this comment

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

Till we re-raise e, I'm ok with using Exception. Also yes, this is the right thing to do at this point.

Copy link
Contributor

@palazzem palazzem left a comment

Choose a reason for hiding this comment

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

Looks good to me!

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

Successfully merging this pull request may close these issues.

2 participants