Skip to content

Commit b7a616b

Browse files
claudeavrabe
authored andcommitted
ci: extract basic metrics from ByteHound profiles
Implements an automated API discovery approach by: 1. Starting ByteHound server in background during CI 2. Probing common API endpoints with curl 3. Saving any JSON responses found 4. Displaying discovered endpoints in GitHub Actions summary This will help us discover what programmatic access ByteHound provides and potentially extract metrics automatically in future runs without requiring manual download and analysis. Endpoints tested: - / (root/homepage) - /api, /api/data, /api/stats, /api/allocations - /data, /stats Any JSON responses are saved as .api*.json files and uploaded as artifacts for inspection.
1 parent d0d529b commit b7a616b

File tree

1 file changed

+64
-5
lines changed

1 file changed

+64
-5
lines changed

.github/workflows/memory-profile.yml

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,55 @@ jobs:
8181
$HOME/bytehound --help 2>&1 || true
8282
echo ""
8383
84-
# Process each profile file
84+
# Try to extract metrics via ByteHound's web server API
85+
profile=$(ls memory-profiling_*.dat | head -1)
86+
if [ -n "$profile" ]; then
87+
echo "Starting ByteHound server for: $profile"
88+
89+
# Start ByteHound server in background on port 8080
90+
$HOME/bytehound server "$profile" --port 8080 &
91+
BYTEHOUND_PID=$!
92+
93+
# Wait for server to start (max 10 seconds)
94+
echo "Waiting for ByteHound server to start..."
95+
for i in {1..20}; do
96+
if curl -s http://localhost:8080 >/dev/null 2>&1; then
97+
echo "Server is up!"
98+
break
99+
fi
100+
sleep 0.5
101+
done
102+
103+
# Try to discover API endpoints
104+
echo ""
105+
echo "Exploring ByteHound API..."
106+
107+
# Common API endpoints to try
108+
for endpoint in / /api /api/data /api/stats /api/allocations /data /stats; do
109+
echo "Trying: http://localhost:8080$endpoint"
110+
response=$(curl -s -w "\nHTTP_CODE:%{http_code}" "http://localhost:8080$endpoint" 2>&1 | head -20)
111+
http_code=$(echo "$response" | grep "HTTP_CODE:" | cut -d: -f2)
112+
113+
if [ "$http_code" = "200" ]; then
114+
echo " ✓ Found endpoint! Response preview:"
115+
echo "$response" | grep -v "HTTP_CODE:" | head -10
116+
117+
# Save full response if it's JSON
118+
if echo "$response" | grep -q -E '^\s*[\{\[]'; then
119+
echo " (Looks like JSON, saving to ${profile}.api${endpoint//\//_}.json)"
120+
echo "$response" | grep -v "HTTP_CODE:" > "${profile}.api${endpoint//\//_}.json"
121+
fi
122+
else
123+
echo " ✗ HTTP $http_code"
124+
fi
125+
done
126+
127+
# Kill the server
128+
kill $BYTEHOUND_PID 2>/dev/null || true
129+
wait $BYTEHOUND_PID 2>/dev/null || true
130+
fi
131+
132+
# Process each profile file for basic summary
85133
for profile in memory-profiling_*.dat; do
86134
echo ""
87135
echo "=== Analyzing: $profile ==="
@@ -90,9 +138,6 @@ jobs:
90138
size=$(stat -c%s "$profile" 2>/dev/null || echo "unknown")
91139
echo "Profile size: $size bytes"
92140
93-
# Try to extract summary if ByteHound supports it
94-
# Common commands: server, strip, etc.
95-
96141
# Create a summary text file with basic info
97142
{
98143
echo "Profile: $profile"
@@ -132,6 +177,18 @@ jobs:
132177
echo "- **$profile** - $size" >> $GITHUB_STEP_SUMMARY
133178
done
134179
180+
# Show discovered API endpoints if any
181+
if ls memory-profiling_*.dat.api*.json 1> /dev/null 2>&1; then
182+
echo "" >> $GITHUB_STEP_SUMMARY
183+
echo "### 🔌 Discovered API Endpoints" >> $GITHUB_STEP_SUMMARY
184+
echo "" >> $GITHUB_STEP_SUMMARY
185+
for api_file in memory-profiling_*.dat.api*.json; do
186+
endpoint=$(basename "$api_file" | sed 's/.*\.api\(.*\)\.json/\1/' | tr '_' '/')
187+
size=$(stat -c%s "$api_file" 2>/dev/null || echo "0")
188+
echo "- \`$endpoint\` - $size bytes" >> $GITHUB_STEP_SUMMARY
189+
done
190+
fi
191+
135192
echo "" >> $GITHUB_STEP_SUMMARY
136193
echo "### 🔍 How to Analyze" >> $GITHUB_STEP_SUMMARY
137194
echo "" >> $GITHUB_STEP_SUMMARY
@@ -163,6 +220,8 @@ jobs:
163220
uses: actions/upload-artifact@v4
164221
with:
165222
name: bytehound-summaries
166-
path: memory-profiling_*.dat.summary.txt
223+
path: |
224+
memory-profiling_*.dat.summary.txt
225+
memory-profiling_*.dat.api*.json
167226
retention-days: 7
168227
if-no-files-found: ignore

0 commit comments

Comments
 (0)