afen-client 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.
- afen_client-1.0.0/PKG-INFO +9 -0
- afen_client-1.0.0/README.md +118 -0
- afen_client-1.0.0/afen_client.egg-info/PKG-INFO +9 -0
- afen_client-1.0.0/afen_client.egg-info/SOURCES.txt +8 -0
- afen_client-1.0.0/afen_client.egg-info/dependency_links.txt +1 -0
- afen_client-1.0.0/afen_client.egg-info/requires.txt +1 -0
- afen_client-1.0.0/afen_client.egg-info/top_level.txt +1 -0
- afen_client-1.0.0/pyproject.toml +10 -0
- afen_client-1.0.0/setup.cfg +4 -0
- afen_client-1.0.0/setup.py +17 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Afen Python SDK
|
|
2
|
+
|
|
3
|
+
Capture runtime errors and send them to an Afen instance.
|
|
4
|
+
|
|
5
|
+
- Automatic capture of unhandled exceptions via `sys.excepthook`
|
|
6
|
+
- Manual capture with optional context
|
|
7
|
+
- Async support
|
|
8
|
+
- Django middleware integration
|
|
9
|
+
- Python ≥ 3.8, zero heavy dependencies
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install afen-client
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from afen.client import AfenClient
|
|
25
|
+
|
|
26
|
+
client = AfenClient(
|
|
27
|
+
api_url="http://localhost:3000",
|
|
28
|
+
api_key="your-api-token",
|
|
29
|
+
service_name="my-service",
|
|
30
|
+
)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
That's it. A global `sys.excepthook` is registered automatically — all unhandled exceptions are forwarded to Afen without any further setup.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Manual Capture
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
try:
|
|
41
|
+
process_payment(payload)
|
|
42
|
+
except Exception as e:
|
|
43
|
+
client.capture(e, context={"order_id": payload["id"]})
|
|
44
|
+
raise
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Async Support
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
async def handler(request):
|
|
53
|
+
try:
|
|
54
|
+
await process_payment(payload)
|
|
55
|
+
except Exception as e:
|
|
56
|
+
await client.capture_async(e, context={"order_id": payload["id"]})
|
|
57
|
+
raise
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Disable Auto-Capture
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
client = AfenClient(
|
|
66
|
+
api_url="http://localhost:3000",
|
|
67
|
+
api_key="your-api-token",
|
|
68
|
+
service_name="my-service",
|
|
69
|
+
auto_capture=False,
|
|
70
|
+
)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Django Integration
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
# settings.py
|
|
79
|
+
MIDDLEWARE = [
|
|
80
|
+
"afen.integrations.django.AfenMiddleware",
|
|
81
|
+
...
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
AFEN = {
|
|
85
|
+
"API_URL": "http://localhost:3000",
|
|
86
|
+
"API_KEY": "your-api-token",
|
|
87
|
+
"SERVICE_NAME": "my-django-app",
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Captures all unhandled Django exceptions and attaches `request.path`, `request.method`, and response status as context.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Configuration
|
|
96
|
+
|
|
97
|
+
| Parameter | Type | Required | Default | Description |
|
|
98
|
+
|---|---|---|---|---|
|
|
99
|
+
| `api_url` | `str` | ✓ | — | Afen server URL |
|
|
100
|
+
| `api_key` | `str` | ✓ | — | API key |
|
|
101
|
+
| `service_name` | `str` | ✓ | — | Identifies the source service |
|
|
102
|
+
| `environment` | `str` | | `"development"` | Deployment environment |
|
|
103
|
+
| `release` | `str` | | `None` | Release or version tag |
|
|
104
|
+
| `auto_capture` | `bool` | | `True` | Register global exception hook |
|
|
105
|
+
| `timeout` | `int` | | `5` | Request timeout in seconds |
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Requirements
|
|
110
|
+
|
|
111
|
+
- Python ≥ 3.8
|
|
112
|
+
- `requests` ≥ 2.28.0
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
MIT © Anamn
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests>=2.28.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "afen-client"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Afen Python SDK – capture and send runtime errors to Afen"
|
|
9
|
+
requires-python = ">=3.8"
|
|
10
|
+
dependencies = ["requests>=2.28.0"]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="afen",
|
|
5
|
+
version="1.0.1",
|
|
6
|
+
description="Afen Python SDK – capture and send runtime errors to Afen",
|
|
7
|
+
packages=find_packages(),
|
|
8
|
+
install_requires=["requests>=2.28.0"],
|
|
9
|
+
python_requires=">=3.8",
|
|
10
|
+
author="Afen Contributors",
|
|
11
|
+
license="MIT",
|
|
12
|
+
entry_points={
|
|
13
|
+
"console_scripts": [
|
|
14
|
+
"afen = afen.cli:main",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
)
|