Skip to content

Commit 3abf298

Browse files
committed
feat: add x-upstream-time header
1 parent 8d006ef commit 3abf298

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/stac_auth_proxy/proxy.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import time
23
from dataclasses import dataclass
34
from urllib.parse import urlparse
45

@@ -41,10 +42,14 @@ async def passthrough(self, request: Request):
4142
)
4243
logger.debug(f"Proxying request to {rp_req.url}")
4344

45+
start_time = time.perf_counter()
4446
rp_resp = await self.client.send(rp_req, stream=True)
47+
proxy_time = time.perf_counter() - start_time
48+
4549
logger.debug(
46-
f"Received response status {rp_resp.status_code!r} from {rp_req.url}"
50+
f"Received response status {rp_resp.status_code!r} from {rp_req.url} in {proxy_time:.3f}s"
4751
)
52+
rp_resp.headers["X-Upstream-Time"] = f"{proxy_time:.3f}"
4853

4954
return StreamingResponse(
5055
rp_resp.aiter_raw(),

0 commit comments

Comments
 (0)