Skip to content

🚀 Feature: Update Rollbar Logger to Send Stack Trace #27

@stnguyen90

Description

@stnguyen90

🔖 Feature description

Currently the Rollbar adapter does not send a stack trace and so errors in Rollbar look like:

image
{
  "body": {
    "timestamp": 1690241898,
    "message": {
      "body": "Document efgh5678 not found"
    }
  },
  "uuid": "7a49f3c1bb014cfc8e32bcdcbc78ce46",
  "level": "error",
  "timestamp": 1690241898,
  "custom": [
    "sdk: Flutter",
    "sdkVersion: 0.0.1",
    "authMode: default",
    "authMethod: cookie",
    "authProvider: MagicLink",
    "type: error",
    "environment: production",
    "sdk: utopia-logger/0.1.0"
  ],
  "environment": "production",
  "framework": "unknown",
  "trace_chain": [
    {
      "category": "http",
      "message": "DELETE /api/v1/database/abcd1234/efgh5678",
      "type": "default",
      "level": "debug"
    },
    {
      "category": "auth",
      "message": "Using API key",
      "type": "default",
      "level": "debug"
    },
    {
      "category": "auth",
      "message": "Authenticated with * Using API Key",
      "type": "default",
      "level": "info"
    },
    {
      "category": "database",
      "message": "Found collection abcd1234",
      "type": "default",
      "level": "info"
    },
    {
      "category": "database",
      "message": "Permission for collection abcd1234 met",
      "type": "default",
      "level": "debug"
    },
    {
      "category": "database",
      "message": "Missing document when searching by ID!",
      "type": "default",
      "level": "error"
    }
  ],
  "metadata": {}
}

It would be helpful to get the stack trace in Rollbar so it looks more like:

