Skip to content

Commit 7b23f0c

Browse files
committed
add stack tests to benchmarks
1 parent fb2c3c9 commit 7b23f0c

4 files changed

Lines changed: 70 additions & 15 deletions

File tree

drift/stack-tests/django-postgres/docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ services:
3030
- TUSK_ANALYTICS_DISABLED=1
3131
- PYTHONUNBUFFERED=1
3232
- DJANGO_SETTINGS_MODULE=settings
33+
- BENCHMARKS=${BENCHMARKS:-}
34+
- BENCHMARK_DURATION=${BENCHMARK_DURATION:-10}
35+
- BENCHMARK_WARMUP=${BENCHMARK_WARMUP:-3}
3336
working_dir: /app
3437
volumes:
3538
# Mount SDK source for hot reload (no rebuild needed for SDK changes)

drift/stack-tests/django-redis/docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ services:
2323
- TUSK_ANALYTICS_DISABLED=1
2424
- PYTHONUNBUFFERED=1
2525
- DJANGO_SETTINGS_MODULE=settings
26+
- BENCHMARKS=${BENCHMARKS:-}
27+
- BENCHMARK_DURATION=${BENCHMARK_DURATION:-10}
28+
- BENCHMARK_WARMUP=${BENCHMARK_WARMUP:-3}
2629
working_dir: /app
2730
volumes:
2831
# Mount SDK source for hot reload (no rebuild needed for SDK changes)

drift/stack-tests/fastapi-postgres/docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ services:
2929
- POSTGRES_PASSWORD=testpass
3030
- TUSK_ANALYTICS_DISABLED=1
3131
- PYTHONUNBUFFERED=1
32+
- BENCHMARKS=${BENCHMARKS:-}
33+
- BENCHMARK_DURATION=${BENCHMARK_DURATION:-10}
34+
- BENCHMARK_WARMUP=${BENCHMARK_WARMUP:-3}
3235
working_dir: /app
3336
volumes:
3437
# Mount SDK source for hot reload (no rebuild needed for SDK changes)

run-all-benchmarks.sh

Lines changed: 61 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
#!/bin/bash
22

3-
# Script to run benchmarks for all Python SDK E2E instrumentation tests serially.
4-
# Each instrumentation runs with BENCHMARKS=1, producing a comparison of
3+
# Script to run benchmarks for all Python SDK E2E instrumentation and stack tests serially.
4+
# Each test runs with BENCHMARKS=1, producing a comparison of
55
# SDK disabled vs enabled (RECORD mode) with Go-style ns/op stats.
66
#
7+
# Test types:
8+
# - Instrumentation: Single instrumentation benchmarks (e.g., flask, fastapi, django)
9+
# - Stack: Multi-instrumentation integration benchmarks (e.g., django-postgres, fastapi-postgres)
10+
#
711
# Usage:
812
# ./run-all-benchmarks.sh # Run all, 10s per endpoint
913
# ./run-all-benchmarks.sh -d 20 # Run all, 20s per endpoint
1014
# ./run-all-benchmarks.sh -f flask,fastapi # Run only flask and fastapi
15+
# ./run-all-benchmarks.sh --stack-only # Run only stack-test benchmarks
16+
# ./run-all-benchmarks.sh -f stack:django-postgres # Run a single stack benchmark
1117
# ./run-all-benchmarks.sh -h # Show help
1218

1319
set -e
@@ -16,6 +22,8 @@ set -e
1622
BENCHMARK_DURATION=${BENCHMARK_DURATION:-10}
1723
BENCHMARK_WARMUP=${BENCHMARK_WARMUP:-3}
1824
FILTER=""
25+
RUN_INSTRUMENTATION=true
26+
RUN_STACK=true
1927

2028
# Colors for output
2129
GREEN='\033[0;32m'
@@ -27,13 +35,15 @@ NC='\033[0m' # No Color
2735
usage() {
2836
echo "Usage: $0 [OPTIONS]"
2937
echo ""
30-
echo "Run SDK benchmarks for all (or selected) instrumentations serially."
38+
echo "Run SDK benchmarks for all (or selected) instrumentations and stack tests serially."
3139
echo ""
3240
echo "Options:"
3341
echo " -d, --duration N Seconds per endpoint for timed loop (default: 10)"
3442
echo " -w, --warmup N Seconds of warmup per endpoint before timing (default: 3)"
35-
echo " -f, --filter LIST Comma-separated list of instrumentations to benchmark"
36-
echo " e.g. flask,fastapi,django"
43+
echo " -f, --filter LIST Comma-separated list of benchmarks to run"
44+
echo " e.g. flask,fastapi,stack:django-postgres"
45+
echo " --instrumentation-only Run only single-instrumentation benchmarks"
46+
echo " --stack-only Run only stack-test benchmarks"
3747
echo " -h, --help Show this help message"
3848
echo ""
3949
echo "Environment variables:"
@@ -42,10 +52,12 @@ usage() {
4252
echo " TUSK_CLI_VERSION CLI version to use in Docker builds"
4353
echo ""
4454
echo "Examples:"
45-
echo " $0 # Benchmark all instrumentations"
55+
echo " $0 # Benchmark all instrumentations and stack tests"
4656
echo " $0 -d 20 # 20s per endpoint"
4757
echo " $0 -d 30 -w 5 # 30s timed, 5s warmup"
4858
echo " $0 -f flask,fastapi # Only benchmark flask and fastapi"
59+
echo " $0 --stack-only # Only benchmark stack tests"
60+
echo " $0 -f stack:django-postgres # Only benchmark django-postgres stack test"
4961
}
5062

5163
# Parse arguments
@@ -75,6 +87,16 @@ while [[ $# -gt 0 ]]; do
7587
FILTER="$2"
7688
shift 2
7789
;;
90+
--instrumentation-only)
91+
RUN_INSTRUMENTATION=true
92+
RUN_STACK=false
93+
shift
94+
;;
95+
--stack-only)
96+
RUN_INSTRUMENTATION=false
97+
RUN_STACK=true
98+
shift
99+
;;
78100
-h|--help)
79101
usage
80102
exit 0
@@ -100,19 +122,34 @@ fi
100122
# Get the directory where this script is located (SDK root)
101123
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
102124

103-
# Discover all e2e test run.sh scripts
104-
ALL_SCRIPTS=($(find "$SCRIPT_DIR/drift/instrumentation" -path "*/e2e-tests/run.sh" -type f | sort))
125+
# Discover test scripts based on flags
126+
E2E_SCRIPTS=()
127+
STACK_SCRIPTS=()
128+
129+
if [ "$RUN_INSTRUMENTATION" = true ]; then
130+
E2E_SCRIPTS=($(find "$SCRIPT_DIR/drift/instrumentation" -path "*/e2e-tests/run.sh" -type f | sort))
131+
fi
132+
133+
if [ "$RUN_STACK" = true ]; then
134+
STACK_SCRIPTS=($(find "$SCRIPT_DIR/drift/stack-tests" -mindepth 2 -maxdepth 2 -name "run.sh" -type f 2>/dev/null | sort))
135+
fi
136+
137+
ALL_SCRIPTS=("${E2E_SCRIPTS[@]}" "${STACK_SCRIPTS[@]}")
105138

106139
if [ ${#ALL_SCRIPTS[@]} -eq 0 ]; then
107-
echo -e "${RED}No e2e test scripts found!${NC}"
140+
echo -e "${RED}No benchmark scripts found!${NC}"
108141
exit 1
109142
fi
110143

111-
# Apply filter if provided
144+
# Extract names and apply filter
112145
RUN_SCRIPTS=()
113146
RUN_NAMES=()
114147
for script in "${ALL_SCRIPTS[@]}"; do
115-
NAME=$(echo "$script" | sed -E 's|.*/instrumentation/([^/]+)/e2e-tests/run.sh|\1|')
148+
if [[ "$script" == *"/stack-tests/"* ]]; then
149+
NAME=$(echo "$script" | sed -E 's|.*/stack-tests/([^/]+)/run.sh|stack:\1|')
150+
else
151+
NAME=$(echo "$script" | sed -E 's|.*/instrumentation/([^/]+)/e2e-tests/run.sh|\1|')
152+
fi
116153
if [ -n "$FILTER" ]; then
117154
# Check if NAME is in the comma-separated filter list
118155
if echo ",$FILTER," | grep -q ",$NAME,"; then
@@ -128,19 +165,28 @@ done
128165
NUM_TESTS=${#RUN_SCRIPTS[@]}
129166

130167
if [ $NUM_TESTS -eq 0 ]; then
131-
echo -e "${RED}No matching instrumentations found for filter: $FILTER${NC}"
132-
echo "Available: $(printf '%s\n' "${ALL_SCRIPTS[@]}" | sed -E 's|.*/instrumentation/([^/]+)/e2e-tests/run.sh|\1|' | tr '\n' ' ')"
168+
echo -e "${RED}No matching benchmarks found for filter: $FILTER${NC}"
169+
# Show all available names
170+
ALL_NAMES=()
171+
for script in "${ALL_SCRIPTS[@]}"; do
172+
if [[ "$script" == *"/stack-tests/"* ]]; then
173+
ALL_NAMES+=($(echo "$script" | sed -E 's|.*/stack-tests/([^/]+)/run.sh|stack:\1|'))
174+
else
175+
ALL_NAMES+=($(echo "$script" | sed -E 's|.*/instrumentation/([^/]+)/e2e-tests/run.sh|\1|'))
176+
fi
177+
done
178+
echo "Available: ${ALL_NAMES[*]}"
133179
exit 1
134180
fi
135181

136182
echo ""
137183
echo -e "${BLUE}========================================${NC}"
138184
echo -e "${BLUE}Python SDK Benchmarks${NC}"
139185
echo -e "${BLUE}========================================${NC}"
140-
echo "Instrumentations: ${RUN_NAMES[*]}"
186+
echo "Benchmarks: ${RUN_NAMES[*]}"
141187
echo "Warmup per endpoint: ${BENCHMARK_WARMUP}s"
142188
echo "Duration per endpoint: ${BENCHMARK_DURATION}s"
143-
echo "Total instrumentations: $NUM_TESTS"
189+
echo "Total benchmarks: $NUM_TESTS"
144190
echo -e "${BLUE}========================================${NC}"
145191
echo ""
146192

0 commit comments

Comments
 (0)