rollbar-gem icon indicating copy to clipboard operation
rollbar-gem copied to clipboard

Stack trace not displayed when calling Rollbar.error("message")

Open santi-h opened this issue 8 years ago • 20 comments

Doing

Rollbar.error("TLE PDF Attachment => [ERR] Failed to create claim: #{claim.errors.messages}")

produces an item like this: screen shot 2017-02-11 at 11 08 46 pm

Seeing an item like this without a stacktrace gives us many difficulties:

  • I have to search throughout our entire code base for strings like "TLE PDF Attachment => [ERR] Failed to create claim" to see exactly where this is getting raised. This makes it difficult to find it sometimes because we might have similar messages in different places.

  • Some words might be dynamically added. For example, in this case, "{:provider=>["can't be blank"]}" is computed at error time, so we can't search for that in our code.

  • Sometimes it's not easy to recognize what parts of the message were computed dynamically and what parts weren't.

  • If "PDF" was dynamically added, then finding the string would've been a pain, because we'd search for "TLE PDF Attachment" and of course we wouldn't get any results.

To get around this problem we had to create this gem, but I was wondering if there's any support for this already that we're not aware of?

Thanks in advance!

santi-h avatar Feb 12 '17 05:02 santi-h

Hi @santi-h, thanks for opening this issue.

We have a configuration option config.populate_empty_backtraces that popualtes the backtrace for not rescued exception, ex: Rollbar.error(Exception.new(message)). I know this is not the same, but is something. The code for this is https://github.com/rollbar/rollbar-gem/blob/master/lib/rollbar/item/backtrace.rb#L92-L99.

The logic you have in your gem could reside in https://github.com/rollbar/rollbar-gem/blob/master/lib/rollbar/item.rb#L187-L193. We'll think on this and reach you on this issue when we have a conclusion about what to do.

Thanks!

jondeandres avatar Feb 12 '17 05:02 jondeandres

I think the solution here is that we should have an option to include backtraces with messages which is off by default. The implementation being what is in this gem. It is a common enough request.

rokob avatar Nov 14 '17 06:11 rokob

@rokob do you think it has sense to use the same option we have now and just populate backtraces also reporting messages without exception?

jondeandres avatar Nov 14 '17 11:11 jondeandres

@jondeandres if I understand correctly, you're suggesting to add logic behind populate_empty_backtraces to also populate backtraces for messages. So it's the same thing @rokob suggested just put in the already existing populate_empty_backtraces option? Is that correct?

ArturMoczulski avatar Nov 16 '17 00:11 ArturMoczulski

Yeah that's what I understood and I agree, we might as well just have one option.

rokob avatar Nov 16 '17 00:11 rokob

@ArturMoczulski that's correct, yes, let's use the same option, imho

jondeandres avatar Nov 16 '17 00:11 jondeandres

Hi there, I’m closing out all issues opened before 2018 that haven’t had any activity on them since the start of this year. If this is still an issue for you, please comment here and we can reopen this. Thanks!

rivkahstandig3636 avatar May 23 '18 11:05 rivkahstandig3636

Hi @rivkahstandig3636, is there any way to display the stacktrace of a Rollbar.error(msg) call that we're not aware of? If not then this is still an issue for us

santi-h avatar May 23 '18 14:05 santi-h

I am using Rollbar and have the same problem. I can: A - send logs when app crashes manually and attach custom data which is super helpful B - trust that you will report crash correctly and provide stacktrace but there is no additional data it's iOS client so symbolication is an issue, I can't just dump stack trace into txt myself.

So question is: 1 - can I ask for stacktrace to be added to message (and translated to human readable thing) 2 - can I inject some additional data to your crash report

adaslesniak avatar May 30 '18 07:05 adaslesniak

Also bumped into this. For now, I'm using something similar to this as a workaround

err = RuntimeError.new(msg)
err.set_backtrace(caller)
Rollbar.error(err, :log_extra => some_extra_data)

(the extra stuff isn't immediately visible on Rollbar, but you can see it if you click on the occurrence)

gingerlime avatar Oct 26 '18 09:10 gingerlime

@ArturMoczulski @rokob @jondeandres this seemed like a great idea. Any idea why there hasn't been more movement on this? Messages can end up being almost useless without this info and it would be great to just always have a stack trace. This is actually what I thought this option would have done by default.

gerrywastaken avatar Jan 13 '19 23:01 gerrywastaken

The thing stopping the easiest implementation is that the API spec does not allow both a trace and a message as part of the body of the item payload. So If you wanted the item to be a message, i.e. have data.body.message with information, then you can't also have data.body.trace which is where we would put the stacktrace. So we have two options that I see:

  1. Convert a message to a trace if populate_empty_backtraces is true, this would be equivalent to transforming Rollbar.error(your_message) to Rollbar.error(Exception.new(your_message))
  2. If you have a message and populate_empty_backtraces is true, then put a stacktrace somewhere else in the payload, probably in extra or custom.

(1) Seems to be the closest to what people here are looking for as you would see the stacktrace in the UI properly, the message would still end up getting indexed as the title. But it would mean you no longer have the slim message type payloads.

(2) This would be more idiomatic to the API spec as a message is not an exception and the stacktrace for where the message originated is extra data associated to the message. The downside is that the stacktrace would not get surfaced the same was as exceptions in the UI so the usability of this option is not great.

Building a stacktrace is not free both computationally as well as in payload size. So including a stacktrace with all messages is not done to allow messages to have this lighter weight. I think we can do what I describe in (1) above via the configuration option which is false by default.

rokob avatar Jan 14 '19 00:01 rokob

What do you think about (1) with option to disable/enable backtrace?

# when populate_empty_backtraces = true
Rollbar.error('msg', backtrace: false)
# when populate_empty_backtraces = false
Rollbar.error('msg', backtrace: true)

Also Rollbar.error(Exception.new('test')) appears in Rollbar as Exception: test. It would be great if message appeared without extra prefixes.

printercu avatar Mar 05 '19 12:03 printercu

Is this ever going to be fixed?

ciriousjoker avatar Jan 11 '20 14:01 ciriousjoker

The blocking issue on this is that the Rollbar API doesn't yet support it. If a trace is sent with a message payload it will either be ignored or rejected as invalid.

waltjones avatar Jan 14 '20 02:01 waltjones

+1 for this feature! For now we're getting around it by just passing a backtrace as an extra parameter in the rollbar call:

msg = "Uh oh something bad happened"
Rollbar.error(msg: msg, backtrace: caller)

But it would be awesome if we could take advantage of the nice backtrace cleanup and display that rollbar provides for exceptions!

slohmeier-onemedical avatar Nov 19 '20 21:11 slohmeier-onemedical

Also very interested in this. Exception message seems to be passed around without any problem in Rollbar. So wouldn't the easiest workaround be just to create Rollbar::Message exception, then just don't display that sepcific exception in Rollbar UI?

swistak avatar Dec 23 '20 12:12 swistak

@swistak That is close to the best thing I know to recommend: Sending an exception report with level set to info (or really any level you want.) This has a message and a stack trace, and won't be treated as an error. For now, anyone could do this themselves by passing an exception object to Rollbar.info(). Using meaningful exception classes should be considered though, as they can be used by the grouping algorithm to improve grouping results. Likewise, ignoring the class on the dashboard side is probably possible, but is more than just not displaying it. It gets consumed in others ways as well.

Aside from any feedback about the SDK interface for this, would the above solution with the exception class displayed be acceptable for people on the dashboard side of the project?

waltjones avatar Dec 23 '20 14:12 waltjones

What do you think about (1) with option to disable/enable backtrace?

# when populate_empty_backtraces = true
Rollbar.error('msg', backtrace: false)
# when populate_empty_backtraces = false
Rollbar.error('msg', backtrace: true)

I would love to have an API like that @printercu

bellef avatar Mar 07 '22 15:03 bellef

This adds a stack trace in our env.

function sendErrorToRollbarManually(message) {
	const err = new Error(message);
	// window.Rollbar.error(message); 	// sends the message string only
	window.Rollbar.error(err); 		// sends the message string with a stack trace
}

spacecowgoesmoo avatar Aug 17 '22 23:08 spacecowgoesmoo