-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (29 loc) · 1.12 KB
/
main.py
File metadata and controls
36 lines (29 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""FastAPI application entrypoint.
Heavy lifting lives in dedicated modules under ``app.core`` and
``app.api``; this file only wires them together so a reader can see the
whole composition at a glance.
"""
from fastapi import FastAPI
from app.api.exception_handlers import register_exception_handlers
from app.api.main import api_router
from app.core.config import settings
from app.core.lifespan import lifespan
from app.core.metrics import init_metrics
from app.core.middleware import register_middleware
from app.core.openapi import custom_generate_unique_id
from app.core.sentry import init_sentry
from app.core.telemetry import init_telemetry
init_sentry()
app = FastAPI(
title=settings.PROJECT_NAME,
openapi_url=f"{settings.API_V1_STR}/openapi.json",
generate_unique_id_function=custom_generate_unique_id,
lifespan=lifespan,
)
register_exception_handlers(app)
register_middleware(app)
app.include_router(api_router, prefix=settings.API_V1_STR)
# OpenTelemetry tracing — no-op unless OTEL_EXPORTER_OTLP_ENDPOINT is set.
init_telemetry(app)
# Prometheus instrumentation + gated /metrics endpoint.
init_metrics(app)