Skip to content

Commit d021da6

Browse files
jbachorikclaude
andcommitted
refactor(profiling): Consolidate converter script output for clarity
Simplified the conversion script output to avoid duplicate information: Default mode (no flags): - Single concise line: "[SUCCESS] Converted: output.pb (45.2KB, 127ms)" - No verbose converter output shown - Perfect for scripting and quick conversions Diagnostics mode (--diagnostics): - Shows converter's detailed output (files, format, time) - Enhanced diagnostics section with compression metrics - Clear input→output flow visualization - Space savings calculations Changes: - Removed duplicate "Converting..." and "Conversion complete" messages - Eliminated redundant output file info in default mode - Consolidated size/time reporting - Renamed section to "Enhanced Diagnostics" to distinguish from converter output Example outputs: Default: [SUCCESS] Converted: output.pb (45.2KB, 127ms) With --diagnostics: [DIAG] Input: recording.jfr (89.3KB) Converting 1 JFR file(s) to OTLP format... Adding: recording.jfr Conversion complete! Output: output.pb Format: PROTO Size: 45.2 KB Time: 127 ms [DIAG] === Enhanced Diagnostics === [DIAG] Input → Output: 89.3KB → 45.2KB [DIAG] Compression: 50.6% of original [DIAG] Space saved: 44.1KB (49.4% reduction) Documentation updated in CLI.md with both output examples. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 7a11c57 commit d021da6

File tree

2 files changed

+58
-43
lines changed

2 files changed

+58
-43
lines changed

dd-java-agent/agent-profiling/profiling-otel/convert-jfr.sh

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,6 @@ fi
276276
# Ensure fat jar is built and get its path
277277
FAT_JAR=$(ensure_fat_jar)
278278

279-
log_info "Converting JFR to OTLP format..."
280-
281279
# Run conversion using fat jar and capture output
282280
# Suppress SLF4J warnings (it defaults to NOP logger which is fine for CLI)
283281
CONVERTER_OUTPUT=$(java -jar "$FAT_JAR" "${CONVERTER_ARGS[@]}" 2>&1 | grep -vE "^SLF4J:|SLF4JServiceProvider")
@@ -287,41 +285,35 @@ if [ $CONVERTER_EXIT -eq 0 ]; then
287285
# Extract output file (last argument)
288286
OUTPUT_FILE="${CONVERTER_ARGS[-1]}"
289287

290-
# Print converter output
291-
echo "$CONVERTER_OUTPUT"
292-
293-
log_success "Conversion completed successfully!"
288+
if [ "$SHOW_DIAGNOSTICS" = true ]; then
289+
# With diagnostics: show converter output plus enhanced metrics
290+
echo "$CONVERTER_OUTPUT"
294291

295-
if [ -f "$OUTPUT_FILE" ]; then
296292
OUTPUT_SIZE=$(get_file_size_bytes "$OUTPUT_FILE")
297-
SIZE=$(format_bytes $OUTPUT_SIZE)
298-
log_info "Output file: $OUTPUT_FILE ($SIZE)"
299293

300-
if [ "$SHOW_DIAGNOSTICS" = true ]; then
301-
echo ""
302-
log_diagnostic "=== Conversion Diagnostics ==="
294+
echo ""
295+
log_diagnostic "=== Enhanced Diagnostics ==="
303296

