Skip to content

Instantly share code, notes, and snippets.

@Condla
Last active November 27, 2023 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Condla/42e34a85a6e80c1ac1a6e1c12f21f5ee to your computer and use it in GitHub Desktop.
Save Condla/42e34a85a6e80c1ac1a6e1c12f21f5ee to your computer and use it in GitHub Desktop.
This is a working example config of nginx server emitting OTel traces. To test this setup run curl localhost:8080/produce_200 or any of the other included proxy_pass configs.
load_module modules/ngx_otel_module.so;
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
otel_exporter {
endpoint localhost:4317;
}
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
otel_service_name nginxtest;
server {
listen 127.0.0.1:8080;
location /produce_404 {
otel_trace on;
otel_trace_context inject;
proxy_pass http://www.example.com/;
}
location /produce_200 {
otel_trace on;
otel_trace_context propagate;
proxy_pass http://www.example.com/;
}
location /produce_301 {
otel_trace on;
otel_span_name this_produces_a_301;
proxy_pass http://pokeapi.co/api/v2/berry/2;
}
location /produce_502 {
otel_trace on;
proxy_pass https://pokeapi.co/api/v2/berry/2;
}
}
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment