You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
현재 로그를 구분하는 식별자는 auto-increment하는 정수값으로 자동 삽입됩니다.
로그에 unique한 Request ID와 User ID가 있으면 Production 환경에서 로그를 분석할 때 편리할 것입니다.
Solution (request ID)
UUIDv4로 unique한 식별자를 생성할 수 있음. 들어오는 모든 요청에 대해 request ID를 들려 보내는 미들웨어를 만들어 볼 수 있음.
문제는 생성한 ID를 어떻게 전달하느냐.
CLS (continuation-local storage)
Node.js에서 Thread Local Storage의 대안. 여기에 request id를 집어넣고 가져다 쓸 수 있음. 그러나, prisma의 rust-based engine 관련 이슈로 context가 유지되지 않아 prisma에서는 CLS를 사용할 수 없음.
request 객체에 X-Request-Id 헤더를 집어넣고, 사용할 때마다 request 객체에서 전달전달~
Solution (user ID)
JWT Auth Guard를 거치면서 req.user.id가 생성됨. 이 값을 logger에 전달하면 되는데, 어떻게 하지..?
Describe the problem and solution
Problem
현재 로그를 구분하는 식별자는 auto-increment하는 정수값으로 자동 삽입됩니다.
로그에 unique한 Request ID와 User ID가 있으면 Production 환경에서 로그를 분석할 때 편리할 것입니다.
Solution (request ID)
UUIDv4로 unique한 식별자를 생성할 수 있음. 들어오는 모든 요청에 대해 request ID를 들려 보내는 미들웨어를 만들어 볼 수 있음.
문제는 생성한 ID를 어떻게 전달하느냐.
Node.js에서 Thread Local Storage의 대안. 여기에 request id를 집어넣고 가져다 쓸 수 있음. 그러나, prisma의 rust-based engine 관련 이슈로 context가 유지되지 않아 prisma에서는 CLS를 사용할 수 없음.
Solution (user ID)
JWT Auth Guard를 거치면서 req.user.id가 생성됨. 이 값을 logger에 전달하면 되는데, 어떻게 하지..?
Validations
The text was updated successfully, but these errors were encountered: