Metadata-Version: 2.4
Name: spanport
Version: 0.1.0
Summary: Send your Python app's logs to Spanport with two lines of code.
Keywords: logging,observability,opentelemetry,otlp,spanport
Author: Nitish Bharadwaj
Author-email: Nitish Bharadwaj <nitishbharadwaj2002@gmail.com>
License-Expression: Apache-2.0
License-File: LICENSE
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: System :: Logging
Classifier: Topic :: System :: Monitoring
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.45.1,<2
Requires-Dist: opentelemetry-instrumentation-logging>=0.66b1,<1
Requires-Dist: opentelemetry-sdk>=1.45.1,<2
Requires-Python: >=3.12
Project-URL: Homepage, https://github.com/span-port/spanport
Project-URL: Source, https://github.com/span-port/spanport
Project-URL: Issues, https://github.com/span-port/spanport/issues
Description-Content-Type: text/markdown

# spanport (Python SDK)

Send your Python app's logs to Spanport. Keep logging the way you already do.

```bash
pip install spanport
```

```python
import logging
import spanport

spanport.init(
    data_key="sp_ingest_...",                       # from: python -m spanport_server.cli create-data-key
    service="hr-portal-api",
    collector_url="http://spanport-collector:4318",  # default http://localhost:4318
    server_url="http://spanport-server:8000",        # default http://localhost:8000
)

logging.getLogger(__name__).error("Payment failed for order 1042")
```

- **Every `logging` call is sent**, at the level your app already logs at (the root logger's level).
- **Logs are sent in the background**, in batches every few seconds. `spanport.shutdown()` sends what is left; it also runs on normal exit.
- **Logs inside an OpenTelemetry span** carry that span's `trace_id` and `span_id`, so they show up with the request.
- **Wrong key?** At start-up the SDK asks the server once whether the key is valid and prints a clear error on stderr if not. Pass `check_key=False` if the app cannot reach the server.
- **It never breaks your app.** `init()` never raises; problems are printed on stderr as `spanport: ...` and the app carries on.

Python 3.12 or newer.

## Development

```bash
uv sync
uv run pytest
uv run ruff check . && uv run ruff format --check .
uv run mypy src tests
```
