Skip to content

Commit

Permalink
Use structlog filter for status endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
rsbowman-striveworks committed Feb 12, 2024
1 parent 8523d50 commit ab2a1fd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
15 changes: 15 additions & 0 deletions api/velour_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,23 @@
logging_level = 20


def status_endpoint_filter(
logger,
method_name,
event_dict,
ignore_paths=frozenset(["/health", "/ready"]),
):
if (
event_dict.get("path", "") in ignore_paths
and event_dict.get("status", 0) == 200
):
raise structlog.DropEvent
return event_dict


structlog.configure(
processors=[
status_endpoint_filter,
structlog.processors.add_log_level,
structlog.processors.TimeStamper(fmt="iso"),
structlog.processors.dict_tracebacks,
Expand Down
3 changes: 0 additions & 3 deletions api/velour_api/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
def log_endpoint(
request: Request,
status_code: Optional[int],
ignore_paths=frozenset(["/health", "/ready"]),
):
if request.url.path in ignore_paths and status_code == 200:
return
logger.info(
"Velour API Call",
method=request.method,
Expand Down

0 comments on commit ab2a1fd

Please sign in to comment.