Gate W3C trace support to request phases with ngx.var access#345
Conversation
5217ac3 to
9eff4ce
Compare
|
Reviewed documentation and code:
|
|
Phases not listed as supported in https://openresty-reference.readthedocs.io/en/latest/Lua_Nginx_API/#ngxvarvariable:
Accessible via |
|
|
|
Thanks for taking a look. That works for me - I updated the allow list. I also had to make some changes to the test workflow because of the Node.js 20 deprecation and an ancient OpenResty image (or more accurately it's Alpine base) which doesn't support Node.js 24. |
The http library reads ngx.var.http_traceparent in send_request to propagate W3C trace context. ngx.var is only readable in request-bearing phases, so this crashes code running in init/init_worker. Gate the read on ngx.get_phase() being in a request-bearing phase via a whitelist, so request-less phases (init, init_worker, timer, etc.) are excluded by default. Behavior is unchanged for real requests.
71c06aa to
4e9afaa
Compare
|
This PR fixes PR #340 which added the |
The http library reads ngx.var.http_traceparent in send_request to propagate W3C trace context. ngx.var is only readable in request-bearing phases, so this crashes code running in init/init_worker.
Gate the read on ngx.get_phase() being in a request-bearing phase via a whitelist, so request-less phases (init, init_worker, timer, etc.) are excluded by default. Behavior is unchanged for real requests.