image
{
  "body": {
    "trace": {
      "frames": [
        {
          "method": "include",
          "args": [
            "/workspace/logger/vendor/phpunit/phpunit/phpunit"
          ],
          "lineno": 122,
          "filename": "/workspace/logger/vendor/bin/phpunit"
        },
        {
          "method": "PHPUnit\\TextUI\\Command::main",
          "args": [],
          "lineno": 107,
          "filename": "/workspace/logger/vendor/phpunit/phpunit/phpunit"
        },
        {
          "method": "PHPUnit\\TextUI\\Command::run",
          "args": [
            [
              "vendor/bin/phpunit",
              "--configuration",
              "phpunit.xml",
              "tests"
            ],
            true
          ],
          "lineno": 97,
          "filename": "/workspace/logger/vendor/phpunit/phpunit/src/TextUI/Command.php"
        },
        {
          "method": "PHPUnit\\TextUI\\TestRunner::run",
          "args": [
            {
              "class": "PHPUnit\\Framework\\TestSuite",
              "value": [
                {
                  "class": "PHPUnit\\Framework\\TestSuite",
                  "value": [
                    {
                      "class": "LoggerTest",
                      "value": []
                    },
                    {
                      "class": "LoggerTest",
                      "value": []
                    },
                    {
                      "class": "LoggerTest",
                      "value": []
                    },
                    {
                      "class": "LoggerTest",
                      "value": []
                    }
                  ]
                }
              ]
            },
            {
              "registerMockObjectsFromTestArgumentsRecursively": false,
              "forceCoversAnnotation": false,
              "verbose": false,
              "convertDeprecationsToExceptions": false,
              "executionOrderDefects": 0,
              "failOnSkipped": false,
              "beStrictAboutResourceUsageDuringSmallTests": false,
              "stopOnFailure": false,
              "disallowTodoAnnotatedTests": false,
              "colors": "auto",
              "stopOnRisky": false,
              "listSuites": false,
              "executionOrder": 0,
              "convertNoticesToExceptions": true,
              "stopOnError": false,
              "failOnRisky": false,
              "noInteraction": false,
              "stopOnSkipped": false,
              "processIsolation": false,
              "enforceTimeLimit": false,
              "backupGlobals": false,
              "notLoadedExtensions": [],
              "strictCoverage": false,
              "reportLowUpperBound": 50,
              "reverseList": false,
              "resolveDependencies": true,
              "testdoxExcludeGroups": [],
              "randomOrderSeed": 1690242484,
              "testdoxGroups": [],
              "cacheResult": true,
              "failOnEmptyTestSuite": false,
              "columns": 80,
              "crap4jThreshold": 30,
              "cacheResultFile": "/workspace/logger",
              "listGroups": false,
              "repeat": false,
              "stopOnDefect": false,
              "listTests": false,
              "warnings": [],
              "groups": [],
              "beStrictAboutChangesToGlobalState": false,
              "timeoutForMediumTests": 10,
              "useDefaultConfiguration": true,
              "configurationObject": {
                "class": "PHPUnit\\TextUI\\XmlConfiguration\\Configuration",
                "value": []
              },
              "convertErrorsToExceptions": true,
              "reportUselessTests": true,
              "disableCodeCoverageIgnore": false,
              "configuration": "phpunit.xml",
              "stopOnWarning": false,
              "unavailableExtensions": [],
              "failOnWarning": false,
              "loadedExtensions": [],
              "stopOnIncomplete": false,
              "defaultTimeLimit": 1,
              "listTestsXml": false,
              "failOnIncomplete": false,
              "backupStaticAttributes": false,
              "bootstrap": "./vendor/autoload.php",
              "timeoutForSmallTests": 1,
              "disallowTestOutput": false,
              "testSuffixes": [
                "Test.php",
                ".phpt"
              ],
              "filter": false,
              "reportHighLowerBound": 90,
              "listeners": [],
              "excludeGroups": [],
              "extensions": [],
              "stderr": false,
              "debug": false,
              "convertWarningsToExceptions": true,
              "ignoreDeprecatedCodeUnitsFromCodeCoverage": false,
              "reverseDefectList": false,
              "timeoutForLargeTests": 60
            },
            [],
            true
          ],
          "lineno": 144,
          "filename": "/workspace/logger/vendor/phpunit/phpunit/src/TextUI/Command.php"
        },
        {
          "method": "PHPUnit\\Framework\\TestSuite::run",
          "args": [
            {
              "class": "PHPUnit\\Framework\\TestResult",
              "value": []
            }
          ],
          "lineno": 651,
          "filename": "/workspace/logger/vendor/phpunit/phpunit/src/TextUI/TestRunner.php"
        },
        {
          "method": "PHPUnit\\Framework\\TestSuite::run",
          "args": [
            {
              "class": "PHPUnit\\Framework\\TestResult",
              "value": []
            }
          ],
          "lineno": 684,
          "filename": "/workspace/logger/vendor/phpunit/phpunit/src/Framework/TestSuite.php"
        },
        {
          "method": "PHPUnit\\Framework\\TestCase::run",
          "args": [
            {
              "class": "PHPUnit\\Framework\\TestResult",
              "value": []
            }
          ],
          "lineno": 684,
          "filename": "/workspace/logger/vendor/phpunit/phpunit/src/Framework/TestSuite.php"
        },
        {
          "method": "PHPUnit\\Framework\\TestResult::run",
          "args": [
            {
              "class": "LoggerTest",
              "value": []
            }
          ],
          "lineno": 964,
          "filename": "/workspace/logger/vendor/phpunit/phpunit/src/Framework/TestCase.php"
        },
        {
          "method": "PHPUnit\\Framework\\TestCase::runBare",
          "args": [],
          "lineno": 728,
          "filename": "/workspace/logger/vendor/phpunit/phpunit/src/Framework/TestResult.php"
        },
        {
          "method": "PHPUnit\\Framework\\TestCase::runTest",
          "args": [],
          "lineno": 1214,
          "filename": "/workspace/logger/vendor/phpunit/phpunit/src/Framework/TestCase.php"
        },
        {
          "method": "LoggerTest::testAdapters",
          "args": [],
          "lineno": 1608,
          "filename": "/workspace/logger/vendor/phpunit/phpunit/src/Framework/TestCase.php"
        },
        {
          "lineno": 201,
          "filename": "/workspace/logger/tests/LoggerTest.php"
        }
      ],
      "exception": {
        "message": "test exception",
        "class": "Exception"
      }
    }
  },
  "uuid": "1a71e944-02b4-457a-a02a-3f0d38b4f074",
  "language": "php",
  "level": "error",
  "timestamp": 1690242484,
  "code_version": "",
  "request": {
    "POST": [],
    "GET": []
  },
  "server": {
    "host": "55b92c98fe5a",
    "argv": [
      "vendor/bin/phpunit",
      "--configuration",
      "phpunit.xml",
      "tests"
    ]
  },
  "environment": "production",
  "platform": "Linux 55b92c98fe5a 6.1.27-060127-generic #202305051509 SMP PREEMPT_DYNAMIC Fri May  5 15:48:49 UTC 2023 x86_64",
  "framework": "unknown",
  "custom": [],
  "notifier": {
    "version": "3.1.2",
    "name": "rollbar-php"
  },
  "metadata": {
    "customer_timestamp": 1690242484
  }
}

🎤 Pitch

Having a stacktrace would make it easier to troubleshoot errors.

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions