open-telemetry / open-telemetry/opentelemetry-cpp-contrib
[nginx] configure with environment variables ?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 153
- Forks
- 184
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 26
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided Dockerfile and nginx.conf, then compare the environment-variable setup with the nginx instrumentation README section linked in the issue. Reproduce the configuration with curl localhost:8080/ping and determine whether the injected variables are supported; done means the behavior is fixed or the documented limitation is made clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nginx
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100