Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v4
Expand All @@ -26,7 +26,9 @@ jobs:
cache: pip

- name: Install dependencies
run: pip install -e ".[dev,async]"
run: |
pip install -e ".[async,starlette,flask,django,fastapi]"
pip install build pytest pytest-asyncio pytest-cov pytest-mock freezegun

- name: Run tests
run: pytest tests/ -v --tb=short
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Flask middleware for auto-logging HTTP requests
- Django middleware for auto-logging HTTP requests
- FastAPI middleware for auto-logging HTTP requests
- Full type hints support for Python 3.8+
- Full type hints support for Python 3.10+

[0.8.5]: https://github.com/logtide-dev/logtide-python/compare/v0.8.4...v0.8.5
[0.8.4]: https://github.com/logtide-dev/logtide-python/compare/v0.1.0...v0.8.4
Expand Down
57 changes: 28 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<p align="center">
<a href="https://pypi.org/project/logtide-sdk/"><img src="https://img.shields.io/pypi/v/logtide-sdk?color=blue" alt="PyPI"></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License"></a>
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/Python-3.8+-blue.svg" alt="Python"></a>
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/Python-3.10+-blue.svg" alt="Python"></a>
<a href="https://github.com/logtide-dev/logtide-python/releases"><img src="https://img.shields.io/github/v/release/logtide-dev/logtide-python" alt="Release"></a>
</p>

Expand All @@ -33,11 +33,11 @@
- **Structured exception serialization** with parsed stack frames
- **Internal metrics** (logs sent, errors, latency, circuit breaker trips)
- **Flask, Django, FastAPI & Starlette middleware** for auto-logging HTTP requests
- **Full Python 3.8+ support** with type hints
- **Full Python 3.10+ support** with type hints

## Requirements

- Python 3.8 or higher
- Python 3.10 or higher

## Installation

Expand Down Expand Up @@ -92,37 +92,37 @@ client.close()

### Basic Options

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `api_url` | `str` | **required** | Base URL of your LogTide instance |
| `api_key` | `str` | **required** | Project API key (starts with `lp_`) |
| `batch_size` | `int` | `100` | Logs per batch before an immediate flush |
| `flush_interval` | `int` | `5000` | Auto-flush interval in ms |
| Option | Type | Default | Description |
| ---------------- | ----- | ------------ | ---------------------------------------- |
| `api_url` | `str` | **required** | Base URL of your LogTide instance |
| `api_key` | `str` | **required** | Project API key (starts with `lp_`) |
| `batch_size` | `int` | `100` | Logs per batch before an immediate flush |
| `flush_interval` | `int` | `5000` | Auto-flush interval in ms |

### Advanced Options

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `max_buffer_size` | `int` | `10000` | Max buffered logs; excess are silently dropped |
| `max_retries` | `int` | `3` | Max retry attempts on send failure |
| `retry_delay_ms` | `int` | `1000` | Initial retry delay (doubles each attempt) |
| `circuit_breaker_threshold` | `int` | `5` | Consecutive failures before opening circuit |
| `circuit_breaker_reset_ms` | `int` | `30000` | Time before testing a half-open circuit |
| `debug` | `bool` | `False` | Print debug output to console |
| `global_metadata` | `dict` | `{}` | Metadata merged into every log entry |
| `auto_trace_id` | `bool` | `False` | Auto-generate a UUID trace ID per log |
| `payload_limits` | `PayloadLimitsOptions` | see below | Safeguards against oversized payloads |
| Option | Type | Default | Description |
| --------------------------- | ---------------------- | --------- | ---------------------------------------------- |
| `max_buffer_size` | `int` | `10000` | Max buffered logs; excess are silently dropped |
| `max_retries` | `int` | `3` | Max retry attempts on send failure |
| `retry_delay_ms` | `int` | `1000` | Initial retry delay (doubles each attempt) |
| `circuit_breaker_threshold` | `int` | `5` | Consecutive failures before opening circuit |
| `circuit_breaker_reset_ms` | `int` | `30000` | Time before testing a half-open circuit |
| `debug` | `bool` | `False` | Print debug output to console |
| `global_metadata` | `dict` | `{}` | Metadata merged into every log entry |
| `auto_trace_id` | `bool` | `False` | Auto-generate a UUID trace ID per log |
| `payload_limits` | `PayloadLimitsOptions` | see below | Safeguards against oversized payloads |

### Payload Limits

`PayloadLimitsOptions` prevents 413 errors from oversized entries.

| Field | Default | Description |
|-------|---------|-------------|
| `max_field_size` | `10 * 1024` (10 KB) | Max length of any single string field |
| `max_log_size` | `100 * 1024` (100 KB) | Max total serialized entry size |
| `exclude_fields` | `[]` | Field names replaced with `"[EXCLUDED]"` |
| `truncation_marker` | `"...[TRUNCATED]"` | Appended to truncated strings |
| Field | Default | Description |
| ------------------- | --------------------- | ---------------------------------------- |
| `max_field_size` | `10 * 1024` (10 KB) | Max length of any single string field |
| `max_log_size` | `100 * 1024` (100 KB) | Max total serialized entry size |
| `exclude_fields` | `[]` | Field names replaced with `"[EXCLUDED]"` |
| `truncation_marker` | `"...[TRUNCATED]"` | Appended to truncated strings |

```python
from logtide_sdk import LogTideClient, ClientOptions, PayloadLimitsOptions
Expand Down Expand Up @@ -167,15 +167,14 @@ except Exception as e:
```

Generated metadata:

```json
{
"exception": {
"type": "RuntimeError",
"message": "Database timeout",
"language": "python",
"stacktrace": [
{"file": "app.py", "function": "run_query", "line": 42}
],
"stacktrace": [{ "file": "app.py", "function": "run_query", "line": 42 }],
"raw": "Traceback (most recent call last):\n ..."
}
}
Expand Down
56 changes: 25 additions & 31 deletions logtide_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
"""LogTide SDK - Official Python SDK for LogTide."""

from .client import LogTideClient, serialize_exception

_has_async = False
try:
from .async_client import AsyncLogTideClient

_has_async = True
except ImportError:
pass # type: ignore[assignment]
from .enums import CircuitState, LogLevel
from .exceptions import BufferFullError, CircuitBreakerOpenError, LogTideError
from .handler import LogTideHandler
from .models import (
from logtide_sdk.client import LogTideClient, serialize_exception
from logtide_sdk.enums import CircuitState, LogLevel
from logtide_sdk.exceptions import BufferFullError, CircuitBreakerOpenError, LogTideError
from logtide_sdk.handler import LogTideHandler
from logtide_sdk.models import (
AggregatedStatsOptions,
AggregatedStatsResponse,
ClientMetrics,
Expand All @@ -23,31 +15,33 @@
QueryOptions,
)

_has_async = False
try:
from logtide_sdk.async_client import AsyncLogTideClient

_has_async = True # type: ignore[assignment]
except ImportError:
pass

__version__ = "0.8.5"

__all__ = [
# Clients
"LogTideClient",
# Logging integration
"LogTideHandler",
# Error serialization utility
"serialize_exception",
# Models
"LogEntry",
"ClientOptions",
"QueryOptions",
"AggregatedStatsOptions",
"ClientMetrics",
"LogsResponse",
"AggregatedStatsResponse",
"PayloadLimitsOptions",
# Enums
"LogLevel",
"BufferFullError",
"CircuitBreakerOpenError",
"CircuitState",
# Exceptions
"ClientMetrics",
"ClientOptions",
"LogEntry",
"LogLevel",
"LogTideClient",
"LogTideError",
"CircuitBreakerOpenError",
"BufferFullError",
"LogTideHandler",
"LogsResponse",
"PayloadLimitsOptions",
"QueryOptions",
"serialize_exception",
]

if _has_async:
Expand Down
Loading
Loading