Skip to content

Commit 2a10d6d

Browse files
committed
Update logging
1 parent 03bc9e3 commit 2a10d6d

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

code/function/fastapp/main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55

66
def get_app() -> FastAPI:
7+
"""Setup the Fast API server.
8+
9+
RETURNS (FastAPI): The FastAPI object to start the server.
10+
"""
711
app = FastAPI(
812
title=settings.PROJECT_NAME,
913
version=settings.APP_VERSION,
@@ -19,9 +23,11 @@ def get_app() -> FastAPI:
1923

2024
@app.on_event("startup")
2125
async def startup_event():
26+
"""Gracefully start the application before the server reports readiness."""
2227
pass
2328

2429

2530
@app.on_event("shutdown")
2631
async def shutdown_event():
32+
"""Gracefully close connections before shutdown of the server."""
2733
pass

code/function/fastapp/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
from logging import Logger
33

44
from fastapp.core.config import settings
5+
from opencensus.extension.azure.functions import OpenCensusExtension
6+
from opencensus.trace import config_integration
7+
8+
config_integration.trace_integrations(["requests"])
9+
OpenCensusExtension.configure()
510

611

712
def setup_logging(module) -> Logger:

code/function/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
azure-functions~=1.14.0
66
fastapi~=0.96.1
77
aiohttp~=3.8.4
8+
opencensus-extension-azure-functions~=1.0.0
9+
opencensus-ext-requests~=0.8.0

0 commit comments

Comments
 (0)