veghe-sdk 1.0.0__tar.gz
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.
- veghe_sdk-1.0.0/LICENSE +21 -0
- veghe_sdk-1.0.0/PKG-INFO +65 -0
- veghe_sdk-1.0.0/README.md +43 -0
- veghe_sdk-1.0.0/pyproject.toml +30 -0
- veghe_sdk-1.0.0/setup.cfg +4 -0
- veghe_sdk-1.0.0/veghe_sdk.egg-info/PKG-INFO +65 -0
- veghe_sdk-1.0.0/veghe_sdk.egg-info/SOURCES.txt +8 -0
- veghe_sdk-1.0.0/veghe_sdk.egg-info/dependency_links.txt +1 -0
- veghe_sdk-1.0.0/veghe_sdk.egg-info/top_level.txt +1 -0
- veghe_sdk-1.0.0/veghe_sdk.py +177 -0
veghe_sdk-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Veghe.ro
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
veghe_sdk-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: veghe-sdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Veghe SDK for Python — minimal, dependency-free error reporting to Veghe.ro
|
|
5
|
+
Author-email: "Veghe.ro" <admin@veghe.ro>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://veghe.ro/en/features/error-tracking
|
|
8
|
+
Project-URL: Documentation, https://veghe.ro/docs/error-tracking/
|
|
9
|
+
Project-URL: Dashboard, https://i.veghe.ro
|
|
10
|
+
Keywords: error-tracking,monitoring,exceptions,veghe,crash-reporting
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Topic :: System :: Monitoring
|
|
17
|
+
Classifier: Topic :: Software Development :: Bug Tracking
|
|
18
|
+
Requires-Python: >=3.8
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# veghe-sdk
|
|
24
|
+
|
|
25
|
+
Minimal, dependency-free error reporting for Python apps, sending to
|
|
26
|
+
[Veghe.ro](https://veghe.ro) error tracking. One module, stdlib only.
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install veghe-sdk
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Use
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import veghe_sdk
|
|
38
|
+
|
|
39
|
+
veghe_sdk.init(
|
|
40
|
+
"https://<key>@i.veghe.ro/<project-id>", # your project DSN
|
|
41
|
+
release="myapp@1.4.2", # enables regression detection
|
|
42
|
+
environment="production",
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# Uncaught exceptions are now reported automatically. You can also:
|
|
46
|
+
veghe_sdk.capture_exception() # inside an except block
|
|
47
|
+
veghe_sdk.capture_message("webhook lagging", level="warning")
|
|
48
|
+
veghe_sdk.set_tag("region", "eu-central")
|
|
49
|
+
veghe_sdk.set_user({"email": "user@example.com"})
|
|
50
|
+
|
|
51
|
+
# For short-lived scripts, flush before exit:
|
|
52
|
+
veghe_sdk.flush()
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Events are sent on background threads and failures are swallowed —
|
|
56
|
+
monitoring never breaks the app it watches.
|
|
57
|
+
|
|
58
|
+
Get a DSN by creating an error project in your
|
|
59
|
+
[Veghe dashboard](https://i.veghe.ro) under **Errors**. Grouped issues,
|
|
60
|
+
stack traces with code context, releases and regression detection,
|
|
61
|
+
threshold alerts and JS source maps are documented in the
|
|
62
|
+
[error tracking docs](https://veghe.ro/docs/error-tracking/).
|
|
63
|
+
|
|
64
|
+
Veghe also speaks the Sentry ingestion protocol, so official Sentry SDKs
|
|
65
|
+
(any platform) work against the same DSN.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# veghe-sdk
|
|
2
|
+
|
|
3
|
+
Minimal, dependency-free error reporting for Python apps, sending to
|
|
4
|
+
[Veghe.ro](https://veghe.ro) error tracking. One module, stdlib only.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pip install veghe-sdk
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Use
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
import veghe_sdk
|
|
16
|
+
|
|
17
|
+
veghe_sdk.init(
|
|
18
|
+
"https://<key>@i.veghe.ro/<project-id>", # your project DSN
|
|
19
|
+
release="myapp@1.4.2", # enables regression detection
|
|
20
|
+
environment="production",
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# Uncaught exceptions are now reported automatically. You can also:
|
|
24
|
+
veghe_sdk.capture_exception() # inside an except block
|
|
25
|
+
veghe_sdk.capture_message("webhook lagging", level="warning")
|
|
26
|
+
veghe_sdk.set_tag("region", "eu-central")
|
|
27
|
+
veghe_sdk.set_user({"email": "user@example.com"})
|
|
28
|
+
|
|
29
|
+
# For short-lived scripts, flush before exit:
|
|
30
|
+
veghe_sdk.flush()
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Events are sent on background threads and failures are swallowed —
|
|
34
|
+
monitoring never breaks the app it watches.
|
|
35
|
+
|
|
36
|
+
Get a DSN by creating an error project in your
|
|
37
|
+
[Veghe dashboard](https://i.veghe.ro) under **Errors**. Grouped issues,
|
|
38
|
+
stack traces with code context, releases and regression detection,
|
|
39
|
+
threshold alerts and JS source maps are documented in the
|
|
40
|
+
[error tracking docs](https://veghe.ro/docs/error-tracking/).
|
|
41
|
+
|
|
42
|
+
Veghe also speaks the Sentry ingestion protocol, so official Sentry SDKs
|
|
43
|
+
(any platform) work against the same DSN.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "veghe-sdk"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Veghe SDK for Python — minimal, dependency-free error reporting to Veghe.ro"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
authors = [{ name = "Veghe.ro", email = "admin@veghe.ro" }]
|
|
12
|
+
requires-python = ">=3.8"
|
|
13
|
+
keywords = ["error-tracking", "monitoring", "exceptions", "veghe", "crash-reporting"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 5 - Production/Stable",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Topic :: System :: Monitoring",
|
|
21
|
+
"Topic :: Software Development :: Bug Tracking",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Homepage = "https://veghe.ro/en/features/error-tracking"
|
|
26
|
+
Documentation = "https://veghe.ro/docs/error-tracking/"
|
|
27
|
+
Dashboard = "https://i.veghe.ro"
|
|
28
|
+
|
|
29
|
+
[tool.setuptools]
|
|
30
|
+
py-modules = ["veghe_sdk"]
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: veghe-sdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Veghe SDK for Python — minimal, dependency-free error reporting to Veghe.ro
|
|
5
|
+
Author-email: "Veghe.ro" <admin@veghe.ro>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://veghe.ro/en/features/error-tracking
|
|
8
|
+
Project-URL: Documentation, https://veghe.ro/docs/error-tracking/
|
|
9
|
+
Project-URL: Dashboard, https://i.veghe.ro
|
|
10
|
+
Keywords: error-tracking,monitoring,exceptions,veghe,crash-reporting
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Topic :: System :: Monitoring
|
|
17
|
+
Classifier: Topic :: Software Development :: Bug Tracking
|
|
18
|
+
Requires-Python: >=3.8
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# veghe-sdk
|
|
24
|
+
|
|
25
|
+
Minimal, dependency-free error reporting for Python apps, sending to
|
|
26
|
+
[Veghe.ro](https://veghe.ro) error tracking. One module, stdlib only.
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install veghe-sdk
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Use
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import veghe_sdk
|
|
38
|
+
|
|
39
|
+
veghe_sdk.init(
|
|
40
|
+
"https://<key>@i.veghe.ro/<project-id>", # your project DSN
|
|
41
|
+
release="myapp@1.4.2", # enables regression detection
|
|
42
|
+
environment="production",
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# Uncaught exceptions are now reported automatically. You can also:
|
|
46
|
+
veghe_sdk.capture_exception() # inside an except block
|
|
47
|
+
veghe_sdk.capture_message("webhook lagging", level="warning")
|
|
48
|
+
veghe_sdk.set_tag("region", "eu-central")
|
|
49
|
+
veghe_sdk.set_user({"email": "user@example.com"})
|
|
50
|
+
|
|
51
|
+
# For short-lived scripts, flush before exit:
|
|
52
|
+
veghe_sdk.flush()
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Events are sent on background threads and failures are swallowed —
|
|
56
|
+
monitoring never breaks the app it watches.
|
|
57
|
+
|
|
58
|
+
Get a DSN by creating an error project in your
|
|
59
|
+
[Veghe dashboard](https://i.veghe.ro) under **Errors**. Grouped issues,
|
|
60
|
+
stack traces with code context, releases and regression detection,
|
|
61
|
+
threshold alerts and JS source maps are documented in the
|
|
62
|
+
[error tracking docs](https://veghe.ro/docs/error-tracking/).
|
|
63
|
+
|
|
64
|
+
Veghe also speaks the Sentry ingestion protocol, so official Sentry SDKs
|
|
65
|
+
(any platform) work against the same DSN.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
veghe_sdk
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"""Veghe SDK for Python — minimal, dependency-free error reporting.
|
|
2
|
+
|
|
3
|
+
Usage:
|
|
4
|
+
import veghe_sdk
|
|
5
|
+
veghe_sdk.init(
|
|
6
|
+
"https://<key>@i.veghe.ro/<project-id>",
|
|
7
|
+
release="myapp@1.4.2",
|
|
8
|
+
environment="production",
|
|
9
|
+
)
|
|
10
|
+
# uncaught exceptions are now reported automatically, or:
|
|
11
|
+
veghe_sdk.capture_exception()
|
|
12
|
+
veghe_sdk.capture_message("payment webhook lagging", level="warning")
|
|
13
|
+
|
|
14
|
+
Single file, stdlib only. Events are sent on a background thread and
|
|
15
|
+
never raise: monitoring must not break the app it watches.
|
|
16
|
+
Download: https://i.veghe.ro/app/static/sdk/veghe_sdk.py
|
|
17
|
+
"""
|
|
18
|
+
import json
|
|
19
|
+
import linecache
|
|
20
|
+
import sys
|
|
21
|
+
import threading
|
|
22
|
+
import traceback
|
|
23
|
+
import urllib.request
|
|
24
|
+
import uuid
|
|
25
|
+
from datetime import datetime, timezone
|
|
26
|
+
|
|
27
|
+
__version__ = "1.0.0"
|
|
28
|
+
|
|
29
|
+
_config = None
|
|
30
|
+
_previous_excepthook = None
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def init(dsn, release=None, environment=None, tags=None, install_excepthook=True, timeout=5):
|
|
34
|
+
"""Configure the SDK. dsn: https://<key>@<host>/<project-id>."""
|
|
35
|
+
global _config, _previous_excepthook
|
|
36
|
+
scheme, rest = dsn.split("://", 1)
|
|
37
|
+
key, host_part = rest.split("@", 1)
|
|
38
|
+
host, project_id = host_part.rsplit("/", 1)
|
|
39
|
+
_config = {
|
|
40
|
+
"endpoint": f"{scheme}://{host}/api/{project_id}/store/?sentry_key={key.split(':')[0]}",
|
|
41
|
+
"release": release,
|
|
42
|
+
"environment": environment,
|
|
43
|
+
"tags": dict(tags or {}),
|
|
44
|
+
"user": None,
|
|
45
|
+
"timeout": timeout,
|
|
46
|
+
}
|
|
47
|
+
if install_excepthook and _previous_excepthook is None:
|
|
48
|
+
_previous_excepthook = sys.excepthook
|
|
49
|
+
sys.excepthook = _excepthook
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def set_tag(key, value):
|
|
53
|
+
if _config is not None:
|
|
54
|
+
_config["tags"][str(key)] = str(value)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def set_user(user):
|
|
58
|
+
"""user: dict with any of id, username, email, ip_address."""
|
|
59
|
+
if _config is not None:
|
|
60
|
+
_config["user"] = user
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def capture_exception(exc=None, tags=None):
|
|
64
|
+
"""Report an exception (defaults to the one currently being handled)."""
|
|
65
|
+
if _config is None:
|
|
66
|
+
return None
|
|
67
|
+
if exc is not None:
|
|
68
|
+
exc_info = (type(exc), exc, exc.__traceback__)
|
|
69
|
+
else:
|
|
70
|
+
exc_info = sys.exc_info()
|
|
71
|
+
if exc_info[0] is None:
|
|
72
|
+
return None
|
|
73
|
+
event = _base_event(tags)
|
|
74
|
+
event["exception"] = {"values": [_exception_value(*exc_info)]}
|
|
75
|
+
return _send(event)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def capture_message(message, level="info", tags=None):
|
|
79
|
+
if _config is None:
|
|
80
|
+
return None
|
|
81
|
+
event = _base_event(tags)
|
|
82
|
+
event["message"] = str(message)
|
|
83
|
+
event["level"] = level
|
|
84
|
+
return _send(event)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def flush(timeout=5):
|
|
88
|
+
"""Wait for in-flight sends (call before exiting short-lived scripts)."""
|
|
89
|
+
for thread in list(_threads):
|
|
90
|
+
thread.join(timeout)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _excepthook(exc_type, exc_value, exc_tb):
|
|
94
|
+
try:
|
|
95
|
+
if _config is not None:
|
|
96
|
+
event = _base_event(None)
|
|
97
|
+
event["level"] = "fatal"
|
|
98
|
+
event["exception"] = {"values": [_exception_value(exc_type, exc_value, exc_tb)]}
|
|
99
|
+
_send(event)
|
|
100
|
+
flush(_config["timeout"])
|
|
101
|
+
finally:
|
|
102
|
+
(_previous_excepthook or sys.__excepthook__)(exc_type, exc_value, exc_tb)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _base_event(tags):
|
|
106
|
+
event = {
|
|
107
|
+
"event_id": uuid.uuid4().hex,
|
|
108
|
+
"timestamp": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
|
|
109
|
+
"platform": "python",
|
|
110
|
+
"level": "error",
|
|
111
|
+
"sdk": {"name": "veghe-python", "version": __version__},
|
|
112
|
+
"server_name": _safe_hostname(),
|
|
113
|
+
"tags": {**_config["tags"], **(tags or {})},
|
|
114
|
+
}
|
|
115
|
+
if _config["release"]:
|
|
116
|
+
event["release"] = _config["release"]
|
|
117
|
+
if _config["environment"]:
|
|
118
|
+
event["environment"] = _config["environment"]
|
|
119
|
+
if _config["user"]:
|
|
120
|
+
event["user"] = _config["user"]
|
|
121
|
+
return event
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def _exception_value(exc_type, exc_value, exc_tb):
|
|
125
|
+
frames = []
|
|
126
|
+
for frame, lineno in traceback.walk_tb(exc_tb):
|
|
127
|
+
filename = frame.f_code.co_filename
|
|
128
|
+
in_app = not ("site-packages" in filename or "dist-packages" in filename
|
|
129
|
+
or filename.startswith(sys.prefix))
|
|
130
|
+
frames.append({
|
|
131
|
+
"filename": filename,
|
|
132
|
+
"function": frame.f_code.co_name,
|
|
133
|
+
"module": frame.f_globals.get("__name__"),
|
|
134
|
+
"lineno": lineno,
|
|
135
|
+
"context_line": linecache.getline(filename, lineno).rstrip() or None,
|
|
136
|
+
"pre_context": [linecache.getline(filename, l).rstrip()
|
|
137
|
+
for l in range(max(1, lineno - 5), lineno)],
|
|
138
|
+
"post_context": [linecache.getline(filename, l).rstrip()
|
|
139
|
+
for l in range(lineno + 1, lineno + 6)],
|
|
140
|
+
"in_app": in_app,
|
|
141
|
+
})
|
|
142
|
+
return {
|
|
143
|
+
"type": getattr(exc_type, "__name__", str(exc_type)),
|
|
144
|
+
"value": str(exc_value),
|
|
145
|
+
"stacktrace": {"frames": frames} if frames else None,
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def _safe_hostname():
|
|
150
|
+
try:
|
|
151
|
+
import socket
|
|
152
|
+
return socket.gethostname()
|
|
153
|
+
except Exception:
|
|
154
|
+
return None
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
_threads = []
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def _send(event):
|
|
161
|
+
def _post():
|
|
162
|
+
try:
|
|
163
|
+
request = urllib.request.Request(
|
|
164
|
+
_config["endpoint"],
|
|
165
|
+
data=json.dumps(event, default=str).encode("utf-8"),
|
|
166
|
+
headers={"Content-Type": "application/json"},
|
|
167
|
+
)
|
|
168
|
+
urllib.request.urlopen(request, timeout=_config["timeout"]).read()
|
|
169
|
+
except Exception:
|
|
170
|
+
pass # never let monitoring break the app
|
|
171
|
+
|
|
172
|
+
thread = threading.Thread(target=_post, daemon=True)
|
|
173
|
+
thread.start()
|
|
174
|
+
_threads.append(thread)
|
|
175
|
+
if len(_threads) > 32:
|
|
176
|
+
del _threads[:-32]
|
|
177
|
+
return event["event_id"]
|