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.6.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.6-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dock_thor_client-1.0.6.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.6.tar.gz
Algorithm Hash digest
SHA256 27a81df98b7d2fc0bdd0d02fb2c90801997c3545c32a66f4f20e3a18de2ad9c9
MD5 245bc4bdd99b7534337c99b63ea26e04
BLAKE2b-256 d166f7e0c19a810c5e42162f3efe29b471ac4107145f28b8e842603aab8616e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dock_thor_client-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2d062809fc7598219697933323a3b1749b62fd0322c492edc475b8642e3dcaff
MD5 a65342ca91e682dc7ce731608148d552
BLAKE2b-256 291a238fce58eca72a4f6eab27ea72489faca6d7b6f96428ed335b8a0d66db76

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