plainx-sentry 0.5.0__py3-none-any.whl → 0.5.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
plainx/sentry/middleware.py
CHANGED
|
@@ -4,9 +4,9 @@ from sentry_sdk.tracing import TransactionSource
|
|
|
4
4
|
from sentry_sdk.utils import capture_internal_exceptions
|
|
5
5
|
|
|
6
6
|
try:
|
|
7
|
-
from plain.models.db import
|
|
7
|
+
from plain.models.db import connections, DEFAULT_DB_ALIAS
|
|
8
8
|
except ImportError:
|
|
9
|
-
|
|
9
|
+
connections = None
|
|
10
10
|
|
|
11
11
|
import logging
|
|
12
12
|
|
|
@@ -19,11 +19,11 @@ def trace_db(execute, sql, params, many, context):
|
|
|
19
19
|
data = {
|
|
20
20
|
"db.params": params,
|
|
21
21
|
"db.executemany": many,
|
|
22
|
-
"db.system":
|
|
23
|
-
"db.name":
|
|
24
|
-
"db.user":
|
|
25
|
-
"server.address":
|
|
26
|
-
"server.port":
|
|
22
|
+
"db.system": connections[DEFAULT_DB_ALIAS].vendor,
|
|
23
|
+
"db.name": connections[DEFAULT_DB_ALIAS].settings_dict.get("NAME"),
|
|
24
|
+
"db.user": connections[DEFAULT_DB_ALIAS].settings_dict.get("USER"),
|
|
25
|
+
"server.address": connections[DEFAULT_DB_ALIAS].settings_dict.get("HOST"),
|
|
26
|
+
"server.port": connections[DEFAULT_DB_ALIAS].settings_dict.get("PORT"),
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
sentry_sdk.add_breadcrumb(message=sql, category="query", data=data)
|
|
@@ -51,7 +51,7 @@ class SentryMiddleware:
|
|
|
51
51
|
request_info = event.setdefault("request", {})
|
|
52
52
|
request_info["url"] = request.build_absolute_uri()
|
|
53
53
|
request_info["method"] = request.method
|
|
54
|
-
request_info["query_string"] = request.
|
|
54
|
+
request_info["query_string"] = request.meta.get("QUERY_STRING", "")
|
|
55
55
|
# Headers and env need some PII filtering, ideally,
|
|
56
56
|
# among other filters... similar for GET/POST data?
|
|
57
57
|
# request_info["headers"] = dict(request.headers)
|
|
@@ -81,9 +81,9 @@ class SentryMiddleware:
|
|
|
81
81
|
with sentry_sdk.start_transaction(
|
|
82
82
|
op="http.server", name=request.path_info
|
|
83
83
|
) as transaction:
|
|
84
|
-
if
|
|
84
|
+
if connections:
|
|
85
85
|
# Also get spans for db queries
|
|
86
|
-
with
|
|
86
|
+
with connections[DEFAULT_DB_ALIAS].execute_wrapper(trace_db):
|
|
87
87
|
response = self.get_response(request)
|
|
88
88
|
else:
|
|
89
89
|
# No db presumably
|
|
@@ -137,9 +137,9 @@ class SentryWorkerMiddleware:
|
|
|
137
137
|
name=f"job:{job.job_class}",
|
|
138
138
|
source=TransactionSource.TASK,
|
|
139
139
|
) as transaction:
|
|
140
|
-
if
|
|
140
|
+
if connections:
|
|
141
141
|
# Also get spans for db queries
|
|
142
|
-
with
|
|
142
|
+
with connections[DEFAULT_DB_ALIAS].execute_wrapper(trace_db):
|
|
143
143
|
job_result = self.run_job(job)
|
|
144
144
|
else:
|
|
145
145
|
# No db presumably
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
plainx/sentry/__init__.py,sha256=Klz3mH_itM2RXzJ_sWWJRIoZcS0jCRxWrhVVIPsG5FY,123
|
|
2
2
|
plainx/sentry/config.py,sha256=EwMnY3DaanIGkgtKD_4h8ncx6MH_MxOML8BF5Hx5GBA,723
|
|
3
3
|
plainx/sentry/default_settings.py,sha256=DNX6OQ0-BqfjyWuszW7JnZhiDn0tGtS3Fa2W7VbTIF8,564
|
|
4
|
-
plainx/sentry/middleware.py,sha256=
|
|
4
|
+
plainx/sentry/middleware.py,sha256=huo7bEmz-yP1ft8vvMHfJqUN5G3tZlZfwLbkBwjnlQI,6174
|
|
5
5
|
plainx/sentry/templates.py,sha256=YovKIswcsjLRjHdmRzdaxG1PHjGfz8fc5TeNE9wcYQA,2046
|
|
6
6
|
plainx/sentry/templates/sentry/js.html,sha256=aOjWAwuUaecGbC-5yZWP1aaGyYAcM-GK0dru-4VOYoE,491
|
|
7
|
-
plainx_sentry-0.5.
|
|
8
|
-
plainx_sentry-0.5.
|
|
9
|
-
plainx_sentry-0.5.
|
|
7
|
+
plainx_sentry-0.5.2.dist-info/METADATA,sha256=h3I8SOjZWC6rfW_Jhyeax594li1llkyhTpYQQMDfgSg,1559
|
|
8
|
+
plainx_sentry-0.5.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
9
|
+
plainx_sentry-0.5.2.dist-info/RECORD,,
|
|
File without changes
|