insider-python 0.1.0__py3-none-any.whl → 0.1.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.
- insider/_envelope.py +3 -0
- insider/_version.py +1 -1
- insider/client.py +20 -0
- insider/stacktrace.py +11 -1
- {insider_python-0.1.0.dist-info → insider_python-0.1.2.dist-info}/METADATA +3 -2
- {insider_python-0.1.0.dist-info → insider_python-0.1.2.dist-info}/RECORD +8 -8
- {insider_python-0.1.0.dist-info → insider_python-0.1.2.dist-info}/WHEEL +0 -0
- {insider_python-0.1.0.dist-info → insider_python-0.1.2.dist-info}/top_level.txt +0 -0
insider/_envelope.py
CHANGED
|
@@ -56,6 +56,7 @@ def build_envelope(
|
|
|
56
56
|
tags: Optional[Dict[str, Any]] = None,
|
|
57
57
|
extra: Optional[Dict[str, Any]] = None,
|
|
58
58
|
occurred_at: Optional[str] = None,
|
|
59
|
+
commit_hash: Optional[str] = None,
|
|
59
60
|
) -> Dict[str, Any]:
|
|
60
61
|
"""Assemble the Beacon envelope. Pure: no I/O, no globals."""
|
|
61
62
|
body: Dict[str, Any] = dict(payload or {})
|
|
@@ -63,6 +64,8 @@ def build_envelope(
|
|
|
63
64
|
body["tags"] = tags
|
|
64
65
|
if extra:
|
|
65
66
|
body["extra"] = extra
|
|
67
|
+
if commit_hash:
|
|
68
|
+
body["commit_hash"] = commit_hash
|
|
66
69
|
return {
|
|
67
70
|
"kind": kind,
|
|
68
71
|
"level": level,
|
insider/_version.py
CHANGED
insider/client.py
CHANGED
|
@@ -16,6 +16,7 @@ from __future__ import annotations
|
|
|
16
16
|
|
|
17
17
|
import atexit
|
|
18
18
|
import os
|
|
19
|
+
import subprocess
|
|
19
20
|
import threading
|
|
20
21
|
from typing import Any, Callable, Dict, Iterable, List, Optional
|
|
21
22
|
|
|
@@ -95,6 +96,23 @@ class Client:
|
|
|
95
96
|
queue_size=transport_queue_size,
|
|
96
97
|
flush_timeout=transport_flush_timeout,
|
|
97
98
|
)
|
|
99
|
+
self.commit_hash: Optional[str] = self._get_commit_hash()
|
|
100
|
+
|
|
101
|
+
# Zero-config release tracking: if no release is provided, fallback to the git commit hash
|
|
102
|
+
if not release and self.commit_hash:
|
|
103
|
+
release = self.commit_hash
|
|
104
|
+
self.scope.static.release = release
|
|
105
|
+
|
|
106
|
+
def _get_commit_hash(self) -> Optional[str]:
|
|
107
|
+
try:
|
|
108
|
+
output = subprocess.check_output(
|
|
109
|
+
["git", "rev-parse", "HEAD"],
|
|
110
|
+
stderr=subprocess.DEVNULL,
|
|
111
|
+
text=True,
|
|
112
|
+
).strip()
|
|
113
|
+
return output if output else None
|
|
114
|
+
except Exception:
|
|
115
|
+
return None
|
|
98
116
|
|
|
99
117
|
# ------------------------------------------------------------------
|
|
100
118
|
# Capture
|
|
@@ -133,6 +151,7 @@ class Client:
|
|
|
133
151
|
environment=self.scope.static.environment,
|
|
134
152
|
release=self.scope.static.release,
|
|
135
153
|
trace_id=trace_id,
|
|
154
|
+
commit_hash=self.commit_hash,
|
|
136
155
|
payload=payload,
|
|
137
156
|
tags=tags,
|
|
138
157
|
extra=extra,
|
|
@@ -169,6 +188,7 @@ class Client:
|
|
|
169
188
|
environment=self.scope.static.environment,
|
|
170
189
|
release=self.scope.static.release,
|
|
171
190
|
trace_id=trace_id,
|
|
191
|
+
commit_hash=self.commit_hash,
|
|
172
192
|
payload=payload,
|
|
173
193
|
tags=tags,
|
|
174
194
|
extra=extra,
|
insider/stacktrace.py
CHANGED
|
@@ -62,18 +62,28 @@ def extract_frames(
|
|
|
62
62
|
"""
|
|
63
63
|
frames: List[Dict[str, Any]] = []
|
|
64
64
|
walked = 0
|
|
65
|
+
cwd = os.getcwd()
|
|
65
66
|
while tb is not None and walked < max_frames:
|
|
66
67
|
try:
|
|
67
68
|
frame = tb.tb_frame
|
|
68
69
|
code = frame.f_code
|
|
69
70
|
filename = code.co_filename
|
|
71
|
+
|
|
72
|
+
frame_in_app = is_in_app(filename, in_app_include)
|
|
73
|
+
|
|
74
|
+
if filename and filename.startswith(cwd):
|
|
75
|
+
try:
|
|
76
|
+
filename = os.path.relpath(filename, cwd)
|
|
77
|
+
except ValueError:
|
|
78
|
+
pass
|
|
79
|
+
|
|
70
80
|
frames.append(
|
|
71
81
|
{
|
|
72
82
|
"filename": filename,
|
|
73
83
|
"function": code.co_name,
|
|
74
84
|
"module": frame.f_globals.get("__name__", ""),
|
|
75
85
|
"lineno": tb.tb_lineno,
|
|
76
|
-
"in_app":
|
|
86
|
+
"in_app": frame_in_app,
|
|
77
87
|
}
|
|
78
88
|
)
|
|
79
89
|
except Exception as exc:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: insider-python
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Python SDK for Insider — ship Beacons to your Insider server.
|
|
5
5
|
Author: Insider
|
|
6
6
|
License-Expression: MIT
|
|
@@ -9,12 +9,13 @@ Keywords: insider,telemetry,errors,monitoring,sdk
|
|
|
9
9
|
Classifier: Development Status :: 3 - Alpha
|
|
10
10
|
Classifier: Intended Audience :: Developers
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
12
13
|
Classifier: Programming Language :: Python :: 3.9
|
|
13
14
|
Classifier: Programming Language :: Python :: 3.10
|
|
14
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
17
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
|
-
Requires-Python: >=3.
|
|
18
|
+
Requires-Python: >=3.8
|
|
18
19
|
Description-Content-Type: text/markdown
|
|
19
20
|
Requires-Dist: urllib3>=1.26
|
|
20
21
|
Provides-Extra: django
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
insider/__init__.py,sha256=DgDevX2wcy9lonZiHaq5dJLieD3_fp3p6l3lotuTpGE,781
|
|
2
|
-
insider/_envelope.py,sha256=
|
|
3
|
-
insider/_version.py,sha256=
|
|
4
|
-
insider/client.py,sha256=
|
|
2
|
+
insider/_envelope.py,sha256=mZiNl-Cha4piAhbIgFuU_KOZnaK4GMrYquFJxLn0D5Q,6684
|
|
3
|
+
insider/_version.py,sha256=lxOKSZJbU9hAXhlPRaq8AWb80mXq8wTnJsQhaOYn7ao,246
|
|
4
|
+
insider/client.py,sha256=qLl7iQQ1N4zygXisGxOOyXNkq16UuWozhEHPGK_24Xs,11540
|
|
5
5
|
insider/dsn.py,sha256=S8BbRhmKKKU1N6W8cpMSQoyDO_EuUJ1PkcjhGrrf5hw,3009
|
|
6
6
|
insider/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
insider/safety.py,sha256=mtzzWLujuvmd24W2VtVcMGO_81GPBbB2tYuVqU2KsuI,1910
|
|
8
8
|
insider/scope.py,sha256=F1eMWt6uu14uBdncc5DC6Lh735EPcUv1yF4prBi--pc,1708
|
|
9
9
|
insider/scrubbing.py,sha256=U8N3MS5VtDUNpIWN4PZ8bvrPqmjRRXq5hWGXxzoF5Gw,2853
|
|
10
|
-
insider/stacktrace.py,sha256=
|
|
10
|
+
insider/stacktrace.py,sha256=tgdS9dQ-bVyz59_874BstuCYaP6rGn2k6HMo9sW8Ks8,5310
|
|
11
11
|
insider/transport.py,sha256=8ncFb3C0LgF2hMRoj_fhxj49NIUD6hsVAHfPZKtNcn4,7292
|
|
12
12
|
insider/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
insider/contrib/django/__init__.py,sha256=UMGrJgVO-FqszZo9Cviw7oWS8PLdXVHt3hwXZ_YMj8A,680
|
|
14
14
|
insider/contrib/django/apps.py,sha256=WOKn-fNp_SSPNyt8xXz_fXYVhkyepafAi1uxpWC9_Bo,1947
|
|
15
15
|
insider/contrib/django/middleware.py,sha256=JWnP_p4JBGyKQMswevjWxoUBSE5o4xgLKYOm1Zrb30g,5365
|
|
16
|
-
insider_python-0.1.
|
|
17
|
-
insider_python-0.1.
|
|
18
|
-
insider_python-0.1.
|
|
19
|
-
insider_python-0.1.
|
|
16
|
+
insider_python-0.1.2.dist-info/METADATA,sha256=ag7XgxFizqFCl4TuPkSlcid8kCp3qvdj6dzyj5Kr0bM,3581
|
|
17
|
+
insider_python-0.1.2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
18
|
+
insider_python-0.1.2.dist-info/top_level.txt,sha256=g_YKp2jCaaefmasZ2nOa9capm0X8q2sAWI_eEClKIos,8
|
|
19
|
+
insider_python-0.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|