304-
# Extract conversion time from converter output (looks for "Time: XXX ms")
305-
CONVERSION_TIME=$(echo "$CONVERTER_OUTPUT" | grep -o 'Time: [0-9]* ms' | grep -o '[0-9]*' | head -1)
306-
if [ -n "$CONVERSION_TIME" ] && [ "$CONVERSION_TIME" != "" ]; then
307-
log_diagnostic "Conversion time: ${CONVERSION_TIME}ms"
308-
fi
297+
# Show size comparison with input
298+
if [ ${#INPUT_FILES[@]} -gt 0 ]; then
299+
RATIO=$(calc_compression_ratio $TOTAL_INPUT_SIZE $OUTPUT_SIZE)
300+
log_diagnostic "Input → Output: $(format_bytes $TOTAL_INPUT_SIZE)$(format_bytes $OUTPUT_SIZE)"
301+
log_diagnostic "Compression: $RATIO of original"
309302

310-
# Show size comparison
311-
if [ ${#INPUT_FILES[@]} -gt 0 ]; then
312-
RATIO=$(calc_compression_ratio $TOTAL_INPUT_SIZE $OUTPUT_SIZE)
313-
log_diagnostic "Output size: $(format_bytes $OUTPUT_SIZE)"
314-
log_diagnostic "Size ratio: $RATIO of input"
315-
316-
if [ "$OUTPUT_SIZE" -lt "$TOTAL_INPUT_SIZE" ]; then
317-
SAVINGS=$((TOTAL_INPUT_SIZE - OUTPUT_SIZE))
318-
SAVINGS_PCT=$(awk "BEGIN {printf \"%.1f%%\", (1 - $OUTPUT_SIZE/$TOTAL_INPUT_SIZE) * 100}")
319-
log_diagnostic "Savings: $(format_bytes $SAVINGS) ($SAVINGS_PCT reduction)"
320-
fi
303+
if [ "$OUTPUT_SIZE" -lt "$TOTAL_INPUT_SIZE" ]; then
304+
SAVINGS=$((TOTAL_INPUT_SIZE - OUTPUT_SIZE))
305+
SAVINGS_PCT=$(awk "BEGIN {printf \"%.1f%%\", (1 - $OUTPUT_SIZE/$TOTAL_INPUT_SIZE) * 100}")
306+
log_diagnostic "Space saved: $(format_bytes $SAVINGS) ($SAVINGS_PCT reduction)"
321307
fi
322-
323-
echo ""
324308
fi
309+
echo ""
310+
else
311+
# Without diagnostics: concise output
312+
# Extract just the key info from converter output
313+
CONVERSION_TIME=$(echo "$CONVERTER_OUTPUT" | grep -o 'Time: [0-9]* ms' | grep -o '[0-9]*' | head -1)
314+
OUTPUT_SIZE=$(get_file_size_bytes "$OUTPUT_FILE")
315+
316+
log_success "Converted: $OUTPUT_FILE ($(format_bytes $OUTPUT_SIZE), ${CONVERSION_TIME}ms)"
325317
fi
326318
else
327319
echo "$CONVERTER_OUTPUT"

dd-java-agent/agent-profiling/profiling-otel/doc/CLI.md

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -364,19 +364,27 @@ Show detailed diagnostics:
364364
./convert-jfr.sh --diagnostics recording.jfr output.pb
365365
```
366366

367-
Output:
367+
Output with diagnostics:
368368
```
369-
[INFO] Converting JFR to OTLP format...
370369
[DIAG] Input: recording.jfr (89.3KB)
371370
[DIAG] Total input size: 89.3KB
372-
[SUCCESS] Conversion completed successfully!
373-
[INFO] Output file: output.pb (45.2KB)
371+
Converting 1 JFR file(s) to OTLP format...
372+
Adding: recording.jfr
373+
Conversion complete!
374+
Output: output.pb
375+
Format: PROTO
376+
Size: 45.2 KB
377+
Time: 127 ms
374378
375-
[DIAG] === Conversion Diagnostics ===
376-
[DIAG] Wall time: 127.3ms
377-
[DIAG] Output size: 45.2KB
378-
[DIAG] Size ratio: 50.6% of input
379-
[DIAG] Savings: 44.1KB (49.4% reduction)
379+
[DIAG] === Enhanced Diagnostics ===
380+
[DIAG] Input → Output: 89.3KB → 45.2KB
381+
[DIAG] Compression: 50.6% of original
382+
[DIAG] Space saved: 44.1KB (49.4% reduction)
383+
```
384+
385+
Without diagnostics (concise):
386+
```
387+
[SUCCESS] Converted: output.pb (45.2KB, 127ms)
380388
```
381389

382390
### Features
@@ -391,11 +399,26 @@ Output:
391399

392400
### Script Output
393401

402+
Without diagnostics (default):
403+
```
404+
[SUCCESS] Converted: output.pb (45.2KB, 127ms)
405+
```
406+
407+
With --diagnostics flag:
394408
```
395-
[INFO] Converting JFR to OTLP format...
396-
[INFO] Arguments: recording.jfr output.pb
397-
[SUCCESS] Conversion completed successfully!
398-
[INFO] Output file: output.pb (45K)
409+
[DIAG] Input: recording.jfr (89.3KB)
410+
Converting 1 JFR file(s) to OTLP format...
411+
Adding: recording.jfr
412+
Conversion complete!
413+
Output: output.pb
414+
Format: PROTO
415+
Size: 45.2 KB
416+
Time: 127 ms
417+
418+
[DIAG] === Enhanced Diagnostics ===
419+
[DIAG] Input → Output: 89.3KB → 45.2KB
420+
[DIAG] Compression: 50.6% of original
421+
[DIAG] Space saved: 44.1KB (49.4% reduction)
399422
```
400423

401424
### When to Use

0 commit comments

Comments
 (0)