stacktrace-sdk-python
Python SDK for the Artim Stacktrace backend. This package provides basic error reporting and event capture utilities similar to the existing React SDK.
Usage
from bug_sdk_python import ArtimStacktrace
ArtimStacktrace.init(
api_key="your-api-key",
project_id="your-project-id",
)
ArtimStacktrace.capture_message("Something went wrong", level="warn")
try:
1 / 0
except Exception as error:
ArtimStacktrace.capture_exception(error)
ArtimStacktrace.set_user({"id": "123", "email": "user@example.com"})
# Or identify by callback
ArtimStacktrace.identify(lambda: {"id": "123", "email": "user@example.com"})
Features
initsets API key, project id, environment, release, and backend endpointcapture_exceptionsends exception details and stacktracecapture_messagesends simple event messagesset_userandidentifyattach user context to events- default backend endpoint:
https://stacktrace-backend.artim-industries.com/api/events
Using with FastAPI
add this to main.py
@app.middleware("http")
async def artim_middleware(request: Request, call_next):
try:
response = await call_next(request)
return response
except Exception as e:
capture_exception(e)
raise
Environment detection
One project holds several environments (development, staging, production,
plus any custom ones). environment and release are detected automatically and
only need to be passed to init() to override the detection.
Environment is resolved in this order:
environmentpassed toinit()ARTIM_ENV, thenENVIRONMENT,ENV,APP_ENV,STAGE,DJANGO_ENV,FLASK_ENV,RAILS_ENV- Debug flags —
ARTIM_DEBUG,DEBUG,FLASK_DEBUG,DJANGO_DEBUGset to a truthy value, or Django'ssettings.DEBUG→development - otherwise
production
Aliases are normalized: dev, local, debug → development; stage, stg,
preview → staging; prod, live → production. Any other value is kept as
a custom environment and registered on the project automatically.
Release detection
releasepassed toinit()ARTIM_RELEASE, thenAPP_VERSION,RELEASE,SOURCE_VERSION,HEROKU_SLUG_COMMIT,RAILWAY_GIT_COMMIT_SHA,FLY_MACHINE_VERSION,GIT_COMMIT,GITHUB_SHA- Installed package version, when
distributionnames your package:ArtimStacktrace.init(api_key="...", distribution="my-service")
versionfrompyproject.tomlin the working directory- Short git SHA of
HEAD "unknown"plus a warning
To check what the SDK resolved:
ArtimStacktrace.get_environment()
ArtimStacktrace.get_release()
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 stacktrace_sdk_python-0.2.0.tar.gz.
File metadata
- Download URL: stacktrace_sdk_python-0.2.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03956d121a603c5bbde3299d03401094a6ea2902c1fde3a6b1dd2d851c3e541b
|
|
| MD5 |
2f8b40c498482cdb26849869c885e594
|
|
| BLAKE2b-256 |
02f48f314f573fb07d7e31ea9941ff4f5634e9fe817cb1dbf24f656220de1f7f
|
File details
Details for the file stacktrace_sdk_python-0.2.0-py3-none-any.whl.
File metadata
- Download URL: stacktrace_sdk_python-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
843ca953f5250883be765d9ce6aa367b3e8fdde884a9e4fe1fb153e5043e8382
|
|
| MD5 |
c8a734776554781d24033bf760385471
|
|
| BLAKE2b-256 |
f419d81906fcf916aadf6d7131f3ae1fb89bb292c9bfdf70cbed2664ccf4e0f9
|