Browse Source

Merge branch 'master' into 'import-post'

# Conflicts:
#   glitchtip/importer/tests.py
David Burke 2 years ago
parent
commit
8ce8e3105c

+ 5 - 4
.gitlab-ci.yml

@@ -5,6 +5,7 @@ variables:
   PIP_DISABLE_PIP_VERSION_CHECK: "on"
   PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
   POETRY_VIRTUALENVS_CREATE: "false"
+  POETRY_HOME: "/opt/poetry"
   POSTGRES_HOST_AUTH_METHOD: "trust"
   DEBUG: "true"
 
@@ -30,15 +31,15 @@ test:
     paths:
       - .cache/pip
   script:
-    - pip install poetry
-    - poetry install --no-interaction --no-ansi
+    - curl -sSL https://install.python-poetry.org | python3 -
+    - $POETRY_HOME/bin/poetry install --no-interaction --no-ansi
     - ./manage.py test
 
 lint:
   image: python:3.10
   script:
-    - pip install poetry
-    - poetry install --no-interaction --no-ansi
+    - curl -sSL https://install.python-poetry.org | python3 -
+    - $POETRY_HOME/bin/poetry install --no-interaction --no-ansi
     # - isort --check glitchtip not compatible with black :(
     # - pylint --load-plugins=pylint_django --django-settings-module=glitchtip.settings --disable=R glitchtip
 

+ 3 - 2
Dockerfile

@@ -3,12 +3,13 @@ ARG IS_CI
 ENV PYTHONUNBUFFERED=1 \
   PORT=8080 \
   POETRY_VIRTUALENVS_CREATE=false \
+  POETRY_HOME=/opt/poetry \
   PIP_DISABLE_PIP_VERSION_CHECK=on
 
-RUN pip install poetry
 WORKDIR /code
+RUN curl -sSL https://install.python-poetry.org | python3 -
 COPY poetry.lock pyproject.toml /code/
-RUN poetry install --no-interaction --no-ansi $(test "$IS_CI" = "True" && echo "--no-dev")
+RUN $POETRY_HOME/bin/poetry install --no-interaction --no-ansi $(test "$IS_CI" = "True" && echo "--no-dev")
 
 FROM python:3.10-slim
 ARG GLITCHTIP_VERSION=local

+ 122 - 0
events/test_data/incoming_events/django_fingerprint.json

@@ -0,0 +1,122 @@
+{
+  "level": "error",
+  "exception": {
+    "values": [
+      {
+        "module": null,
+        "type": "Exception",
+        "value": "something 9",
+        "mechanism": null,
+        "stacktrace": {
+          "frames": [
+            {
+              "filename": "errors/views.py",
+              "abs_path": "/code/errors/views.py",
+              "function": "get",
+              "module": "errors.views",
+              "lineno": 91,
+              "pre_context": [
+                "        0 / 0",
+                "",
+                "class FingerprintView(View):",
+                "    def get(self, request, *args, **kwargs):",
+                "        try:"
+              ],
+              "context_line": "            raise Exception(\"something %s\" % randrange(10))",
+              "post_context": [
+                "        except Exception as err:",
+                "            with push_scope() as scope:",
+                "                scope.fingerprint = [\"foo\"]",
+                "                capture_exception(err)",
+                "        return HttpResponse(\"Ok\")"
+              ],
+              "vars": {
+                "self": "<errors.views.FingerprintView object at 0x7fdb827a69b0>",
+                "request": "<WSGIRequest: GET '/fingerprint/'>",
+                "args": [],
+                "kwargs": {},
+                "err": "Exception('something 9')",
+                "scope": "<Scope id=0x7fdb827bb5e0 name=wsgi>"
+              },
+              "in_app": true
+            }
+          ]
+        }
+      }
+    ]
+  },
+  "event_id": "3ae3fd09af864ff2b47b5660ffdd2335",
+  "timestamp": "2022-08-26T01:04:11.691403Z",
+  "breadcrumbs": { "values": [] },
+  "transaction": "/fingerprint/",
+  "transaction_info": { "source": "route" },
+  "fingerprint": ["foo"],
+  "contexts": {
+    "trace": {
+      "trace_id": "c5092e5166294f92a45c85400396415e",
+      "span_id": "b12138ae837c101f",
+      "parent_span_id": "b7bf9900011a3876",
+      "op": "django.view",
+      "description": "fingerprint"
+    },
+    "runtime": {
+      "name": "CPython",
+      "version": "3.10.6",
+      "build": "3.10.6 (main, Aug  3 2022, 10:24:07) [GCC 10.2.1 20210110]"
+    }
+  },
+  "modules": {
+    "django": "3.2.15",
+    "ipython-genutils": "0.2.0"
+  },
+  "extra": { "sys.argv": ["./manage.py", "runserver", "0.0.0.0:8001"] },
+  "request": {
+    "url": "http://localhost:8001/fingerprint/",
+    "query_string": "",
+    "method": "GET",
+    "env": { "SERVER_NAME": "0242d0b0a287", "SERVER_PORT": "8001" },
+    "headers": {
+      "Content-Length": "",
+      "Content-Type": "text/plain",
+      "Host": "localhost:8001",
+      "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:104.0) Gecko/20100101 Firefox/104.0",
+      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
+      "Accept-Language": "en-US,en;q=0.5",
+      "Accept-Encoding": "gzip, deflate, br",
+      "Referer": "http://localhost:8001/",
+      "Connection": "keep-alive",
+      "Cookie": "",
+      "Upgrade-Insecure-Requests": "1",
+      "Sec-Fetch-Dest": "document",
+      "Sec-Fetch-Mode": "navigate",
+      "Sec-Fetch-Site": "same-origin",
+      "Dnt": "1",
+      "Sec-Gpc": "1"
+    }
+  },
+  "environment": "production",
+  "server_name": "0242d0b0a287",
+  "sdk": {
+    "name": "sentry.python",
+    "version": "1.9.5",
+    "packages": [{ "name": "pypi:sentry-sdk", "version": "1.9.5" }],
+    "integrations": [
+      "argv",
+      "atexit",
+      "dedupe",
+      "django",
+      "excepthook",
+      "logging",
+      "modules",
+      "redis",
+      "stdlib",
+      "threading"
+    ]
+  },
+  "platform": "python",
+  "_meta": {
+    "request": {
+      "headers": { "Cookie": { "": { "rem": [["!config", "x", 0, 464]] } } }
+    }
+  }
+}

