Metadata-Version: 2.4
Name: salopulse-django
Version: 1.0.0
Summary: SaloPulse SDK for Django — error, performance and SQL monitoring.
Author: SaloPulse
License: MIT
Project-URL: Homepage, https://salopulse.com
Project-URL: Source, https://github.com/mersieS/salopulse-django
Keywords: monitoring,apm,django,observability,salopulse
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.0
Classifier: Framework :: Django :: 5.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: django
Requires-Dist: Django>=4.0; extra == "django"
Provides-Extra: dev
Requires-Dist: Django>=4.0; extra == "dev"
Requires-Dist: pytest>=7.0; extra == "dev"
Dynamic: license-file

# SaloPulse Django SDK

Error, performance and SQL monitoring for Django apps. Byte-compatible wire
protocol with the SaloPulse Ruby SDK.

## Install

```bash
pip install salopulse-django
```

## Quickstart

Add the middleware to `settings.py` (as early as possible, ideally first):

```python
MIDDLEWARE = [
    "salopulse_django.middleware.SalopulseMiddleware",
    # ... your other middleware ...
]
```

Initialize the SDK at startup (e.g. in `settings.py`, `wsgi.py` or your app's
`AppConfig.ready`):

```python
import os
import salopulse_django

salopulse_django.init(dsn=os.environ["SALOPULSE_DSN"])
```

That's it. Requests now emit a performance event (with `span_count`), captured
SQL queries (with N+1 detection), and unhandled exceptions automatically.

### Optional: auto-init via INSTALLED_APPS

Instead of calling `init` yourself, add the app and set `SALOPULSE_DSN` in the
environment or settings:

```python
INSTALLED_APPS = [
    # ...
    "salopulse_django",
]
```

## Configuration

```python
salopulse_django.init(
    dsn=os.environ["SALOPULSE_DSN"],
    release="v1.2.3",
    environment="production",
    service="checkout-api",
    sample_rate=1.0,
)
```

When `dsn` is omitted, the SDK reads `SALOPULSE_DSN` from the environment or
Django settings. The DSN format is `https://<api_key>@host[:port]`.

## API

```python
import salopulse_django

salopulse_django.capture_exception(err)
salopulse_django.capture_message("something happened", level="warning")
salopulse_django.set_user(id=123, email="a@b.com")
salopulse_django.flush()   # flush buffered events now
salopulse_django.close()   # stop the background flusher (called on exit)
```

The SDK never raises into your app: a missing or invalid DSN makes every call a
safe no-op.

## License

MIT — see [LICENSE](LICENSE).
