Skip to content

Commit 2670ca2

Browse files
authored
Merge pull request #3038 from fractal-analytics-platform/millisec
Simplify middleware timestamp formatting
2 parents df1eace + ab77096 commit 2670ca2

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The main contents of this release are the introduction of the project sharing an
1717
* Modify `GET /auth/current-user/allowed-viewer-paths/` logic, with `include_shared_projects` query parameter (\#3031).
1818
* Add validator for paths to forbid parent-directory references (\#3031).
1919
* App:
20-
* Add `SlowResponseMiddleware` middleware (\#3035).
20+
* Add `SlowResponseMiddleware` middleware (\#3035, \#3038).
2121
* Settings:
2222
* Add `Settings.FRACTAL_LONG_REQUEST_TIME` configuration variable (\#3035).
2323
* Database:

fractal_server/main.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ async def lifespan(app: FastAPI):
134134

135135
slow_response_logger = set_logger("slow-response")
136136

137-
MIDDLEWARE_DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S.%f"
138-
139137

140138
class SlowResponseMiddleware:
141139
def __init__(self, app: FastAPI, time_threshold: float):
@@ -171,8 +169,8 @@ async def send_wrapper(message: Message):
171169
f"?{scope['query_string'].decode('utf-8')}, "
172170
f"{context['status_code']}, "
173171
f"{request_time:.2f}, "
174-
f"{start_timestamp.strftime(MIDDLEWARE_DATETIME_FORMAT)}, "
175-
f"{end_timestamp.strftime(MIDDLEWARE_DATETIME_FORMAT)}"
172+
f"{start_timestamp.isoformat(timespec='milliseconds')}, "
173+
f"{end_timestamp.isoformat(timespec='milliseconds')}"
176174
)
177175

178176

0 commit comments

Comments
 (0)