Page MenuHomePhabricator

[keyserver] Introduce `logEndpointMetrics` and `yarn dev-log-metrics`
ClosedPublic

Authored by atul on Sep 27 2023, 12:44 PM.
Tags
None
Referenced Files
F3369692: D9308.diff
Mon, Nov 25, 11:15 PM
Unknown Object (File)
Sun, Nov 24, 5:50 PM
Unknown Object (File)
Fri, Nov 22, 4:53 PM
Unknown Object (File)
Fri, Nov 22, 4:46 PM
Unknown Object (File)
Sat, Nov 16, 9:28 PM
Unknown Object (File)
Sat, Nov 16, 9:28 PM
Unknown Object (File)
Sat, Nov 16, 9:28 PM
Unknown Object (File)
Sat, Nov 16, 9:28 PM
Subscribers
None

Details

Summary

Introduce logEndpointMetrics middleware (on Express middleware: https://expressjs.com/en/guide/using-middleware.html) to log request-response duration and Content-Length for each endpoint.

This middleware is enabled when KEYSERVER_ENDPOINT_METRICS_ENABLED is set.

Will introduce a separate yarn command to write logs to disk

Test Plan

Logs look as expected when KEYSERVER_ENDPOINT_METRICS_ENABLED is set:

dc3255.png (1×1 px, 517 KB)

Logs don't appear when KEYSERVER_ENDPOINT_METRICS_ENABLED is unset.

Diff Detail

Repository
rCOMM Comm
Branch
master
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

atul published this revision for review.Sep 27 2023, 12:44 PM
atul edited the test plan for this revision. (Show Details)

resolve flow issues, no easy way to use performance.now() without typing it myself, so using Date.now() for timebeing which is probably more than accurate enough

This revision is now accepted and ready to land.Sep 27 2023, 3:19 PM
This revision was landed with ongoing or failed builds.Sep 27 2023, 4:23 PM
This revision was automatically updated to reflect the committed changes.
keyserver/src/middleware/endpoint_profiling.js
3 ↗(On Diff #31473)

Nit: filename should've been endpoint-profiling.js instead of endpoint_profiling.js to match conventions