Skip to content

Commit 585499c

Browse files
authored
Support latest Zipkin tracer (#159)
* Built Zipkin tracer in docker image * Update example to test Zipkin Nginx config
1 parent 1ff1b00 commit 585499c

File tree

6 files changed

+51
-7
lines changed

6 files changed

+51
-7
lines changed

Dockerfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ ARG NGINX_LABEL=latest
33
FROM nginx:${NGINX_LABEL}
44

55
ARG OPENTRACING_CPP_VERSION=v1.6.0
6+
ARG ZIPKIN_CPP_VERSION=master
67
ARG JAEGER_CPP_VERSION=v0.7.0
78
ARG GRPC_VERSION=v1.27.x
8-
ARG DATADOG_VERSION="master"
9+
ARG DATADOG_VERSION=master
910

1011
COPY . /src
1112

@@ -63,6 +64,15 @@ RUN set -x \
6364
-DBUILD_TESTING=OFF .. \
6465
&& make && make install \
6566
&& cd "$tempDir" \
67+
### Build zipkin-cpp-opentracing
68+
&& apt-get --no-install-recommends --no-install-suggests -y install libcurl4-gnutls-dev \
69+
&& git clone --depth 1 -b $ZIPKIN_CPP_VERSION https://github.com/rnburn/zipkin-cpp-opentracing.git \
70+
&& cd zipkin-cpp-opentracing \
71+
&& mkdir .build && cd .build \
72+
&& cmake -DBUILD_SHARED_LIBS=1 -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF .. \
73+
&& make && make install \
74+
&& cd "$tempDir" \
75+
&& ln -s /usr/local/lib/libzipkin_opentracing.so /usr/local/lib/libzipkin_opentracing_plugin.so \
6676
### Build Jaeger cpp-client
6777
&& git clone --depth 1 -b $JAEGER_CPP_VERSION https://github.com/jaegertracing/cpp-client.git jaeger-cpp-client \
6878
&& cd jaeger-cpp-client \

example/go/otel/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ $ docker-compose up --build
2323
Send requests to the app:
2424

2525
```shell
26-
$ curl localhost:8081
26+
$ curl localhost:8081 # W3C format traces
27+
$ curl localhost:8082 # Zipkin format traces
2728
```
2829

2930
Visit http://localhost:16686 to view the traces in Jaeger.

example/go/otel/docker-compose.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ services:
1414
# - "6831/udp" # Default endpoint for Jaeger thrift_compact receiver
1515
- "14268" # Jaeger http thrift receiver
1616
- "55680" # Default endpoint for OpenTelemetry receiver
17+
- "9411" # Zipkin port
1718
- "8888" # Metrics
1819
ports:
1920
- "55680:55680"
21+
- "9411:9411"
2022
# - "6831:6831/udp"
2123
- "8888:8888"
2224
- "14268:14268"
@@ -33,24 +35,27 @@ services:
3335
volumes:
3436
- ./nginx.conf:/etc/nginx/nginx.conf
3537
- ./jaeger-config.json:/etc/jaeger-config.json
38+
- ./zipkin-config.json:/etc/zipkin-config.json
3639
expose:
3740
- "8081"
41+
- "8082"
3842
ports:
3943
- "8081:8081"
44+
- "8082:8082"
4045

4146
jaeger:
4247
image: jaegertracing/all-in-one
48+
environment:
49+
- COLLECTOR_ZIPKIN_HTTP_PORT=19411
4350
pull_policy: always
4451
networks:
4552
example:
4653
aliases:
4754
- jaeger
4855
expose:
49-
- "9411"
5056
- "16686"
5157
- "14250"
5258
ports:
53-
- "9411:9411"
5459
- "16686:16686"
5560
- "14250:14250"
5661

example/go/otel/nginx.conf

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,39 @@ events {}
44

55
http {
66
opentracing on;
7-
87
opentracing_load_tracer /usr/local/lib/libjaegertracing_plugin.so /etc/jaeger-config.json;
8+
opentracing_tag nginx_global http;
99

1010
server {
11+
opentracing_tag nginx_server server;
12+
1113
root /var/www;
1214
error_log /var/log/nginx/debug.log debug;
1315
listen 8081;
1416
server_name web.info;
1517

1618
location / {
17-
opentracing_trace_locations off;
19+
opentracing_tag nginx_location location;
20+
opentracing_trace_locations on;
1821
proxy_pass http://web:8080;
1922
opentracing_propagate_context;
2023
}
2124
}
25+
26+
# Zipkin example
27+
# server {
28+
# opentracing_tag server_nginx_tag server;
29+
# opentracing_load_tracer /usr/local/lib/libzipkin_opentracing_plugin.so /etc/zipkin-config.json;
30+
31+
# root /var/www;
32+
# error_log /var/log/nginx/debug.log debug;
33+
# listen 8081;
34+
# server_name web.info;
35+
36+
# location / {
37+
# opentracing_trace_locations off;
38+
# proxy_pass http://web:8080;
39+
# opentracing_propagate_context;
40+
# }
41+
# }
2242
}

example/go/otel/otel.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ receivers:
99
thrift_http:
1010
# 6831/UDP - not used but specified in jaeger-config.json
1111
thrift_compact:
12+
# 9411 - default zipkin port
13+
zipkin:
1214
processors:
1315
batch:
1416
exporters:
@@ -20,6 +22,6 @@ exporters:
2022
service:
2123
pipelines:
2224
traces:
23-
receivers: [otlp, jaeger]
25+
receivers: [otlp, jaeger, zipkin]
2426
processors: [batch]
2527
exporters: [logging, jaeger]

example/go/otel/zipkin-config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"service_name": "nginx",
3+
"collector_host": "otel",
4+
"collector_port": 9411,
5+
"sample_rate": 1
6+
}

0 commit comments

Comments
 (0)