Skip to main content

hawkapi-sentry

PyPI Python License CI Downloads

Sentry integration for HawkAPI — a plugin that initialises the Sentry SDK on startup and captures unhandled exceptions, plus a middleware that creates a performance transaction per request.


Quickstart

pip install hawkapi-sentry
from hawkapi import HawkAPI
from hawkapi_sentry import SentryPlugin, SentryMiddleware

app = HawkAPI()

app.add_plugin(
    SentryPlugin(
        dsn="https://key@sentry.io/123",
        environment="production",
        traces_sample_rate=0.1,
    )
)
app.add_middleware(SentryMiddleware)

That's it. Every unhandled exception is captured with full request context; every request gets a Sentry performance transaction.


SentryPlugin parameter reference

Parameter Type Default Description
dsn str | None None Sentry DSN. Empty/None = no-op mode (safe for local dev).
environment str "production" Sentry environment tag.
release str | None None Release string. None = not set.
traces_sample_rate float 0.0 Fraction of transactions to sample for performance monitoring.
profiles_sample_rate float 0.0 Fraction of sampled transactions to profile.
include_user_data bool False When True, attach request.state.user dict to Sentry events.
user_getter Callable[[Request], dict] | None None Custom callable to extract user data from the request. Takes priority over include_user_data.
before_send Callable | None None Passed directly to sentry_sdk.init. Return None to drop an event.
tags dict[str, str] | None None Global tags applied to every captured event.
ignore_status_codes tuple[int, ...] (404, 401, 403) HTTP status codes for which exceptions are not sent to Sentry.

Migration from sentry-sdk[fastapi]

FastAPI / starlette-sentry hawkapi-sentry
sentry_sdk.init(integrations=[StarletteIntegration(), FastApiIntegration()]) app.add_plugin(SentryPlugin(dsn=...))
SentryAsgiMiddleware(app) app.add_middleware(SentryMiddleware)
before_send kwarg to sentry_sdk.init SentryPlugin(before_send=...)
Manual with sentry_sdk.push_scope() as scope: scope.set_user(...) SentryPlugin(user_getter=lambda req: {...})

The main difference: HawkAPI plugins own the SDK lifecycle, so you never call sentry_sdk.init() yourself — SentryPlugin.on_startup() does it.


Development

# Clone and install in editable mode with dev extras
git clone https://github.com/Hawk-API/hawkapi-sentry.git
cd hawkapi-sentry
uv sync --extra dev

# Run tests
uv run pytest tests/ -q

# Lint
uv run ruff check .
uv run ruff format .

# Type-check
uv run pyright src/

License

MIT — Copyright (c) 2026 HawkAPI Contributors.

Metadata

Release files for hawkapi-sentry 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hawkapi-sentry 0.2.1
File Size Uploaded Provenance
hawkapi_sentry-0.2.1.tar.gz 24.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for hawkapi-sentry 0.2.1
File Interpreter ABI Platform
hawkapi_sentry-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 33.3 kB

Release files / hawkapi_sentry-0.2.1.tar.gz

Download URL hawkapi_sentry-0.2.1.tar.gz
Size 24.5 kB
Tags Source
SHA-256 checksum
How to use checksums
cb5bbd6cfba2b707a638311a3ebb3a80865c5781b38bf13fac509a9006be447f
BLAKE2b-256 checksum
How to use checksums
ed059f33ffa75a0d71b9b8e2306abf18352d290fe67c235dd96d66b96dd08027
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.

Transparency log

Release files / hawkapi_sentry-0.2.1-py3-none-any.whl

Download URL hawkapi_sentry-0.2.1-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d1798b6fff38a5eb41327c6405b549f492757461f5a32076b0901930b8231d3
BLAKE2b-256 checksum
How to use checksums
eb9491cf01fee66838067e29ccafb247dcc9f40699e35f6be759a34f10b94d5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.

Transparency log

Security for hawkapi-sentry 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for hawkapi_sentry-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page