Skip to content

Commit

Permalink
Merge pull request #5 from CaseyTa/health_filter
Browse files Browse the repository at this point in the history
Filter out health from access log
  • Loading branch information
micheldumontier authored Aug 27, 2024
2 parents 588d845 + 05c2e84 commit 2c962cd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/trapi_predict_kit/trapi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import time
from typing import Any, Callable, Dict, List, Optional
import logging

from fastapi import Body, FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
Expand Down Expand Up @@ -317,3 +318,9 @@ def add_opentelemetry(app: FastAPI, service_name: str) -> None:
# FastAPIInstrumentor.instrument_app(app, tracer_provider=trace, excluded_urls="docs,openapi.json")
RequestsInstrumentor().instrument()
HTTPXClientInstrumentor().instrument()

# Filter out /health endpoint to stop flooding uvicorn log
class EndpointFilter(logging.Filter):
def filter(self, record: logging.LogRecord) -> bool:
return record.getMessage().find("/health") == -1
logging.getLogger("uvicorn.access").addFilter(EndpointFilter())

0 comments on commit 2c962cd

Please sign in to comment.