Skip to main content

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

  • init sets API key, project id, environment, release, and backend endpoint
  • capture_exception sends exception details and stacktrace
  • capture_message sends simple event messages
  • set_user and identify attach 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:

  1. environment passed to init()
  2. ARTIM_ENV, then ENVIRONMENT, ENV, APP_ENV, STAGE, DJANGO_ENV, FLASK_ENV, RAILS_ENV
  3. Debug flags — ARTIM_DEBUG, DEBUG, FLASK_DEBUG, DJANGO_DEBUG set to a truthy value, or Django's settings.DEBUGdevelopment
  4. otherwise production

Aliases are normalized: dev, local, debugdevelopment; stage, stg, previewstaging; prod, liveproduction. Any other value is kept as a custom environment and registered on the project automatically.

Release detection

  1. release passed to init()
  2. ARTIM_RELEASE, then APP_VERSION, RELEASE, SOURCE_VERSION, HEROKU_SLUG_COMMIT, RAILWAY_GIT_COMMIT_SHA, FLY_MACHINE_VERSION, GIT_COMMIT, GITHUB_SHA
  3. Installed package version, when distribution names your package:
    ArtimStacktrace.init(api_key="...", distribution="my-service")
    
  4. version from pyproject.toml in the working directory
  5. Short git SHA of HEAD
  6. "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

stacktrace_sdk_python-0.2.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stacktrace_sdk_python-0.2.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

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

Hashes for stacktrace_sdk_python-0.2.0.tar.gz
Algorithm Hash digest
SHA256 03956d121a603c5bbde3299d03401094a6ea2902c1fde3a6b1dd2d851c3e541b
MD5 2f8b40c498482cdb26849869c885e594
BLAKE2b-256 02f48f314f573fb07d7e31ea9941ff4f5634e9fe817cb1dbf24f656220de1f7f

See more details on using hashes here.

File details

Details for the file stacktrace_sdk_python-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for stacktrace_sdk_python-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 843ca953f5250883be765d9ce6aa367b3e8fdde884a9e4fe1fb153e5043e8382
MD5 c8a734776554781d24033bf760385471
BLAKE2b-256 f419d81906fcf916aadf6d7131f3ae1fb89bb292c9bfdf70cbed2664ccf4e0f9

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page