Skip to content

No designated place for traceback in message item #471

Open

Description

@ArturMoczulski

Steps to reproduce:

  • set send_message_trace to true,
  • report a message item Rollbar::log(Level::INFO, 'Message from app');

Expected result
The trace back should be visible in the Rollbar item details page just as when reporting an exception.

Result
The trace back is not visible in the Rollbar item details page. It's under body.message.backtrace in unformatted and hard to read in occurrence details.

Impact across SDKs
This is a problem that will appear across other SDKs as well as currently we just don't support backtrace for message items. Support for that needs to be implemented.

Activity

  1. brianr commented on Sep 30, 2019

    @brianr
    Member

    @ArturMoczulski FWIW: at the API level, the current idea for these is that "message" items that contain tracebacks would be reported as tracebacks containing an explicit message. In those the message goes in trace.exception.description.

  2. zanderwar commented on Apr 8, 2020

    @zanderwar

    +1 Please, this would be really great and I personally need it to go alongside SQL errors that I catch, and can only get the backtrace to appear in occurrences as @ArturMoczulski mentions

  3. zanderwar commented on Apr 8, 2020

    @zanderwar

    This is good enough for me atm

    function reportSqlError($sql, $error)
    {
    	$message = "SQL ERROR: {$error}\n\n";
    
    	// maintain the layout, but reduce any excessive tabs or spaces
    	$message .= preg_replace('/\t\s?/m', '', trim($sql)) . "\n\n";
    
    	// build backtrace
    	$e = new Exception();
    	$trace = explode("\n", $e->getTraceAsString());
    
    	// reverse array to make steps line up chronologically
    	$trace = array_reverse($trace);
    
    	// remove {main}
    	array_shift($trace);
    
    	// remove call to this method
    	array_pop($trace);
    
    	// renumber items
    	$length = count($trace);
    	$result = array();
    
    	for ($i = 0; $i < $length; $i++)
    	{
    		$result[] = ($i + 1)  . ')' . substr($trace[$i], strpos($trace[$i], ' ')); // replace '#someNum' with '$i)', set the right ordering
    	}
    
    	$message .= implode("\n", $result);
    
    	\Rollbar\Rollbar::log(\Rollbar\Payload\Level::CRITICAL, $message);
    }
    

    image

  4. troygilbert commented on Sep 5, 2023

    @troygilbert

    Glad I'm not the only one suffering this issue, but so sad to see it's been like this for 4+ years!? I don't understand why the backtrace can't be used identically to what happens when there's an exception thrown? Is there any movement on this from the Rollbar PHP maintainers?

  5. danielmorell commented on Sep 15, 2023

    @danielmorell
    Collaborator

    Let me see if I can get this in either v4.1 or v4.2. For now, I will aim at v4.1.

  6. added this to the v4.1.0 milestone on Sep 15, 2023
  7. troygilbert commented on Jan 3, 2024

    @troygilbert

    Any movement on this?

    As a stopgap, are there any tools that can prettify the data contained in the backtrace field? I thought it was PHP serialized, but I'm unable to deserialize it, so I must be missing something.

  8. modified the milestones: v4.1.0, v4.2.0 on Mar 1, 2024
  9. modified the milestones: v4.2.0, v4.3.0 on Nov 25, 2025
  10. danielmorell commented on Oct 16, 2026

    @danielmorell
    Collaborator

    I was thinking about this and have a few ideas.

    The Rollbar backend is designed to accept different types of items. Typically, if you were to send a log message you would do something like this...

    Rollbar::log(Level::INFO, 'Message from app');

    However, what you send determines the "type" of item that is sent to the Rollbar backend by the SDK. If an exception is the item being sent a full stack trace is included by default.

    This sends a log that contains a full stack trace...

    Rollbar::log(Level::INFO, new Exception('Message from app'));

    The main downside is that this shows up labeled "Exception: Message from app". This is probably not the ideal way to identify a "log" from your app. But this is also easy to change.

    /**
     * Not intended for throwing, just for sending to Rollbar.
     */
    class BacktraceLog extends Exception {}
    
    Rollbar::log(Level::INFO, new BacktraceLog('Message from app'));

    This now creates a new item in Rollbar titled "BacktraceLog: Message from app". It includes a full stack trace and message that was logged.

  11. danielmorell commented on Nov 6, 2026

    @danielmorell
    Collaborator

    After an internal conversation we have determined to make this something supported by the core SDK. It will be resolved in v4.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions