https://github.com/opentracing-contrib/nginx-opentracing
Enable requests served by nginx for distributed tracing via The OpenTracing Project.
- The C++ OpenTracing Library
- A C++ OpenTracing Tracer. It currently works with either Zipkin or LightStep.
- Source for Nginx 1.9.13 or later.
A docker image rnburn/nginx-opentracing
is provided to support using nginx with OpenTracing
in a manner analogous to the nginx Docker image.
See here for examples of how to use it.
$ tar zxvf nginx-1.9.x.tar.gz
$ cd nginx-1.9.x
$ export NGINX_OPENTRACING_VENDOR="ZIPKIN" # or export NGINX_OPENTRACING_VENDOR="LIGHTSTEP"
$ ./configure --add-dynamic-module=/absolute/path/to/nginx-opentracing/opentracing \
# To enable tracing with Zipkin
--add-dynamic-module=/absolute/path/to/nginx-opentracing/zipkin \
# To enable tracing with LightStep
--add-dynamic-module=/absolute/path/to/nginx-opentracing/lightstep
$ make && sudo make install
# Load the OpenTracing dynamic module.
load_module modules/ngx_http_opentracing_module.so;
# Load a vendor OpenTracing dynamic module.
# For example,
# load_module modules/ngx_http_lightstep_module.so;
# or
# load_module modules/ngx_http_zipkin_module.so;
http {
# Configure your vendor's tracer.
# For example,
# lightstep_access_token ACCESSTOKEN;
# ....
# or
# zipkin_collector_host localhost;
# ...
# Enable tracing for all requests.
opentracing on;
# Optionally, set additional tags.
opentracing_tag http_user_agent $http_user_agent;
location ~ \.php$ {
# The operation name used for spans defaults to the name of the location
# block, but you can use this directive to customize it.
opentracing_operation_name $uri;
fastcgi_pass 127.0.0.1:1025;
}
}
See Tutorial for a more complete example, Reference for a list of available OpenTracing-related directives, and LightStep and Zipkin for a list of vendor tracing directives.