Skip to content

src/dazzle_back/runtime/api_middleware.py

Generated: 2026-03-30T04:38:46.753436+00:00

Commit: 615f1354a103

Language: python

Scope: dazzle_back

Purpose

API Tracking Middleware.

FastAPI middleware that automatically tracks outbound API calls when using the integrated HTTP client.

Also provides request correlation for tracing API calls back to the originating user request.

Key Exports

  • get_correlation_id
  • get_tenant_id
  • get_user_id
  • RequestContext
  • ApiTrackingMiddleware
  • add_api_tracking_middleware
  • create_correlation_middleware
  • create_tracked_client
  • current
  • CorrelationMiddleware
  • ContextAwareTrackedClient
  • send_with_correlation
  • dispatch
  • request

Dependencies

Imports

  • contextvars
  • dataclasses.dataclass
  • typing.Any
  • uuid.uuid4
  • fastapi.FastAPI
  • fastapi.Request
  • fastapi.Response
  • starlette.middleware.base.RequestResponseEndpoint
  • dazzle_back.runtime.api_tracker.ApiTracker
  • starlette.middleware.base.BaseHTTPMiddleware
  • dazzle_back.runtime.api_tracker.TrackedHttpxClient

Event Interactions

None detected.

Invariants and Assumptions

No invariants documented.

Tests

  • tests/integration/test_runtime_e2e.py
  • tests/integration/test_runtime_pipeline.py
  • tests/unit/test_runtime_test_routes.py
  • tests/unit/test_runtime_services.py
  • tests/unit/test_runtime_mcp_tools.py

Notes

This page was automatically generated by tools/gen_reference_docs.py.