Metadata-Version: 2.4
Name: sra-sdk
Version: 0.1.1
Summary: System Reliability Assistant - SDK for automatic incident detection and response
Home-page: https://github.com/Greekatz/hackonauts-api
Author: SRA Team
Author-email: team@sra.dev
Project-URL: Bug Reports, https://github.com/Greekatz/hackonauts-api/issues
Project-URL: Source, https://github.com/Greekatz/hackonauts-api
Keywords: logging,monitoring,incident-response,observability,apm
Classifier: Development Status :: 3 - Alpha
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.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: System :: Logging
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Provides-Extra: metrics
Requires-Dist: psutil>=5.9.0; extra == "metrics"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: project-url
Dynamic: provides-extra
Dynamic: requires-python
Dynamic: summary

# System Reliability Assistant (SRA)

Lightweight Python SDK for automatic log collection, metrics tracking, and incident detection.

## Installation

```bash
pip install sra-sdk
```

For system metrics collection:
```bash
pip install sra-sdk[metrics]
```

## Quick Start

### Basic Logging

```python
from sra_sdk import SRALogger

logger = SRALogger(
    api_key="your-api-key",
    endpoint="https://your-backend.com",
    service="my-service",
    environment="production"
)

logger.info("Application started")
logger.warning("High memory usage detected")
logger.error("Database connection failed", extra={"db_host": "localhost"})
```

### Integration with Python Logging

```python
import logging
from sra_sdk import SRAHandler

handler = SRAHandler(
    api_key="your-api-key",
    endpoint="https://your-backend.com",
    service="my-service"
)
logging.root.addHandler(handler)

logging.info("This is forwarded to SRA")
logging.error("Errors are captured automatically")
```

### Metrics Collection

```python
from sra_sdk import MetricsCollector

metrics = MetricsCollector(
    api_key="your-api-key",
    endpoint="https://your-backend.com",
    service="my-service"
)

metrics.gauge("active_users", 150)
metrics.counter("requests_total")
metrics.timing("request_duration_ms", 45.2)

# Auto-collect system metrics
metrics.start_system_metrics(interval=30)
```

### Exception Capture

```python
from sra_sdk import SRALogger, capture_exceptions

logger = SRALogger(api_key="your-key", capture_exceptions=True)

@capture_exceptions(logger)
def risky_function():
    return 1 / 0
```

## Configuration

### SRALogger Options

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| api_key | str | required | Your API key |
| endpoint | str | http://localhost:8000 | Backend URL |
| service | str | None | Service name |
| environment | str | None | Environment |
| capture_exceptions | bool | True | Auto-capture exceptions |
| batch_size | int | 50 | Logs per batch |
| flush_interval | float | 5.0 | Seconds between flushes |

## License

MIT