+ 2 - 2
glitchtip/importer/importer.py

@@ -132,10 +132,10 @@ class GlitchTipImporter:
         project_resource.import_data(dataset, raise_errors=True)
         owned_project_ids = Project.objects.filter(
             organization_id=self.organization_id,
-            pk__in=[d["projectID"] for d in project_keys],
+            pk__in=[d["projectId"] for d in project_keys],
         ).values_list("pk", flat=True)
         project_keys = list(
-            filter(lambda key: key["projectID"] in owned_project_ids, project_keys)
+            filter(lambda key: key["projectId"] in owned_project_ids, project_keys)
         )
         dataset.dict = project_keys
         project_key_resource.import_data(dataset, raise_errors=True)

+ 1 - 1
glitchtip/importer/tests.py

@@ -13,7 +13,7 @@ test_project = {"id": "1", "slug": "project", "name": "project"}
 test_key = {
     "id": "a" * 32,
     "public": "a" * 32,
-    "projectID": 1,
+    "projectId": 1,
     "label": "Default",
 }
 

+ 6 - 9
glitchtip/settings.py

@@ -388,6 +388,7 @@ if broker_sentinel_password := env.str("CELERY_BROKER_SENTINEL_KWARGS_PASSWORD",
     }
 
 CELERY_RESULT_BACKEND = "django-db"
+CELERY_RESULT_EXTENDED = True
 CELERY_CACHE_BACKEND = "django-cache"
 CELERY_BEAT_SCHEDULE = {
     "send-alert-notifications": {
@@ -550,17 +551,13 @@ ACCOUNT_USER_MODEL_USERNAME_FIELD = None
 ACCOUNT_ADAPTER = "glitchtip.social.MFAAccountAdapter"
 INVITATION_BACKEND = "organizations_ext.invitation_backend.InvitationBackend"
 SOCIALACCOUNT_PROVIDERS = {}
-GITLAB_URL = env.url("SOCIALACCOUNT_PROVIDERS_gitlab_GITLAB_URL", None)
-if GITLAB_URL:
+if GITLAB_URL := env.url("SOCIALACCOUNT_PROVIDERS_gitlab_GITLAB_URL", None):
     SOCIALACCOUNT_PROVIDERS["gitlab"] = {"GITLAB_URL": GITLAB_URL.geturl()}
-GITEA_URL = env.url("SOCIALACCOUNT_PROVIDERS_gitea_GITEA_URL", None)
-if GITEA_URL:
+if GITEA_URL := env.url("SOCIALACCOUNT_PROVIDERS_gitea_GITEA_URL", None):
     SOCIALACCOUNT_PROVIDERS["gitea"] = {"GITEA_URL": GITEA_URL.geturl()}
-NEXTCLOUD_URL = env.url("SOCIALACCOUNT_PROVIDERS_nextcloud_SERVER", None)
-if NEXTCLOUD_URL:
+if NEXTCLOUD_URL := env.url("SOCIALACCOUNT_PROVIDERS_nextcloud_SERVER", None):
     SOCIALACCOUNT_PROVIDERS["nextcloud"] = {"SERVER": NEXTCLOUD_URL.geturl()}
-KEYCLOAK_URL = env.url("SOCIALACCOUNT_PROVIDERS_keycloak_KEYCLOAK_URL", None)
-if KEYCLOAK_URL:
+if KEYCLOAK_URL := env.url("SOCIALACCOUNT_PROVIDERS_keycloak_KEYCLOAK_URL", None):
     alt_url_env = env.url("SOCIALACCOUNT_PROVIDERS_keycloak_KEYCLOAK_URL_ALT", None)
 
     if alt_url_env:
@@ -735,7 +732,7 @@ if CELERY_TASK_ALWAYS_EAGER:
         }
     }
 
-MFA_SERVER_NAME = "GlitchTip"
+MFA_SERVER_NAME = GLITCHTIP_URL.hostname
 FIDO_SERVER_ID = GLITCHTIP_URL.hostname
 
 # Workaround for error encountered at build time (source: https://github.com/axnsan12/drf-yasg/issues/761#issuecomment-1014530805)

+ 1 - 0
glitchtip/views.py

@@ -45,6 +45,7 @@ class SettingsView(APIView):
                 "sentryTracesSampleRate": settings.SENTRY_TRACES_SAMPLE_RATE,
                 "environment": settings.ENVIRONMENT,
                 "version": settings.GLITCHTIP_VERSION,
+                "serverTimeZone": settings.TIME_ZONE,
             }
         )
 

File diff suppressed because it is too large
+ 169 - 138
poetry.lock


Some files were not shown because too many files changed in this diff