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

Rewrite doesn't generate a trace #47

Open
PandeoF1 opened this issue Mar 29, 2024 · 6 comments
Open

Rewrite doesn't generate a trace #47

PandeoF1 opened this issue Mar 29, 2024 · 6 comments

Comments

@PandeoF1
Copy link

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.
@p-pautov
Copy link
Contributor

Can you provide minimal and complete config example to reproduce the issue? I'd guess, that "/private_api" location disables tracing.

@PandeoF1
Copy link
Author

PandeoF1 commented Apr 5, 2024

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

@PandeoF1
Copy link
Author

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

@p-pautov
Copy link
Contributor

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.

@PandeoF1
Copy link
Author

PandeoF1 commented May 2, 2024

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 !

@p-pautov
Copy link
Contributor

p-pautov commented May 9, 2024

Possibly. Rearranging config to avoid server level rewrites might be an option, in the meantime.

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

2 participants