Skip to content

Commit 68ea4c1

Browse files
committed
Add ditributed tracing to walshadow
1 parent a64f4c9 commit 68ea4c1

25 files changed

Lines changed: 1785 additions & 851 deletions

Cargo.lock

Lines changed: 212 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ toml = { version = "1", default-features = false, features = ["parse", "serde"]
6262
tracing = "0.1"
6363
tracing-subscriber = { version = "0.3", default-features = false, features = ["env-filter", "fmt", "ansi"] }
6464
zstd = "0.13"
65+
opentelemetry = "0.32"
66+
opentelemetry_sdk = { version = "0.32", features = ["rt-tokio"] }
67+
opentelemetry-otlp = { version = "0.32", default-features = false, features = ["grpc-tonic", "trace"] }
68+
tracing-opentelemetry = { version = "0.33", default-features = false }
6569

6670
[dev-dependencies]
6771
tempfile = "3"

bench/ec2/ec2-walshadow/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ source ./state.env # PUBLIC_IP, KEY_NAME, ...
2121
source ../lib.sh
2222

2323
IMAGE="${IMAGE:-walshadow:local}"
24-
FLUSH_TIMEOUT_MS="${FLUSH_TIMEOUT_MS:-50}"
24+
FLUSH_TIMEOUT_MS="${FLUSH_TIMEOUT_MS:-1000}"
2525
node_ssh_setup
2626

2727
SRC_PRIV="${SOURCE_PRIVATE_IP:-$(read_state_var ../ec2-source-pg/state.env SOURCE_PRIVATE_IP)}"

bench/ec2/ec2-walshadow/node.env

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# Config for the walshadow daemon host. SSH + Prometheus metrics (:9484) from
2-
# the operator only; it emits into ClickHouse OUTBOUND over the VPC.
1+
# Config for the walshadow daemon host. SSH + walshadow /metrics (:9484) +
2+
# the co-located observability UIs — Grafana (:3000), Prometheus (:9090) —
3+
# all from the operator only; it emits into ClickHouse OUTBOUND over the VPC.
34
NODE_NAME=walshadow-daemon
4-
SG_DESC="walshadow daemon: SSH + Prometheus metrics from my IP"
5-
INGRESS="22:my 9484:my"
5+
SG_DESC="walshadow daemon: SSH + metrics + grafana/prometheus from my IP"
6+
INGRESS="22:my 9484:my 3000:my 9090:my"
67
NODE_NEXT="next: ./deploy.sh ships the image + config and starts the daemon"

bench/ec2/ec2-walshadow/profile.sh

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,33 @@ sudo sysctl -w kernel.perf_event_paranoid=-1 kernel.kptr_restrict=0 >/dev/null 2
3333
PIDS=$(sudo docker top walshadow -eo pid --no-headers 2>/dev/null | awk '{print $1}' | paste -sd,)
3434
[ -n "$PIDS" ] || PIDS=$(sudo pgrep -f 'walshadow-stream|postgres' 2>/dev/null | paste -sd,)
3535
[ -n "$PIDS" ] || { echo "no walshadow processes found — is the daemon up?" >&2; exit 1; }
36-
# The walshadow-stream daemon (decode/insert engine) for the single-PID eBPF profiler.
36+
# The walshadow-stream daemon (decode/insert engine) for the single-PID eBPF
37+
# profiler. Required and must be live — profiling with no walshadow-stream
38+
# process is meaningless, so fail loudly here rather than producing empty output.
3739
WS=$(sudo pgrep -f 'walshadow-stream' 2>/dev/null | head -1 || true)
3840
[ -n "$WS" ] || WS=$(sudo docker inspect -f '{{.State.Pid}}' walshadow 2>/dev/null || true)
39-
echo "walshadow pids (perf): $PIDS walshadow-stream pid (eBPF): ${WS:-none}"
41+
{ [ -n "$WS" ] && sudo test -d "/proc/$WS"; } \
42+
|| { echo "walshadow-stream daemon not running — nothing to profile (is the walshadow container up?)" >&2; exit 1; }
43+
echo "walshadow pids (perf): $PIDS walshadow-stream pid (eBPF): $WS"
4044
4145
sudo nohup bash -c "
42-
{ [ -n \"$WS\" ] && profile-bpfcc -F 99 -f -p $WS $DUR > $OUT/oncpu-walshadow-$TS.folded 2>$OUT/oncpu-$TS.log ; } &
43-
perf record -F 99 -g -p $PIDS -o $OUT/perf-$TS.data -- sleep $DUR 2>>$OUT/perf-$TS.log \
46+
profile-bpfcc -F 99 -f -p $WS $DUR > $OUT/oncpu-walshadow-$TS.folded 2>$OUT/oncpu-$TS.log &
47+
# Re-filter the PID list to processes still alive RIGHT NOW: perf -p aborts the
48+
# whole record if any one PID has exited (transient PG backends churn between
49+
# the snapshot above and this point) → 'Couldn't create thread/CPU maps'. The
50+
# walshadow-stream PID is asserted live above, so the list is never empty.
51+
LIVE=\"\"; for x in \$(echo '$PIDS' | tr ',' ' '); do [ -d /proc/\$x ] && LIVE=\"\$LIVE,\$x\"; done; LIVE=\${LIVE#,}
52+
# DWARF call-graph: walshadow links musl and has no frame pointers, so -g/fp
53+
# unwinding dead-ends at the leaf (memcpy/[unknown]). DWARF unwinds via the
54+
# binary's .eh_frame (present — default panic=unwind). Tuning that matters:
55+
# * dwarf,65528 — large per-sample stack dump. Rust async frames are big;
56+
# a small dump (8192) truncates the unwind so callers above memcpy are lost.
57+
# * -m 64M — ring buffer big enough for those dumps (avoids a wakeup storm).
58+
# * --no-buildid* — skip perf's end-of-record build-id/addr2line finalization,
59+
# which fails on this host and left the file unfinalized ('data size 0').
60+
# Safe: we run `perf script` on this same host, resolving symbols live.
61+
perf record -F 99 --call-graph dwarf,65528 -m 64M --no-buildid --no-buildid-cache \
62+
-p \"\$LIVE\" -o $OUT/perf-$TS.data -- sleep $DUR 2>>$OUT/perf-$TS.log \
4463
|| echo 'perf record failed (see log)' >>$OUT/perf-$TS.log
4564
wait
4665
chown -R ubuntu $OUT

0 commit comments

Comments
 (0)