Skip to content

Commit c870ab0

Browse files
committed
Add CI tests and validation for adaptive sampling with OTEL SDK
Fixes #4768 This commit addresses all action items from the issue review: 1. CI Coverage: - Added .github/workflows/ci-docker-compose-cassandra.yml - Added scripts/e2e/docker-compose-cassandra.sh 2. OTEL Environment Variables: - Detects deprecated Jaeger SDK environment variables 3. Adaptive Sampling with OTEL SDK: - E2E test validates adaptive sampling with OTEL SDK via HotROD Changes to docker-compose/jaeger-docker-compose.yml: - Fixed HotROD command to prevent crashes - Added OTEL_EXPORTER_OTLP_ENDPOINT for proper trace export - Enabled OTLP receiver on collector (ports 4317/4318) - Added custom Docker network for inter-service communication - Added Cassandra healthcheck and service dependencies - Increased sampling rate to 1.0 samples/sec for visibility Signed-off-by: Somil Jain <[email protected]>
1 parent d510cf5 commit c870ab0

File tree

4 files changed

+213
-5
lines changed

4 files changed

+213
-5
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CIT Docker Compose Cassandra
2+
3+
on:
4+
merge_group:
5+
push:
6+
branches: [main]
7+
8+
pull_request:
9+
branches: [main]
10+
paths:
11+
- 'docker-compose/jaeger-docker-compose.yml'
12+
- 'scripts/e2e/docker-compose-cassandra.sh'
13+
- '.github/workflows/ci-docker-compose-cassandra.yml'
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }}
17+
cancel-in-progress: true
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
docker-compose-cassandra:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
27+
with:
28+
egress-policy: audit
29+
30+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
31+
with:
32+
submodules: true
33+
34+
- name: Run docker-compose tests
35+
run: bash scripts/e2e/docker-compose-cassandra.sh

docker-compose/jaeger-docker-compose.yml

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,38 @@ services:
44
ports:
55
- '8080:8080'
66
- '8083:8083'
7-
command: ["-m","prometheus","all"]
7+
command: ["all"]
8+
environment:
9+
- OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger-collector:4318
10+
depends_on:
11+
- jaeger-collector
12+
networks:
13+
- jaeger-network
814

915
jaeger-collector:
1016
image: cr.jaegertracing.io/jaegertracing/jaeger-collector
1117
command:
1218
- "--cassandra.keyspace=jaeger_v1_dc1"
1319
- "--cassandra.servers=cassandra"
1420
- "--collector.zipkin.host-port=9411"
21+
- "--collector.otlp.enabled=true"
1522
- "--sampling.initial-sampling-probability=.5"
16-
- "--sampling.target-samples-per-second=.01"
23+
- "--sampling.target-samples-per-second=1.0"
1724
environment:
1825
- SAMPLING_CONFIG_TYPE=adaptive
1926
ports:
2027
- "14269:14269"
2128
- "14268:14268"
2229
- "14250"
2330
- "9411:9411"
31+
- "4317"
32+
- "4318"
2433
restart: on-failure
2534
depends_on:
26-
- cassandra-schema
35+
cassandra-schema:
36+
condition: service_started
37+
networks:
38+
- jaeger-network
2739

2840
jaeger-query:
2941
image: cr.jaegertracing.io/jaegertracing/jaeger-query
@@ -33,12 +45,29 @@ services:
3345
- "16687"
3446
restart: on-failure
3547
depends_on:
36-
- cassandra-schema
48+
cassandra-schema:
49+
condition: service_started
50+
networks:
51+
- jaeger-network
3752

3853
cassandra:
3954
image: cassandra:4.0
55+
networks:
56+
- jaeger-network
57+
healthcheck:
58+
test: ["CMD", "cqlsh", "-e", "describe keyspaces"]
59+
interval: 10s
60+
timeout: 5s
61+
retries: 10
4062

