feat(clients): add Python, Go, and Java client libraries (BIT-14250)
Zero-dependency clients for errors.bitreport.pt following the same patterns as clients/node and clients/php: batch size 25, 5 s flush interval, 8 s HTTP timeout, fire-and-forget, env-var config. Each client ships with unit tests backed by an embedded HTTP server (no mocks), an example file, and a build manifest (pyproject.toml, go.mod, pom.xml). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
1 parent
8bb49ce32b
commit
da57d2a444
12 files changed
+1653
No files matched your search
@@ -0,0 +1,36 @@
|
||||
"""
|
||||
Basic usage example for the BitReport Python error reporter.
|
||||
|
||||
Run with:
|
||||
ERROR_REPORTING_TOKEN=your_token python basic_usage.py
|
||||
"""
|
||||
|
||||
import atexit
|
||||
import os
|
||||
|
||||
from error_reporter import flush, init_reporter, report_error, report_message
|
||||
|
||||
init_reporter(
|
||||
token=os.environ.get("ERROR_REPORTING_TOKEN", ""),
|
||||
project_name="My Python App",
|
||||
project_slug="my-python-app",
|
||||
)
|
||||
|
||||
# Flush before the process exits so queued events are not lost
|
||||
atexit.register(flush)
|
||||
|
||||
# Report a plain message
|
||||
report_message("Application started", level="info")
|
||||
|
||||
# Report a warning with extra context
|
||||
report_message("Cache miss", level="warning", context={"cache_key": "user:42"})
|
||||
|
||||
# Report an exception caught in a try/except
|
||||
try:
|
||||
result = 1 / 0
|
||||
except ZeroDivisionError as e:
|
||||
report_error(e, {"operation": "divide", "numerator": 1, "denominator": 0})
|
||||
|
||||
# Flush immediately so the example does not exit before events are sent
|
||||
flush()
|
||||
print("Events sent. Check your errors.bitreport.pt dashboard.")
|
||||
Reference in new issue
Block a user