matrix-org / matrix-org/matrix-viewer

Request logging

Open
#9 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

dev-notes T-Task
Dominant language
JavaScript
Stars
84
Forks
10
PR merge metrics
No merged PRs in 30d

Description

Basically we want per-request logging where logs that happen within a Express request can be correlated together (span). We need to store a request ID in the context of a request and be able to get the request ID without needing to pass around `request` everywhere.

- https://www.izertis.com/en/-/blog-express-js-logging-info-with-global-unique-request-id-node-js
- Talks about using [`express-http-context`](https://www.npmjs.com/package/express-http-context) and wrapping `winston` to include the request ID in the logs
- Uses `cls-hooked` under the hood which is "Continuation-Local Storage" and the equivalent to "Thread Local Storage" (TLS) for Node.js in the call stack context (and `async_hooks`).
- https://javascript.plainenglish.io/simple-request-specific-logging-for-node-js-212bb2c0e887
- [`async_hooks`](https://nodejs.org/docs/latest-v16.x/api/async_hooks.html) are still "[Stability: 1](https://nodejs.org/docs/latest-v16.x/api/documentation.html#stability-index) - Experimental",
- Links to an interesting performance analysis about the performance hit when using `async_hooks`, https://github.com/bmeurer/async-hooks-performance-impact

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the repository's Express request-handling and logging entry points, then compare the referenced express-http-context, cls-hooked, winston, and async_hooks approaches. The issue is complete when request IDs can be stored per request and included in correlated logs without passing request through every call, with the performance tradeoff addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
express, javascript, node.js
Domain
backend, observability
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.