Send call stack and context without triggering an exception
See original GitHub issueI’m trying to catch a bug in my code, that is very hard to reproduce. I can detect it, but I’d need a bit more context to reliably reproduce it.
I think the data that is reported to sentry on exception (call stack, values of local variables) will be very useful to track it. Is there any way to trigger such an event? I don’t want to interrupt my program, so I can’t raise an exception here. I’ve tried capture_event()
and capture_message()
but none of them captures the data I need.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Supress/filter exception context when raised within a trigger
In a Python application I'm catching exceptions thrown from stored procedures on my database as psycopg2.InternalError . I've noticed that when ...
Read more >Best Practices for exceptions - .NET - Microsoft Learn
Learn best practices for exceptions, such as using try/catch/finally, handling common conditions without exceptions, and using predefined .
Read more >Can I store information even if the trigger throws an exception?
EXCEPTION - To summarize the edits from subsequent contact with salesforce: this will not work if every record in the trigger has errors....
Read more >contextlib — Utilities for with-statement contexts ... - Python Docs
For any context managers and exit callbacks registered, the arguments passed in will indicate that no exception occurred. class contextlib.AsyncExitStack¶. An ...
Read more >Java Stack Trace: How to Read and Understand to Debug Code
Usually, a stack trace is shown when an Exception is not handled correctly in code. (An exception is what a runtime environment uses...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Found this when googeling, EXCATLY what i needed.
Perfected it a little bit by popping the last element of the stack and added a proper name to the message if possible:
OK, I think I’ve figured out from the logging
EventHandler
how to do what I want - the code is not pretty, but works:I think this could be inside some utility function, but it is good enough for me.
One question though - the last frame of the stacktrace points at
"stacktrace": current_stacktrace(client_options["with_locals"]),
, which makes sense, but I’d like to remove it. I’ve figured out that I can remove the last element fromevent['threads']['values'][0]['stacktrace']['frames']
, and my stacktrace looks much better. The question is ifevent['threads']['values'][0]
is guaranteed to be the current thread, or it may change when multiple threads are used?