issue_generator.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import random
  2. from glitchtip.test_utils.test_data import ENVIRONMENTS, RELEASES
  3. def brower_tag_generator():
  4. return random.choice(BROWSER_TAGS)
  5. SDKS = [
  6. {
  7. "version": "1.5.1",
  8. "name": "sentry.python",
  9. "packages": [{"version": "1.5.1", "name": "pypi:sentry-sdk"}],
  10. "integrations": [],
  11. },
  12. {
  13. "name": "sentry.javascript.react",
  14. "version": "7.36.0",
  15. "packages": [{"name": "npm:@sentry/react", "version": "7.36.0"}],
  16. "integrations": [
  17. "InboundFilters",
  18. ],
  19. },
  20. {"name": "sentry.php.laravel", "version": "2.9.0"},
  21. ]
  22. EXCEPTIONS = [
  23. {
  24. "values": [
  25. {
  26. "type": "Error",
  27. "value": "A Generic Error 9371d7",
  28. "stacktrace": {
  29. "frames": [
  30. {
  31. "colno": 27,
  32. "filename": "http://localhost:4201/polyfills.js",
  33. "function": "globalZoneAwareCallback",
  34. "in_app": True,
  35. "lineno": 4864,
  36. },
  37. ]
  38. },
  39. }
  40. ]
  41. },
  42. {
  43. "values": [
  44. {
  45. "type": "System.DivideByZeroException",
  46. "value": "Attempted to divide by zero.",
  47. "module": "System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=1111111111111111",
  48. "thread_id": 1,
  49. "stacktrace": {
  50. "frames": [
  51. {
  52. "function": "Invoke",
  53. "module": "Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware",
  54. "in_app": False,
  55. "package": "Microsoft.AspNetCore.Diagnostics, Version=3.1.3.0, Culture=neutral, PublicKeyToken=111111",
  56. "instruction_offset": 130,
  57. },
  58. {
  59. "function": "InvokeHandlerMethodAsync",
  60. "module": "Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker",
  61. "in_app": False,
  62. "package": "Microsoft.AspNetCore.Mvc.RazorPages, Version=3.1.3.0, Culture=neutral, PublicKeyToken=111111",
  63. "instruction_offset": 202,
  64. },
  65. ]
  66. },
  67. }
  68. ]
  69. },
  70. ]
  71. BROWSER_TAGS = [
  72. {
  73. "device": "Desktop",
  74. "browser": "GlitchBot 1.2",
  75. "os.name": "Linux",
  76. "server_name": "glitch-server",
  77. "browser.name": "GlitchBot",
  78. },
  79. {
  80. "device": "Mobile",
  81. "browser": "Firefox 120",
  82. "os.name": "Android",
  83. "server_name": "glitch-server",
  84. "browser.name": "Firefox",
  85. },
  86. {
  87. "device": "Desktop",
  88. "browser": "bingbot 2.0",
  89. "os.name": "Other",
  90. "server_name": "cool-server",
  91. "browser.name": "bingbot",
  92. },
  93. {
  94. "browser": "Chrome 106.0.0",
  95. "os.name": "Windows",
  96. "release": "v1.0.0",
  97. "browser.name": "Chrome",
  98. },
  99. ]
  100. CULPRITS = [
  101. "/src/Controller/FunController.php in App\Controller\FunController::showFun",
  102. "blarg.php in ?",
  103. "subscriber.contract.view.modal.block.unblock",
  104. ]
  105. SERVER_TAGS = [
  106. {
  107. "os.name": "Linux",
  108. "server_name": "ip-111-11-11-111.ec3.internal",
  109. },
  110. {
  111. "server_name": "11335c17-b136-1e4a-1241-e243221c1221",
  112. },
  113. ]
  114. TAG_CHOICES = BROWSER_TAGS + SERVER_TAGS
  115. TITLE_CHOICES = [
  116. "The error has happened here",
  117. "ErrorException: Notice: Trying to access array offset on value of type null",
  118. "WorkerLostError: Worker exited prematurely: signal 15 (SIGTERM) Job: 1.",
  119. "ErrorException: Warning: filesize(): stat failed for /var/www/vhosts/example.com/private/me/data/1",
  120. "Project\Database\QueryException: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type uuid: 12345",
  121. "OperationalError: ERROR: no more connections allowed (max_client_conn)",
  122. ]
  123. def generate_tags() -> dict[str, str]:
  124. tags: dict[str, str] = random.choice(TAG_CHOICES)
  125. if environment := random.choice(ENVIRONMENTS):
  126. tags["environment"] = environment
  127. if release := random.choice(RELEASES):
  128. tags["release"] = release
  129. return tags