irontelemetry-python/README.md

163 lines
4.6 KiB
Markdown

<p align="center">
<a href="https://irontelemetry.com">
<img src="https://irontelemetry.com/logo.png" alt="IronTelemetry" width="120" />
</a>
</p>
<h1 align="center">IronTelemetry SDK for Python</h1>
<p align="center">
<strong>Error monitoring and crash reporting for Python applications</strong>
</p>
<p align="center">
<a href="https://pypi.org/project/irontelemetry/"><img src="https://img.shields.io/pypi/v/irontelemetry.svg" alt="PyPI version"></a>
<a href="https://pypi.org/project/irontelemetry/"><img src="https://img.shields.io/pypi/pyversions/irontelemetry.svg" alt="Python versions"></a>
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
</p>
<p align="center">
<a href="https://irontelemetry.com">Website</a>
<a href="https://irontelemetry.com/docs">Documentation</a>
<a href="https://irontelemetry.com/docs/python">Python Guide</a>
<a href="https://git.marketally.com/ironservices">Git</a>
</p>
---
**IronTelemetry** helps you capture exceptions, track user journeys, and get actionable insights to fix issues faster. Built for developers who want simple, powerful error monitoring without the complexity.
## Features
- **Exception Capture** - Automatically capture and report exceptions with full stack traces
- **Journey Tracking** - Understand what users did before an error occurred
- **Breadcrumbs** - Add context with custom breadcrumbs and metadata
- **Framework Support** - Built-in integrations for Django, Flask, FastAPI
- **Async Support** - Full async/await support
- **Type Hints** - Complete type annotations for IDE support
- **Offline Queue** - Events are queued when offline and sent when connectivity returns
## Installation
```bash
pip install irontelemetry
```
## Quick Start
### Initialize the SDK
```python
import irontelemetry
irontelemetry.init("https://pk_live_xxx@irontelemetry.com")
```
### Capture Exceptions
```python
try:
do_something()
except Exception as e:
irontelemetry.capture_exception(e)
raise
```
### Track User Journeys
```python
with irontelemetry.start_journey("Checkout Flow"):
irontelemetry.set_user("user-123", "user@example.com")
with irontelemetry.start_step("Validate Cart", "business"):
validate_cart()
with irontelemetry.start_step("Process Payment", "business"):
process_payment()
with irontelemetry.start_step("Send Confirmation", "notification"):
send_confirmation_email()
```
### Add Breadcrumbs
```python
from irontelemetry import add_breadcrumb, BreadcrumbCategory
add_breadcrumb("User clicked checkout button", BreadcrumbCategory.UI)
add_breadcrumb("Payment API called", BreadcrumbCategory.HTTP)
```
## Framework Integrations
### Django
```python
# settings.py
INSTALLED_APPS = [
'irontelemetry.django',
# ...
]
IRONTELEMETRY_DSN = "https://pk_live_xxx@irontelemetry.com"
```
### Flask
```python
from flask import Flask
from irontelemetry.flask import IronTelemetry
app = Flask(__name__)
IronTelemetry(app, dsn="https://pk_live_xxx@irontelemetry.com")
```
### FastAPI
```python
from fastapi import FastAPI
from irontelemetry.fastapi import IronTelemetryMiddleware
app = FastAPI()
app.add_middleware(IronTelemetryMiddleware, dsn="https://pk_live_xxx@irontelemetry.com")
```
## Configuration
```python
from irontelemetry import TelemetryOptions, init
init(TelemetryOptions(
dsn="https://pk_live_xxx@irontelemetry.com",
environment="production",
app_version="1.2.3",
sample_rate=1.0,
debug=False,
before_send=lambda event: event if "expected" not in (event.message or "") else None,
))
```
## Documentation
For complete documentation, visit [irontelemetry.com/docs](https://irontelemetry.com/docs).
## Other SDKs
| Platform | Package |
|----------|---------|
| JavaScript/TypeScript | [@ironservices/telemetry](https://git.marketally.com/ironservices/irontelemetry-js) |
| .NET | [IronTelemetry.Client](https://git.marketally.com/ironservices/irontelemetry-dotnet) |
| Go | [irontelemetry-go](https://git.marketally.com/ironservices/irontelemetry-go) |
| Java | [irontelemetry-java](https://git.marketally.com/ironservices/irontelemetry-java) |
| Rust | [irontelemetry](https://git.marketally.com/ironservices/irontelemetry-rust) |
## Support
- **Documentation**: [irontelemetry.com/docs](https://irontelemetry.com/docs)
- **Email**: dev@ironservices.io
- **Issues**: [git.marketally.com/ironservices/irontelemetry-python/issues](https://git.marketally.com/ironservices/irontelemetry-python/issues)
## License
MIT License - see [LICENSE](LICENSE) for details.