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
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
Unknown Object (File)
Sat, Nov 16, 9:28 PM
Unknown Object (File)
Sat, Nov 16, 9:25 PM
Unknown Object (File)
Oct 23 2024, 5:27 AM
Unknown Object (File)
Oct 23 2024, 5:13 AM
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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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

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