Skip to content

Commit

Permalink
Strip out numbers from paths
Browse files Browse the repository at this point in the history
  This is so we can better aggregate by path in cloudwatch
  • Loading branch information
caparker committed Feb 7, 2024
1 parent 26d9503 commit cae7a5c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions openaq_api/openaq_api/models/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from fastapi import Request, status
from humps import camelize
from pydantic import BaseModel, ConfigDict, Field, computed_field

import re

class LogType(StrEnum):
SUCCESS = "SUCCESS"
Expand Down Expand Up @@ -107,8 +107,8 @@ def user_agent(self) -> str:
@computed_field(return_type=str)
@property
def path(self) -> str:
"""str: returns URL path from request"""
return self.request.url.path
"""str: returns URL path from request but replaces numbers in the path with :id"""
return re.sub(r'/[0-9]+', '/:id', self.request.url.path)

@computed_field(return_type=str)
@property
Expand Down

0 comments on commit cae7a5c

Please sign in to comment.