Skip to content

Commit 9d1f94f

Browse files
romtsnclaude
andcommitted
chore: Update btrace skill with release builds and sound cues
Use release builds for accurate profiling, add ProGuard keep rules for btrace and Sentry class names, increase trace duration to 30s, and play a Ping sound synced to the actual trace start. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 76e9b72 commit 9d1f94f

1 file changed

Lines changed: 33 additions & 5 deletions

File tree

.claude/skills/btrace-perfetto/SKILL.md

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Before starting, verify:
2828
|----------|---------|-------------|
2929
| branch1 | current branch | First branch to trace |
3030
| branch2 | `main` | Second branch to compare against |
31-
| duration | `20` | Trace duration in seconds |
31+
| duration | `30` | Trace duration in seconds |
3232
| sql-query | see below | SQL query to prefill in Perfetto UI |
3333

3434
If no arguments are provided, ask the user what they want to trace and which branches to compare. If only one branch is given, capture only that branch (no comparison).
@@ -73,10 +73,23 @@ protected void attachBaseContext(Context base) {
7373

7474
**Important**: The package is `com.bytedance.rheatrace`, not `com.bytedance.btrace`.
7575

76+
### 2d: Add ProGuard keep rule for release builds
77+
78+
In `sentry-samples/sentry-samples-android/proguard-rules.pro`, add:
79+
80+
```
81+
-keep class com.bytedance.rheatrace.** { *; }
82+
-keepnames class io.sentry.** { *; }
83+
```
84+
85+
The first rule prevents R8 from stripping btrace's HTTP server classes (fails with `SocketException` otherwise). The second preserves Sentry class and method names so they appear readable in the Perfetto trace instead of obfuscated single-letter names.
86+
7687
## Step 3: Build and Install
7788

89+
Always use release builds for tracing — debug builds have StrictMode, debuggable overhead, and no R8 optimizations, which skew results.
90+
7891
```bash
79-
./gradlew :sentry-samples:sentry-samples-android:installDebug
92+
./gradlew :sentry-samples:sentry-samples-android:installRelease
8093
```
8194

8295
## Step 4: Capture Trace
@@ -95,7 +108,20 @@ adb shell am start -n io.sentry.samples.android/.MainActivity
95108

96109
The app must be started AFTER `debug.rhea3.startWhenAppLaunch` is set, otherwise the trace server won't initialize.
97110

98-
### 4b: Tell the user to interact with the app, then capture
111+
### 4b: Play a sound to signal the user, then capture
112+
113+
Play a sound when tracing actually starts so the user knows to begin interacting. Pipe btrace output through a loop that triggers the sound on the "start tracing" line:
114+
115+
```bash
116+
java -jar tools/btrace/rhea-trace-shell.jar ... 2>&1 | while IFS= read -r line; do
117+
echo "$line"
118+
if [[ "$line" == *"start tracing"* ]]; then
119+
afplay -v 1.5 /System/Library/Sounds/Ping.aiff &
120+
fi
121+
done
122+
```
123+
124+
This ensures the sound is synchronized with the actual trace start, not an estimated delay.
99125

100126
```bash
101127
java -jar tools/btrace/rhea-trace-shell.jar \
@@ -116,11 +142,12 @@ When capturing a second branch:
116142
```bash
117143
git stash push -m "btrace integration" -- \
118144
sentry-samples/sentry-samples-android/build.gradle.kts \
119-
sentry-samples/sentry-samples-android/src/main/java/io/sentry/samples/android/MyApplication.java
145+
sentry-samples/sentry-samples-android/src/main/java/io/sentry/samples/android/MyApplication.java \
146+
sentry-samples/sentry-samples-android/proguard-rules.pro
120147
```
121148
2. Checkout the other branch
122149
3. Pop the stash: `git stash pop`
123-
4. Rebuild and install: `./gradlew :sentry-samples:sentry-samples-android:installDebug`
150+
4. Rebuild and install: `./gradlew :sentry-samples:sentry-samples-android:installRelease`
124151
5. Repeat steps 4a and 4b with a different output filename
125152
6. Switch back to the original branch and restore files
126153

@@ -172,3 +199,4 @@ After tracing is complete, remind the user that the btrace integration changes t
172199
| `wait for trace ready timeout` on download | Set `debug.rhea3.startWhenAppLaunch=1` BEFORE launching the app, and use `-waitTraceTimeout 60` |
173200
| Empty jar file (0 bytes) | Download from Maven Central (`repo1.maven.org`), not `oss.sonatype.org` |
174201
| `FileNotFoundException` on sampling download | App was already running when properties were set; force-stop and relaunch |
202+
| `SocketException: Unexpected end of file` in release builds | R8 stripped btrace classes; add `-keep class com.bytedance.rheatrace.** { *; }` to proguard-rules.pro |

0 commit comments

Comments
 (0)