Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ def setup_telemetry(app: FastAPI) -> None:
"""
logger.info("🔧 Setting up telemetry...")

# Add startup event for telemetry initialization
@app.on_event("startup")
# Use router events instead of deprecated on_event
async def startup_telemetry():
logger.info("📊 Telemetry initialized successfully")
logger.info(f"📍 Application: {app.title} v{app.version}")

# Add shutdown event for cleanup
@app.on_event("shutdown")
async def shutdown_telemetry():
logger.info("📊 Telemetry shutdown complete")

app.router.on_startup.append(startup_telemetry)
app.router.on_shutdown.append(shutdown_telemetry)
Comment on lines +47 to +48
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of app.router.on_startup and app.router.on_shutdown is deprecated in modern FastAPI versions and conflicts with the lifespan pattern already used in main.py. Since main.py already uses a lifespan context manager (lines 28-47), the recommended approach is to either:

  1. Move this telemetry initialization into the existing lifespan context manager in main.py, OR
  2. Use the new lifespan parameter approach with dependency injection

The current implementation appending to router events is discouraged when a lifespan handler is already defined, as it can lead to unpredictable execution order and maintenance issues.

Copilot uses AI. Check for mistakes.

logger.info("✅ Telemetry setup complete")


Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ known_third_party = ["fastapi", "pydantic", "starlette"]
combine_as_imports = true
force_sort_within_sections = true
lines_after_imports = 2


[tool.black]
line-length = 88
target-version = ["py312"]
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jinja2==3.1.6
requests==2.32.4
httpx==0.27.0

pytest==8.2.0
pytest==8.4.2
pytest-asyncio==0.23.6
pytest-cov==5.0.0

Expand Down