askrobots / foxray Public

Foxray: a light error tracker for the Sentry SDKs. Runs inside Django (the admin is the UI) or on its own; SQLite or Postgres, nothing else. Not affiliated with Sentry.

0 downloads

foxray/tests/sdk_any_client.py
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/foxray.git
HTTPS
https://gitstable.com/git/askrobots/foxray.git
SSH
ssh://git@gitstable.com:2222/askrobots/foxray.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 0.1.2: the first PyPI release (v0.1.1 is already tagged at 05cc354, before the PyPI metadata) 58507e3 4 weeks ago History
sdk_any_client.py · 877 bytes · 31 lines
1"""A client that works on sentry-sdk 1.x and 2.x: errors and messages only (no crons, no new_scope).
2
3 python tests/sdk_any_client.py <dsn> prints the reported ids as JSON on the last line"""
4
5import json
6import sys
7
8import sentry_sdk
9
10
11def checkout(n):
12 return 10 / n
13
14
15def main(dsn: str) -> None:
16 sentry_sdk.init(dsn=dsn, traces_sample_rate=0, release="shop@1.0.0", environment="test")
17 ids = {"exc": []}
18 for _ in range(2):
19 try:
20 checkout(0)
21 except ZeroDivisionError as e:
22 ids["exc"].append(sentry_sdk.capture_exception(e))
23 with sentry_sdk.push_scope() as scope:
24 scope.set_tag("tenant", "acme")
25 ids["msg"] = sentry_sdk.capture_message("Payment provider slow: 1234 ms", level="warning")
26 sentry_sdk.flush(timeout=10)
27 print(json.dumps(ids))
28
29
30if __name__ == "__main__":
31 main(sys.argv[1])