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

[nginx] configure with environment variables ? #515

Open
sinux-l5d opened this issue Jan 27, 2025 · 0 comments
Open

[nginx] configure with environment variables ? #515

sinux-l5d opened this issue Jan 27, 2025 · 0 comments
Labels

Comments

@sinux-l5d
Copy link

Describe your environment
nginx 1.27.1

Steps to reproduce
Dockerfile:

FROM nginx:1.27.1-alpine

RUN apk update \
  && apk add --no-cache tzdata \
  && apk add --no-cache libprotobuf \
  && wget https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/download/nginx%2Fv0.1.1/otel_ngx_module-alpine-3.20-1.27.1.so -O /usr/lib/nginx/modules/otel_ngx_module.so \
  && chmod +x /usr/lib/nginx/modules/otel_ngx_module.so

nginx.conf:

load_module /etc/nginx/modules/otel_ngx_module.so;

env OTEL_COLLECTOR_SERVICE;
env OTEL_SERVICE_NAME;
env OTEL_EXPORTER_OTLP_ENDPOINT;
env OTEL_RESOURCE_ATTRIBUTES_POD_NAME;
env OTEL_RESOURCE_ATTRIBUTES_POD_UID;
env OTEL_RESOURCE_ATTRIBUTES_NODE_NAME;
env OTEL_PROPAGATOR;
env OTEL_TRACES_SAMPLER;
env OTEL_TRACES_SAMPLER_ARG;
env OTEL_RESOURCE_ATTRIBUTES;

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    server {
        listen 8080;
        server_name _;

        location /ping {
            return 200 "pong!";
        }
    }

    include /etc/nginx/conf.d/*.conf;
}

What is the expected behavior?

If I understand correctly, webserver autoinstrumentation is far behind (nginx 1.23). So I'm building my container with the Dockerfile above to use the nginx "manual" instrumentation.

However, I'm using kubernetes and I'd like to use env vars injection, say with instrumentation.opentelemetry.io/inject-sdk annotation. As described here, it sounds possible to use env vars. But the nginx.conf configuration above doesn't send the traces to my otel collector.

What is the actual behavior?

With the described configuration, the nginx cpp module doesn't seem to pick the env var and does not send variables

Additional context

I'm testing with :

curl localhost:8080/ping
@sinux-l5d sinux-l5d added the instrumentation:nginx Nginx module label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant