Metadata-Version: 2.5
Name: narrativetrace-asgi
Version: 0.1.1
Summary: ASGI middleware (Starlette/FastAPI) for narrativetrace request tracing
Project-URL: Homepage, https://github.com/narrativetrace/narrativetrace-python
Project-URL: Source, https://github.com/narrativetrace/narrativetrace-python
Author: narrativetrace contributors
License-Expression: BUSL-1.1
License-File: LICENSE
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: narrativetrace
Provides-Extra: httpx
Requires-Dist: httpx>=0.27; extra == 'httpx'
Description-Content-Type: text/markdown

# narrativetrace-asgi

Pure-ASGI middleware that captures one [narrativetrace](../narrativetrace) trace tree per HTTP
request. Compatible with Starlette and FastAPI.

* **Fail-safe** — throwing request/user extractors or exporters never fail the request and never
  mask the handler's own exception.
* **Request-boundary export** — the captured tree is exported in a `finally` block with the real
  status code and duration; an empty tree is never exported.
* **W3C `traceparent`** — inbound trace-id adoption plus an outbound injection helper for `httpx`.
* **Request-scoped accessor** — `get_narrative_context()` returns the context bound to the
  in-flight request (contextvars-based, so concurrent requests are isolated).
