bcgov / digital_marketplace

The intent of this development is to build a product that will support digital procurement needs for the BC Government including services such as, but not limited to, Sprint With Us, Code With Us, The Procurement Concierge.
Apache License 2.0
13 stars 17 forks source link

Dm1134 logging with Node memory usage #360

Closed sutherlanda closed 1 year ago

sutherlanda commented 1 year ago

This PR adds configurable logging in production.

Two new configuration parameters were added for the back-end:

LOG_DEBUG --> enables debug-level logging in production (per-request) LOG_MEM_USAGE --> enables logging memory usage metrics (also requires debug level logging to be enabeld)

Below is an example of the memory usage logging that will be include with each request log:

[request:2f6aaba1-3382-4f28-9a98-38766ee3c5a4] -> GET /images/wayne.jpg sessionId="anonymous"
[request:2f6aaba1-3382-4f28-9a98-38766ee3c5a4] <- 200 1ms
[request:2f6aaba1-3382-4f28-9a98-38766ee3c5a4] memory usage arrayBuffers="0.74 MB" external="2.38 MB" heapUsed="55.83 MB" heapTotal="85.02 MB" rss="147.23 MB"
[request:516acefb-7879-4b39-a203-e5c05e4841dd] -> GET /fonts/BCSans/BCSans-Bold.woff2 sessionId="anonymous"
[request:516acefb-7879-4b39-a203-e5c05e4841dd] <- 200 0ms
[request:516acefb-7879-4b39-a203-e5c05e4841dd] memory usage arrayBuffers="0.95 MB" external="2.6 MB" heapUsed="55.92 MB" heapTotal="85.02 MB" rss="147.28 MB"
[request:b23f2c52-86f9-42d0-9dfc-b31059ab0ee6] -> GET /fonts/BCSans/BCSans-Regular.woff2 sessionId="anonymous"
[request:b23f2c52-86f9-42d0-9dfc-b31059ab0ee6] <- 200 1ms
[request:b23f2c52-86f9-42d0-9dfc-b31059ab0ee6] memory usage arrayBuffers="1.15 MB" external="2.79 MB" heapUsed="55.99 MB" heapTotal="85.02 MB" rss="147.3 MB"

Here is a good explanation of the memory usage metrics.