Skip to main content

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

dock_thor_client-1.0.8.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dock_thor_client-1.0.8-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file dock_thor_client-1.0.8.tar.gz.

File metadata

  • Download URL: dock_thor_client-1.0.8.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for dock_thor_client-1.0.8.tar.gz
Algorithm Hash digest
SHA256 d38c2d77b545afa3a680d9a491e287a3c83ddff07a500095e6ee674121bf07e1
MD5 c50ead525d4930129655716adb84d36d
BLAKE2b-256 e09520d4ba21a1916fbbf3fc6d3f61817be87fcfa295ab6228eb98ab1cbe4cc7

See more details on using hashes here.

File details

Details for the file dock_thor_client-1.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for dock_thor_client-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 6f998204ba7d0770fd6c88be826c81181939f327d83362bc8c3ac48a57b96b14
MD5 3d867967af03901abc5b6957a964b600
BLAKE2b-256 e4f86e5ca5fed4a2182d57a25f62fce4f7c1b87248deb752b42e34a46c5fa23c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page