Rewrite doesn't generate a trace
PandeoF1 opened this issue · 6 comments
Describe the bug
Hi, i have an nginx configurated with some location.
[...]
location /test {
otel_trace on;
otel_trace_context propagate;
index index.html
}
location /api {
rewrite /api/(.*) /private_api/$1 break;
otel_trace on;
otel_trace_context propagate;
proxy_pass $api;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
[...]
I also have a rewrite confs :
rewrite ^/api/(.*) /api/$1 break;
rewrite ^/[^/]+(/.*)$ $1 break;
rewrite ^/[^/]+/(api/.*)$ /$1 break;
When i hit /test
the trace are succesfully created
But with /client_name/api/...
there is no trace.
I think that otel don't want to create a trace because he detect /client_name/api/
and not /api/
after the
Expected behavior
I want a trace for location after the rewrite
(before: /client_name/api/
-> after: /api/
)
Your environment
FROM nginxinc/nginx-unprivileged:1.25.4-bookworm
[...]
USER root
RUN apt update
RUN apt install curl gnupg2 ca-certificates lsb-release debian-archive-keyring -y
RUN curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor | tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
RUN echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/mainline/debian `lsb_release -cs` nginx" \
| tee /etc/apt/sources.list.d/nginx.list
RUN apt update
RUN apt install nginx-module-otel -y
USER nginx
EXPOSE 80 443
[...]
### Additional context
Add any other context about the problem here.
Can you provide minimal and complete config example to reproduce the issue? I'd guess, that "/private_api" location disables tracing.
Can you provide minimal and complete config example to reproduce the issue? I'd guess, that "/private_api" location disables tracing.
/api just rewrite to /private_api on the $host.
There is nothing in more in the configuration.
My problem is that otel logs /api but when it's rewrite to /private_api otel don't detect it
In my logs when i hit /api
it write /private_api
because it's rewrited, it's why i think otel doesn't detect it
I was able to reproduce the issue, basically server level rewrites prevent trace generation. We'll need to fix that.
Location level rewrites, though, shouldn't prevent trace generation, as long as initial location has tracing enabled.
I was able to reproduce the issue, basically server level rewrites prevent trace generation. We'll need to fix that. Location level rewrites, though, shouldn't prevent trace generation, as long as initial location has tracing enabled.
Hi @p-pautov !
Sorry for the ping but do you know if this issue will be patched in the next weeks ?
Thanks in advance !
Possibly. Rearranging config to avoid server level rewrites might be an option, in the meantime.