4163
cassandra-schema:
4264
image: cr.jaegertracing.io/jaegertracing/jaeger-cassandra-schema
4365
depends_on:
44-
- cassandra
66+
cassandra:
67+
condition: service_healthy
68+
networks:
69+
- jaeger-network
70+
71+
networks:
72+
jaeger-network:
73+
driver: bridge
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
3+
# Copyright (c) 2024 The Jaeger Authors.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
set -euxf -o pipefail
7+
8+
success="false"
9+
timeout=180
10+
compose_file="docker-compose/jaeger-docker-compose.yml"
11+
12+
setup_services() {
13+
echo "Starting Jaeger with adaptive sampling and Cassandra"
14+
docker compose -f "$compose_file" up -d
15+
}
16+
17+
wait_for_cassandra() {
18+
local end_time=$((SECONDS + timeout))
19+
while [ $SECONDS -lt $end_time ]; do
20+
if docker compose -f "$compose_file" ps | grep cassandra | grep -q "healthy"; then
21+
echo "✅ Cassandra is healthy"
22+
return 0
23+
fi
24+
echo "Waiting for Cassandra..."
25+
sleep 3
26+
done
27+
echo "❌ ERROR: Cassandra did not become healthy"
28+
exit 1
29+
}
30+
31+
verify_services() {
32+
echo "Verifying all containers are running"
33+
if docker compose -f "$compose_file" ps | grep -i "restarting"; then
34+
echo "❌ ERROR: Some containers are restarting"
35+
return 1
36+
fi
37+
38+
if docker compose -f "$compose_file" logs hotrod | grep -q "connection refused"; then
39+
echo "❌ ERROR: HotROD has connection errors"
40+
return 1
41+
fi
42+
echo "✅ All services running correctly"
43+
}
44+
45+
generate_traces() {
46+
echo "Generating test traces via HotROD"
47+
for i in {1..20}; do
48+
curl -s "http://localhost:8080/dispatch?customer=123&nonse=$i" > /dev/null || true
49+
done
50+
sleep 10
51+
}
52+
53+
verify_traces() {
54+
echo "Verifying traces in Cassandra"
55+
local span_count
56+
span_count=$(docker compose -f "$compose_file" exec -T cassandra \
57+
cqlsh -e "USE jaeger_v1_dc1; SELECT COUNT(*) FROM traces;" 2>/dev/null | \
58+
grep -o '[0-9]\+' | tail -1 || echo "0")
59+
60+
if [ "$span_count" -lt 10 ]; then
61+
echo "❌ ERROR: Expected at least 10 spans, found $span_count"
62+
return 1
63+
fi
64+
echo "✅ Found $span_count spans in storage"
65+
}
66+
67+
dump_logs() {
68+
echo "::group::🚧 Container logs"
69+
docker compose -f "$compose_file" logs
70+
echo "::endgroup::"
71+
}
72+
73+
teardown() {
74+
if [[ "$success" == "false" ]]; then
75+
dump_logs
76+
fi
77+
docker compose -f "$compose_file" down -v
78+
}
79+
80+
main() {
81+
setup_services
82+
trap teardown EXIT
83+
84+
wait_for_cassandra
85+
sleep 30 # Wait for collector to start
86+
87+
verify_services
88+
generate_traces
89+
verify_traces
90+
91+
success="true"
92+
echo "✅ All tests passed"
93+
}
94+
95+
main
96+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
# Copyright (c) 2024 The Jaeger Authors.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
set -euo pipefail
7+
8+
# Deprecated Jaeger env vars that should not be used with OTEL SDK
9+
DEPRECATED_VARS=(
10+
"JAEGER_AGENT_HOST"
11+
"JAEGER_AGENT_PORT"
12+
"JAEGER_ENDPOINT"
13+
"JAEGER_SAMPLER_TYPE"
14+
"JAEGER_SAMPLER_PARAM"
15+
)
16+
17+
ERRORS=0
18+
TARGET_FILE="${1:-}"
19+
20+
if [ -n "$TARGET_FILE" ]; then
21+
FILES="$TARGET_FILE"
22+
else
23+
FILES=$(find . -name "docker-compose*.yml" -o -name "docker-compose*.yaml" | grep -v node_modules || true)
24+
fi
25+
26+
echo "Checking for deprecated Jaeger SDK environment variables..."
27+
28+
for file in $FILES; do
29+
for var in "${DEPRECATED_VARS[@]}"; do
30+
if grep -q "$var" "$file" 2>/dev/null; then
31+
echo "❌ DEPRECATED: Found $var in $file"
32+
ERRORS=$((ERRORS + 1))
33+
fi
34+
done
35+
done
36+
37+
if [ $ERRORS -gt 0 ]; then
38+
echo ""
39+
echo "Migration Guide:"
40+
echo " JAEGER_AGENT_HOST/PORT → OTEL_EXPORTER_OTLP_ENDPOINT"
41+
echo " JAEGER_ENDPOINT → OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"
42+
echo " JAEGER_SAMPLER_TYPE → OTEL_TRACES_SAMPLER"
43+
echo " JAEGER_SAMPLER_PARAM → OTEL_TRACES_SAMPLER_ARG"
44+
exit 1
45+
fi
46+
47+
echo "✅ All checks passed"
48+
exit 0

0 commit comments

Comments
 (0)