nginxinc/nginx-otel

Any Guide to move from `opentelemetry-cpp-contrib` to this

Closed this issue · 1 comments

Is your feature request related to a problem? Please describe

We are currently using the Open Telemetry Web Module for NGINX and its kind of a pain to deploy, not super maintained etc. In our testing, this is much easier to use/deploy, but it doesn't work with out currently app set.

Describe the solution you'd like

Something to document the main differences/gotchas when migrating.

Describe alternatives you've considered

N/A

Additional context

Basic Example, we have NGINX running in docker, acting as a proxy to a Python Fast API App with uvicorn.

So for the Open Telemetry Web Module you just do something like

load_module /opt/opentelemetry-webserver-sdk/WebServerModule/Nginx/1.24.0/ngx_http_opentelemetry_module.so;

http {
  ...
  include /etc/nginx/conf.d/opentelemetry_module.conf;

  server {
      ...
      proxy_pass http://${APP_HOST}:${APP_PORT};

Where the opentelemetry_module.conf file just sets up where you are tracing too, and service names.

NginxModuleEnabled ON;
NginxModuleOtelSpanExporter otlp;
NginxModuleOtelExporterEndpoint ${COLLECTOR_HOST}:4317;
NginxModuleServiceName ${SERVICE_NAME};
NginxModuleServiceNamespace ${TREX_ENV};
NginxModuleServiceInstanceId ${DEPLOYMENT_ID};
NginxModuleResolveBackends ON;
NginxModuleTraceAsError ${TRACE_ERRORS};

The equivalent setup with nginx-otel is something like

load_module modules/ngx_otel_module.so;
http {
  otel_exporter {
      endpoint ${COLLECTOR_HOST}:4317;
  }

  otel_service_name ${SERVICE_NAME};
  otel_trace on;

  server {
    ...
    location / {
      proxy_pass http://${APP_HOST}:${APP_PORT};

This does work in the sense that I get nginx traces. The problem is they are no longer associated between nginx and the fronting application.

Trace id's

FastAPI - d6547050b9ce70d614328b6e47ea283c
NGINX   - 208243709646b4a141b0436be8c1bee5

Im sure the problem is on my side, but I cant really find documentation on how to tie this together, or move from OTLP Web Module to the nginx-otel module.

Most likely, you are missing otel_trace_context inject; (or otel_trace_context propagate;) in your config. It seems that "webserver module" just doesn't provide toggle to control this. There is some documentation here.