Skip to content

[Feat][SDK- 431] Add threads information to payload #327

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

Merged
merged 37 commits into from
May 15, 2025

Conversation

buongarzoni
Copy link
Collaborator

@buongarzoni buongarzoni commented Mar 24, 2025

Description of the change

We will send information about the status of the threads in the application when sending an exception, whether it is caught or not.

  • Add "threads" object to "body" in payload
  • Add truncation strategy for Rollbar threads
    • For a given RollbarThread we use the same Strategy we have in a TraceChain, cutting the extra frames leaving 10 in head and 10 in tail.
  • Add truncation strategy for Telemetry events
    • By default the telemetry events have a maximum capacity of 100. But when the payload is too big, we set the maximum to 10, leaving only the latest events.
  • The structure of the new payload is:
{
   "trace": {
     "exception": {
       "description": "another thing to exist",
       "message": "this is an error",
       "class": "java.lang.Error"
     },
     "frames": [
       {
         "filename": "MainActivity.java",
         "lineno": 77,
         "method": "run",
         "class_name": "com.rollbar.example.android.MainActivity$2"
       }
     ]
   },
   "threads": [{
       "id": "2",
       "name": "main",
       "state": "RUNNABLE",
       "is_main": true
       "priority": "5",
       "group": [{
           "trace_chain": [{
               "frames": [{
                       "filename": "Thread.java",
                       "lineno": 1012,
                       "method": "run",
                       "class_name": "java.lang.Thread",
                   },
                   {
                       "filename": "Daemons.java",
                       "lineno": 145,
                       "method": "run",
                       "class_name": "java.lang.Daemons$Daemon",
                   },
               ],
               "exception": {
                   "message": "Uncaught exception",
                   "class": "java.lang.RuntimeException"
               }
           }]
       }]
   }]
}

Fields in a Body object

Field
Type Mandatory Description
trace Trace Yes (only 1 trace, trace_chain or message object is required) Represent a Stack Trace
trace_chain List < Trace > Yes (only 1 trace, trace_chain or message object is required) Represents a chain of errors (Traces)
message Message Yes (only 1 trace, trace_chain or message object is required) Represents a message (text) sent to Rollbar, possible with additional information
-------- ------- ------- -------
telemetry List < TelemetryEvents > No
threads List < Thread > No

⚠️ whenever we send trace and trace_chain we are going to send threads, since these are going to be replaced by it. message continues to be sent as usual.

How to test

With any of the test examples we can see this new information in the payload.

Fields in a Thread object

Field
Type Mandatory Description
state String No State of the Thread, could be:
NEW, RUNNABLE, BLOCKED, WAITING, TIMED_WAITING or TERMINATED
priority String No Priority level of a Thread, values would be [1, 10]
id String Yes Positive long number generated when the Thread was created
name String No Name of the Thread
is_main Boolean No Boolean representing if this is a main thread
group List < TraceChain > Yes This represent a Group of trace chains in a Thread.
In Java we only send 1 TraceChain per Group,
in other languages like Python (ExceptionGroup) or JS (AggregatorError),
it may be more TraceChains per group.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Maintenance
  • New release

Related issues

Shortcut stories and GitHub issues (delete irrelevant)

Checklists

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers assigned
  • Issue from task tracker has a link to this pull request
  • Changes have been reviewed by at least one other engineer

@buongarzoni buongarzoni self-assigned this Mar 24, 2025
Copy link

linear bot commented Mar 24, 2025

@buongarzoni buongarzoni added this to the v2.1.0 milestone Apr 13, 2025
@@ -17,38 +19,128 @@ public class RollbarThrowableWrapper implements ThrowableWrapper {

private final Throwable throwable;

private final Thread thread;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we actually need the Thread object here, or would the information held by RollbarThread be sufficient?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think you're right, I could just use the RollbarThread here, I'll check it out, thanks!

+ ", stackTraceElements=" + Arrays.toString(stackTraceElements)
+ ", cause=" + cause
+ ", throwable=" + throwable
+ ", thread=" + thread
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the expected display value here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

something like thread=Thread[main,5,main]
anyway with the other suggestion you made, I'm probably going to change this

@buongarzoni buongarzoni merged commit b88ad18 into master May 15, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants