Python client for DockTHOR error reporting
Project description
dock-thor-client
dock-thor-client is a Python client for DockTHOR error reporting, designed to easily capture and send application errors, exceptions, and messages to the DockTHOR API. It supports asynchronous operation so that sending errors does not block your main application flow.
Features
- Capture exceptions and messages from your Python application.
- Send events asynchronously to avoid slowing down your application.
- Fully compatible with DockTHOR API.
- Serialize events, stack traces, and context data automatically.
- Supports user, environment, and custom metadata.
Installation
pip install dock-thor-client
Usage
Initialize the client
from dock_thor import DockThorClient
client = DockThorClient(token="your-token", private_key="your-private-key")
Capture an exception
try:
1 / 0
except Exception as e:
client.capture_exception(e)
Capture a message
client.capture_message("Something happened!", level="error")
Automatic FastAPI Integration
If you’re using FastAPI, the client can automatically measure request durations, capture errors, and send transaction data.
from fastapi import FastAPI
from dock_thor import DockThorClient, DockThorFastAPIMiddleware
client = DockThorClient(token="your-token", private_key="your-private-key")
app = FastAPI()
# Add DockTHOR middleware with optional exclusions
app.add_middleware(
DockThorFastAPIMiddleware,
client=client,
exclude_paths=["/api/health", "/metrics"]
)
Now every request will automatically:
- Generate a transaction (trace_id, span_id, duration, HTTP status)
- Send it to DockTHOR
- Capture and report any unhandled exceptions
Manual Transaction Capture
You can also manually capture custom transactions (e.g. background jobs):
import time
from dock_thor import Span
start = time.time()
# your process here
end = time.time()
span = Span(
span_id="abc123",
trace_id="xyz789",
start_timestamp=start,
end_timestamp=end,
description="Background job",
op="worker.task",
status="200",
data={"duration_ms": round((end - start) * 1000, 2)},
)
await client.capture_transaction(
name="job:daily_cleanup",
spans=[span]
)
Contributing
Contributions are welcome! Please open issues or pull requests on GitHub
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dock_thor_client-1.1.0.tar.gz.
File metadata
- Download URL: dock_thor_client-1.1.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b2739ed41b35abd17c0ac525dc38bcb1338975a1ea42e0d72a28ae07d6e6577
|
|
| MD5 |
0c76301e6909eefff64e13abbcbe4ff7
|
|
| BLAKE2b-256 |
62e702ac5804344f371fbd918aa4f3449c626a29cd73c61afe472fe9347067a8
|
File details
Details for the file dock_thor_client-1.1.0-py3-none-any.whl.
File metadata
- Download URL: dock_thor_client-1.1.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8213ce91a3393d364585af2d0f25f142f5c3f09235c12889c35817d51b986a39
|
|
| MD5 |
f498488f30eaf1353a3acfa3ecf1a700
|
|
| BLAKE2b-256 |
c784f26047d0821c6b0a32ae332fa9506b408441dae35f04c6af5f030940fbb9
|