getsentry / sentry

Developer-first error tracking and performance monitoring
https://sentry.io
Other
39.12k stars 4.2k forks source link

[feature] optional (and perhaps by default) absolute paths in raw stack traces (ruby) #77320

Open alxwrk opened 2 months ago

alxwrk commented 2 months ago

Problem Statement

Currently paths in the "raw" stack trace shown in the portal look like this:

Mysql2::Error: Deadlock found when trying to get lock; try restarting transaction
  from mysql2/client.rb:131:in `_query'
  from mysql2/client.rb:131:in `block in query'
  from mysql2/client.rb:130:in `handle_interrupt'
  from mysql2/client.rb:130:in `query'
  from active_record/connection_adapters/abstract_mysql_adapter.rb:187:in `block (2 levels) in execute'
  from active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
  from active_support/concurrency/share_lock.rb:187:in `yield_shares'
  from active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
  from active_record/connection_adapters/abstract_mysql_adapter.rb:186:in `block in execute'
  from active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'

Far too much is stripped from the path, most notably the gem folder. Internal paths within a gem won't necessarily identify the gem and aren't necessarily unique across all gems. This makes it difficult to navigate these paths locally when investigating sentry reported exceptions.

Also these paths can't be considered "raw" since the actual original/raw paths in ruby exceptions are absolute.

Solution Brainstorm

Since you already collect absolute paths and they are definitely useful for precisely identifying and navigating the file in the frame, there should be an option to show absolute paths in the raw stack trace:

Image

You could add a toggle for absolute paths in this popup or the toolbar above it.

I'd argue that "raw" stack traces should have absolute paths by default since they are the original/raw paths.

Product Area

Issues

getsantry[bot] commented 2 months ago

Auto-routing to @getsentry/product-owners-issues for triage ⏲️

MichaelSun48 commented 2 months ago

Hey there again @alxwrk, thanks for creating a separate issue for this! 🙏 Our team is actively working on improving the issue details page now, so I'll relay this feature request to the appropriate people internally and see if we can get it supported in the future.

I noticed in the original ticket, your reason for wanting this feature was:

This makes it difficult to map these paths to the real gem files on the system.

Could you elaborate more on that? I want to make sure we're fully understanding why this feature would be important to you. Thanks!

alxwrk commented 2 months ago

take this frame for example:

from active_record/connection_adapters/abstract_mysql_adapter.rb:187:in `block (2 levels) in execute'

the goal is to easily translate this to a local absolute path so the referenced line can opened in an editor/IDE that understands stack trace paths and makes them clickable/navigable.

The local absolute paths will be:

$LOCAL_GEMS_PATH/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb

How do you easily translate

active_record/connection_adapters/abstract_mysql_adapter.rb

to

$LOCAL_GEMS_PATH/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb

for every frame? You can't, easily. Your truncated paths are too lossy. You have to reconstruct the missing gem folder and missing internal path prefix (e.g. activerecord-5.2.4.1/lib) from the left over stub active_record/connection_adapters/abstract_mysql_adapter.rb.

If you had the absolute path in the trace it would be much easier,

going from

$PROD_GEMS_PATH/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb

to

$LOCAL_GEMS_PATH/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb

is just a matter of replacing $PROD_GEMS_PATH with $LOCAL_GEMS_PATH.

MichaelSun48 commented 2 months ago

Gotcha, thanks for the extra context! I can definitely see where your frustration is coming from now. I'll forward this to the people working on issue details right now and reply back here if we can get this supported.

alxwrk commented 1 month ago

The product side should make it possible to view abs_path in the UX and I believe they will do so shortly when time permits.

@sl0thentr0py @MichaelSun48

Do you know yet when this is expected?

armenzg commented 1 month ago

@alxwrk I will let @sl0thentr0py @MichaelSun48 answer, however, would you mind sharing a link to one of your issues so I can look closely?

alxwrk commented 3 weeks ago

@armenzg

https://sentry.io/issues/5735038623

A portion of the raw stack trace copied from the issue is in the OP.

armenzg commented 3 weeks ago

@alxwrk We expose the absolute paths in a tooltip of the normal stack trace view: Image

Does this feature help your needs?

alxwrk commented 3 weeks ago

I need the full raw stacktrace with raw absolute paths. Are you suggesting I build it myself, one frame at a time, from tooltips?

jangjodi commented 3 weeks ago

Hi @alxwrk, the "View JSON" {} button, also exposes the raw stack trace, including absolute paths. Does this help?

alxwrk commented 3 weeks ago

No, I made it clear from the first post

I need the full raw ruby stack trace with raw original absolute paths.

To be able to navigate it locally. Ruby IDEs and dev focused editors recognize ruby stack traces and let you navigate them

You already expose what you call "raw" ruby stack trace:

Mysql2::Error: Deadlock found when trying to get lock; try restarting transaction
  from mysql2/client.rb:131:in `_query'
  from mysql2/client.rb:131:in `block in query'
  from mysql2/client.rb:130:in `handle_interrupt'
  from mysql2/client.rb:130:in `query'
  from active_record/connection_adapters/abstract_mysql_adapter.rb:187:in `block (2 levels) in execute'
  from active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
  from active_support/concurrency/share_lock.rb:187:in `yield_shares'
  from active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
  from active_record/connection_adapters/abstract_mysql_adapter.rb:186:in `block in execute'
  from active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'

Except its not really raw. A raw (unprocessed) stack trace should have raw original absolute paths, at least optionally.

jangjodi commented 3 weeks ago

@alxwrk Apologies for the confusion. I am referring to this button shown in the screenshot. This JSON includes the absolute path that @armenzg mentioned previously in the tool tip. For example "abs_path": "/apps/cloud_ready/shared/bundle/ruby/2.6.0/gems/mysql2-0.5.3/lib/mysql2/client.rb" is included. Image

alxwrk commented 3 weeks ago

I need a raw ruby stacktrace with absolute paths, not your propitiatory json which I then have to process myself.

Can you understand that ruby IDEs and editors already recognize ruby stack traces? There's no such guarantee with with your verbose and voluminous propitiatory json

jangjodi commented 3 weeks ago

@alxwrk If the absolute paths in the JSON are incorrect, then this is an SDK issue. If you could either open another ticket with @getsentry/team-web-sdk-backend or provide some details about what is incorrect about the absolute paths, I can create one.

I took a look at the related ticket https://github.com/getsentry/sentry-ruby/issues/2407 and realized that this ticket's focus is for showing the raw absolute path in the UI. I can forward this request to the members on our team working on issue details.

alxwrk commented 3 weeks ago

@MichaelSun48 @sl0thentr0py

I don't know what @jangjodi is talking about.

What was supposed to be done here was determined a month ago, namely to optionally or always show absolute paths in the raw stack traces. It was explained why they are needed multiple times. When is this going to happen?

armenzg commented 3 weeks ago

@alxwrk This tone is inappropriate. Please refrain from writing in such terms.

This is a unique request that other customers have not seen the need for; thus, we're trying to understand if there are no existing features that would already be in place which could help.

We will consult with our managers and let them prioritize this work.

sl0thentr0py commented 3 weeks ago

In https://github.com/getsentry/sentry-ruby/releases/tag/5.20.0, I added a strip_backtrace_load_path config that can be turned false on the SDK side that @alxwrk can use to disable the SDK logic as asked.

We are still waiting for the product side to add a toggle somewhere so he can see what he wants in the UI, which is currently not possible.

alxwrk commented 3 weeks ago

I was already told by a "Member" @sl0thentr0py a month ago that raw stacktraces will (optionally or always) have raw absolute paths.

A month goes by, and there's not even a plan for when this might happen. Instead you start treating this as new issue, even though everything was already settled. I find that "inappropriate". And lets remember that we pay for this service, so take it easy with your tone policing. I said nothing "inappropriate" to any of you.

mrduncan commented 3 weeks ago

@alxwrk showing a full path when the raw stack trace is enabled on an event is on our backlog however I'm not able to provide a timeline for this work right now as our team is focused on other higher priorities.