-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: xray_trace_id is not populated in log lines #773
Comments
Hello @humanzz, thanks for opening this issue. I made a couple of tests and was able to reproduce the behaviour you describe also in the latest version ( We will be looking at a fix for this. |
After a closer look I just realised that it's not possible to piggy back on The above would contradict with the statement (docs) that Will be looking at alternatives. |
A fix is available in #776, it will be most probably included in one of the next two releases based on time needed for review & merge. |
Thanks @dreamorosi, really appreciate the prompt action. I'll keep an eye for the upcoming releases |
|
Bug description
According to documentation, the
xray_trace_id
should be emitted in all log lines if the request is traced. However, I'm not seeing any setting of that field in my logs despite theREPORT
log line showing the request is traced.Expected Behavior
All log lines to have
xray_trace_id
populated if the request is traced (as confirmed byREPORT
line).Current Behavior
No log lines showing the
xray_trace_id
.Possible Solution
I've read a little bit in the code in Logger.ts and I suspect that xRayTraceId is set only once at
Logger
construction time.The traceId is read via an environment variable that'll change for each different request. As such, I think a possible solution is to leverage
addContext
to also set that value when calling this.addToPowertoolLogDataThe actual behaviour I've seen is that
xray_trace_id
is not being written to the logs. If my understanding is correct, I believe this issue can be manifested in 1 of 2 waysxray_trace_id
which is likely to happen if the first request is not traced (i.e. cold start request). In this case all subsequent requests will not have the fieldxray_trace_id
(not observed) if the first request is traced and the environment variables is read and the field is set in Logger's state but subsequent requests will not update that value.Steps to Reproduce
For a handler looking like
xray_trace_id
in the different requests (especially those whereREPORT
line indicates request is traced)xray_trace_id
is missingEnvironment
Related issues, RFCs
N/A
The text was updated successfully, but these errors were encountered: