Skip to content
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

Set opentracing context for a request in an earlier phase #85

Closed
ElvinEfendi opened this issue Feb 20, 2019 · 5 comments
Closed

Set opentracing context for a request in an earlier phase #85

ElvinEfendi opened this issue Feb 20, 2019 · 5 comments

Comments

@ElvinEfendi
Copy link

I'm working on kubernetes/ingress-nginx#3783 to enable tracing of each Nginx phase we run Lua code. I've noticed that ngx.var.opentracing_binary_context is not set at rewrite phase and when I try to access it in Lua I get:

2019/02/20 14:40:54 [error] 42#42: *374 failed to expand opentracing_context_ for request 0000564FD8E6D060: no OpenTracingContext attached to request, client: 172.17.0.1, server: example.com, request: "GET /echo HTTP/1.1", host: "example.com"

Looking at the source code, I noticed that opentracing runs after rewrite phase:

&core_main_config->phases[NGX_HTTP_PREACCESS_PHASE].handlers));

Can we inject it at NGX_HTTP_POST_READ_PHASE or NGX_HTTP_SERVER_REWRITE_PHASE? According to http://nginx.org/en/docs/dev/development_guide.html#http_phases NGX_HTTP_POST_READ_PHASE is the earliest phase.

@rnburn
Copy link
Collaborator

rnburn commented Feb 20, 2019

I think that would be ok. Can you try making the change and seeing if it breaks anything?

@ElvinEfendi
Copy link
Author

I'll give it a try, but not sure when.

terrynsun added a commit to terrynsun/nginx-opentracing that referenced this issue May 14, 2019
Subrequests begin their lives in the server-rewrite phase, so this
module is still loaded for subrequests.
@terrynsun
Copy link
Contributor

terrynsun commented May 14, 2019

I moved it to the SERVER_REWRITE phase, because when I moved it earlier than the SERVER_REWRITE phase, the module doesn't get loaded for subrequests. This seems to work fine for me. [Edit: except apparently I'm not passing the tests. I'll take a look.]

@ElvinEfendi
Copy link
Author

@terrynsun SERVER_REWRITE is probably good enough, maybe open a PR so that the maintainer can help with tests.

terrynsun added a commit to terrynsun/nginx-opentracing that referenced this issue May 17, 2019
Subrequests begin their lives in the server-rewrite phase, so this
module is still loaded for subrequests.
rnburn pushed a commit that referenced this issue May 21, 2019
Subrequests begin their lives in the server-rewrite phase, so this
module is still loaded for subrequests.
myob-geoff-speirs added a commit to myob-geoff-speirs/nginx-opentracing that referenced this issue Jul 9, 2019
myob-geoff-speirs added a commit to myob-geoff-speirs/nginx-opentracing that referenced this issue Jul 9, 2019
@rnburn
Copy link
Collaborator

rnburn commented Aug 20, 2019

Done in #98

@rnburn rnburn closed this as completed Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants