No project description provided
Project description
Initial version of the sentry rest API client, with reporting generation. This software is not production ready, and may greatly change in the future.
Usage examples
First you need to get auth token, organization and project name.
To get auth token check this documentation:
Auth Tokens.
Don't forget to allow at least read access for Issues & Events.
organization and project name you can find in sentry UI.
https://<your_organization>.sentry.io/projects/ - here you can find required
project.
export SENTRY_AUTH_TOKEN=...
export SENTRY_ORGANIZATION=my_org
export SENTRY_PROJECT=my_project
Then you can use this package to interact with sentry API.
from os import environ
import asyncio
from sentry_rest import SentryClient
sentry_client = SentryClient(
auth_token=environ["SENTRY_AUTH_TOKEN"],
auth_organization=environ["SENTRY_ORGANIZATION"],
auth_project=environ["SENTRY_PROJECT"],
search_query="Proxy error detected",
tracing_enabled=False, # toggle aiohttp requests information
)
# Filter issues with `search_query` and print their event ids
print([event["id"] for event in asyncio.run(sentry_client.extract())])
# TODO: explain which fields are available in event
More complex example, with grouping by proxy IP
and time range aviable in examples directory. But it can not work for you,
because it's relays on specific messages format.
TODO: add more examples, which may work everywhere.
My main usage (current one) of this package is to generate reports for groups of specific errors, here is an example how to use it to group proxy-related issues and events by specific time range (14 days by default).
# Run example from your directory (copy it to your project root)
python proxy_errors.py
# If you want to run example from package root directory, use this command:
PYTHONPATH=. python examples/proxy_errors.py
For me this example will generate report like this:
Proxy checking report (2 weeks), timezone is UTC
========================================
[Proxy: 111.111.111.111 Total erors: 5] <!-- group by proxy -->
2024-09-04: 3 errors <!-- group by day -->
02:18:20 >> ProxyCheckError
--------🕐-------- <!-- group by hour -->
06:18:20 >> ProxyCheckError
--------🕐--------
10:18:20 >> ProxyCheckError
2024-09-03: 2 errors
18:18:20 >> ProxyCheckError
--------🕐--------
22:18:20 >> ProxyCheckError
========================================
[Proxy: 111.111.111.111 Total erors: 39]
2024-09-04: 3 errors
02:18:20 >> ProxyCheckError
--------🕐--------
06:18:20 >> ProxyCheckError
--------🕐--------
10:18:20 >> ProxyCheckError
2024-09-03: 36 errors
14:36:32 >> APIError_fetch_data
14:36:33 >> APIError_fetch_data
14:36:34 >> APIError_fetch_data
14:36:36 >> APIError_fetch_data
14:36:37 >> APIError_fetch_data
14:36:38 >> APIError_fetch_data
14:36:52 >> initialize_api
--------🕐--------
18:13:12 >> APIError_fetch_data
18:13:13 >> APIError_fetch_data
18:13:14 >> APIError_fetch_data
18:13:15 >> APIError_fetch_data
18:13:18 >> APIError_fetch_data
18:13:32 >> APIError_fetch_data
18:13:32 >> initialize_api
18:18:20 >> ProxyCheckError
18:58:11 >> APIError_fetch_data
18:58:12 >> APIError_fetch_data
18:58:13 >> APIError_fetch_data
18:58:15 >> APIError_fetch_data
18:58:20 >> APIError_fetch_data
18:58:31 >> initialize_api
--------🕐--------
19:56:58 >> APIError_fetch_data
19:56:58 >> APIError_fetch_data
19:56:59 >> APIError_fetch_data
19:57:02 >> APIError_fetch_data
19:57:11 >> APIError_fetch_data
19:57:17 >> APIError_fetch_data
19:57:18 >> initialize_api
20:01:57 >> APIError_fetch_data
20:01:58 >> APIError_fetch_data
20:01:59 >> APIError_fetch_data
20:02:00 >> APIError_fetch_data
20:02:04 >> APIError_fetch_data
20:02:06 >> APIError_fetch_data
20:02:17 >> initialize_api
--------🕐--------
22:18:20 >> ProxyCheckError
========================================
[Proxy: 111.111.111.111 Total erors: 5]
2024-09-04: 3 errors
01:31:38 >> APIError_fetch_data
--------🕐--------
09:01:08 >> APIError_fetch_data
09:38:20 >> APIError_fetch_data
2024-09-03: 2 errors
22:03:20 >> APIError_fetch_data
22:03:39 >> APIError_fetch_data
========================================
Features
- Built with
asyncioandaiohttp, we get sentry events concurrently. - Used
backoffpackage to retry failed requests.
Limitations
Right now we don't support many sentry API endpoints. And this package right
now focused on Issues & Events API.
Dependencies
- aiohttp
- backoff
To-do
- verify and fix types
- add tests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sentry_rest-0.0.4.tar.gz.
File metadata
- Download URL: sentry_rest-0.0.4.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33f27cc98d495a8f09a0ae7b2c432dc9c9d6216d02a8edda86a5ba5a3be12b07
|
|
| MD5 |
6f959b99add8bbf394047bb8208142de
|
|
| BLAKE2b-256 |
952b9fd91393af7828d26518e1f19ab45cd2471d15572041d549d288860e6aa2
|
File details
Details for the file sentry_rest-0.0.4-py3-none-any.whl.
File metadata
- Download URL: sentry_rest-0.0.4-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60b34b86dce4f9c52aca158655351077ffe3887d6ab91f7a4727559bd0028366
|
|
| MD5 |
0a733944f52440f5be6a313264c31ce1
|
|
| BLAKE2b-256 |
b1c25663dc0aaf767291e73f8de536d321a27a5464287c5db3186eecfbefda3c
|