Metadata-Version: 2.5
Name: elenjical-sdk
Version: 0.1.0
Summary: Elenjical error tracking and logs for Python: Django, Flask, FastAPI, Celery and plain scripts.
Author: Elenjical
License-Expression: MIT
License-File: LICENSE
License-File: NOTICE
Keywords: django,elenjical,error-tracking,fastapi,flask,logging,observability
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Bug Tracking
Classifier: Topic :: System :: Logging
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: sentry-sdk<3,>=2.69.1
Provides-Extra: celery
Requires-Dist: sentry-sdk[celery]<3,>=2.69.1; extra == 'celery'
Provides-Extra: django
Requires-Dist: sentry-sdk[django]<3,>=2.69.1; extra == 'django'
Provides-Extra: fastapi
Requires-Dist: sentry-sdk[fastapi]<3,>=2.69.1; extra == 'fastapi'
Provides-Extra: flask
Requires-Dist: sentry-sdk[flask]<3,>=2.69.1; extra == 'flask'
Provides-Extra: sqlalchemy
Requires-Dist: sentry-sdk[sqlalchemy]<3,>=2.69.1; extra == 'sqlalchemy'
Description-Content-Type: text/markdown

# elenjical-sdk

Error tracking and logs for Python services (Django, Flask, FastAPI, Celery, scripts), reported to Elenjical.

## Install

```sh
pip install "elenjical-sdk[flask]"     # or [django], [fastapi], [celery], [sqlalchemy], or none
```

## Set up

Set `ELENJICAL_DSN` (your service's DSN from Elenjical, Settings > Services) and, optionally,
`ELENJICAL_ENVIRONMENT` and `ELENJICAL_RELEASE`. Then, before the application starts:

```python
import logging

import elenjical
from elenjical.integrations.flask import FlaskIntegration
from elenjical.integrations.logging import LoggingIntegration, ignore_logger

elenjical.init(
    integrations=[
        FlaskIntegration(),
        LoggingIntegration(level=logging.INFO, event_level=logging.ERROR, logs_level=logging.INFO),
    ],
)
ignore_logger("gunicorn.access")
```

Arguments you pass take precedence over the environment. Report handled errors with
`elenjical.capture_exception(error)`, identify people with `elenjical.set_user({"id": ..., "email": ...})`, write
logs with `elenjical.logger.info("...")`.

| Variable | Meaning |
| --- | --- |
| `ELENJICAL_DSN` | where to report; unset turns reporting off |
| `ELENJICAL_ENVIRONMENT` | `development`, `uat`, `production`, ... |
| `ELENJICAL_RELEASE` | the deployed version, e.g. `api@<git sha>` |
| `ELENJICAL_TRACES_SAMPLE_RATE` | tracing sample rate (default 0) |
| `ELENJICAL_DEBUG` | `true` logs what the SDK does |

If browsers call this service, allow `elenjical.TRACE_HEADERS` in CORS (Flask-CORS:
`allow_headers=["Content-Type", "Authorization", *elenjical.TRACE_HEADERS]`) so their sessions link to your
errors.

See NOTICE for the open-source software this package is built on.
