Skip to content

Commit 47628de

Browse files
author
Uzziah Eyee
committed
Added the jaeger-collector service which will save traces in Elasticsearch.
1 parent c2f16d0 commit 47628de

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

docker-compose.dev.yml

+17
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,23 @@ services:
4646
env_file: log-shipper/.env
4747

4848

49+
jaeger-collector:
50+
build: jaeger-collector
51+
environment:
52+
# more options: https://www.jaegertracing.io/docs/1.11/deployment/#all-options-1
53+
SPAN_STORAGE_TYPE: elasticsearch
54+
ES_SERVER_URLS: http://elasticsearch:9200
55+
restart: on-failure
56+
# todo: eliminate duplication of health-check url in 'command'
57+
command: wait.sh http://elasticsearch:9200 5 20 "jaeger-collector"
58+
ports:
59+
- "14269:14269" # healthcheck
60+
- "14250:14250" # for receiving spans via grpc
61+
networks:
62+
- aparnet
63+
depends_on:
64+
- elasticsearch
65+
4966
jaeger-query:
5067
build: jaeger-query
5168
environment:

jaeger-collector/Dockerfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM alpine:3.9.3
2+
3+
# required by wait script
4+
RUN apk add --no-cache bash curl
5+
6+
COPY jaeger-collector wait.sh /usr/local/bin/
7+
8+
RUN chmod +x /usr/local/bin/wait.sh

jaeger-collector/jaeger-collector

31.2 MB
Binary file not shown.

jaeger-collector/wait.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# Requires a container with Bash and Curl installed.
4+
5+
is_healthy () {
6+
retryInterval=${2:-5}
7+
maxAttempts=${3:-1000000}
8+
9+
i=0
10+
while [ $i -lt $maxAttempts ]
11+
do
12+
status=$(curl -s -L -o /dev/null -w %{http_code} $1)
13+
14+
# stop trying if we get a success response
15+
if [ $status -ge 200 ] && [ $status -lt 300 ]
16+
then
17+
return 0
18+
fi
19+
20+
((i++))
21+
echo "Attempt $i of $maxAttempts: Endpoint $1 returned code $status. Retrying in $retryInterval seconds."
22+
sleep $retryInterval
23+
done
24+
25+
return 1
26+
}
27+
28+
# args: endpoint, retryInterval (secs), maxAttempts, command
29+
if is_healthy $1 $2 $3
30+
then
31+
echo "Running command: $4"
32+
# vulnerable to input-injection attacts (but I don't care :)
33+
eval "$4"
34+
else
35+
echo "Exiting: Cannot run command because health-check failed."
36+
fi

0 commit comments

Comments
 (0)