Metadata-Version: 2.4
Name: patera-telemetry
Version: 0.1.0
Summary: OpenTelemetry tracing, metrics and log correlation for Patera
Keywords: patera,opentelemetry,tracing,metrics,observability
Author: Marko Šterk
Author-email: Marko Šterk <marko_sterk@hotmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Typing :: Typed
Classifier: Topic :: System :: Monitoring
Classifier: Topic :: Internet :: WWW/HTTP
Requires-Dist: opentelemetry-api>=1.39
Requires-Dist: patera>=0.126.0
Requires-Dist: opentelemetry-sdk>=1.39 ; extra == 'all'
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.39 ; extra == 'all'
Requires-Dist: opentelemetry-instrumentation-sqlalchemy>=0.60b0 ; extra == 'all'
Requires-Dist: sqlalchemy<2.1 ; extra == 'all'
Requires-Dist: opentelemetry-instrumentation-httpx>=0.60b0 ; extra == 'all'
Requires-Dist: opentelemetry-instrumentation-redis>=0.60b0 ; extra == 'all'
Requires-Dist: opentelemetry-sdk>=1.39 ; extra == 'grpc'
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.39 ; extra == 'grpc'
Requires-Dist: opentelemetry-instrumentation-httpx>=0.60b0 ; extra == 'httpx'
Requires-Dist: opentelemetry-instrumentation-redis>=0.60b0 ; extra == 'redis'
Requires-Dist: opentelemetry-sdk>=1.39 ; extra == 'sdk'
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.39 ; extra == 'sdk'
Requires-Dist: opentelemetry-instrumentation-sqlalchemy>=0.60b0 ; extra == 'sqlalchemy'
Requires-Dist: sqlalchemy<2.1 ; extra == 'sqlalchemy'
Requires-Python: >=3.13
Project-URL: Homepage, https://github.com/MarkoSterk/Patera
Project-URL: Documentation, https://github.com/MarkoSterk/Patera#readme
Project-URL: Repository, https://github.com/MarkoSterk/Patera
Project-URL: Issues, https://github.com/MarkoSterk/Patera/issues
Project-URL: Changelog, https://github.com/MarkoSterk/Patera/blob/main/CHANGELOG.md
Provides-Extra: all
Provides-Extra: grpc
Provides-Extra: httpx
Provides-Extra: redis
Provides-Extra: sdk
Provides-Extra: sqlalchemy
Description-Content-Type: text/markdown

# patera-telemetry

OpenTelemetry tracing, metrics and log correlation for Patera. Part of [Patera](https://github.com/MarkoSterk/Patera), a modular async-first Python web framework.

## Installation

```sh
pip install patera-telemetry            # instrumentation only (opentelemetry-api)
pip install "patera-telemetry[all]"     # + SDK, OTLP/HTTP exporter, integrations
# or, with uv
uv add "patera[telemetry]"
```

Extras: `sdk` (SDK and OTLP/HTTP exporter), `grpc` (OTLP/gRPC exporter), `sqlalchemy`,
`httpx`, `redis` (instrumentations), and `all` (everything except `grpc`).

Requires Python 3.13 or newer and a Patera core with `req.on_finish` and the middleware
opt-in flags.

## Usage

```python
from patera.telemetry import Telemetry, TelemetryConfig

class Config(BaseConfig):
    TELEMETRY: TelemetryConfig = TelemetryConfig(SETUP_SDK=True, INSTRUMENT=["sqlalchemy"])

@app(__name__, configs=Config)
class App(Patera[Config]):
    app_extensions = [Telemetry, Databases]
```

Each HTTP request becomes a SERVER span named after its route, with the
`http.server.request.duration` metric and `trace_id`/`span_id` in the request's log records.
Set `OTEL_EXPORTER_OTLP_ENDPOINT` to send them to a collector, Jaeger or a hosted backend.
Without `SETUP_SDK`, the extension uses the providers configured elsewhere; without any, it is a
no-op.

Privacy defaults: client addresses, query strings and headers are not recorded unless enabled,
and captured `authorization`, `cookie`, `set-cookie` and `proxy-authorization` values are masked.

See the [telemetry documentation](https://github.com/MarkoSterk/Patera/blob/main/docs/extensions/telemetry.md).
