Skip to content

Commit

Permalink
fix(mockotlpserver): fix an alignment issue in trace-summary gutter w…
Browse files Browse the repository at this point in the history
…ith 1-char units

Before:

```
------ trace 43670f (3 spans) ------
       span 7dc366 "Test Parent" (2007.4ms, SPAN_KIND_INTERNAL)
  +1ms `- span f84ec1 "Test Child 1" (1003.2ms, SPAN_KIND_INTERNAL)
  +1s `- span 534247 "Test Child 2" (1002.1ms, SPAN_KIND_INTERNAL)
```

After:

```
------ trace 43670f (3 spans) ------
       span 7dc366 "Test Parent" (2007.4ms, SPAN_KIND_INTERNAL)
  +1ms `- span f84ec1 "Test Child 1" (1003.2ms, SPAN_KIND_INTERNAL)
  +1s  `- span 534247 "Test Child 2" (1002.1ms, SPAN_KIND_INTERNAL)
```
  • Loading branch information
trentm committed Jan 29, 2025
1 parent 36c3745 commit 53f16ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/mockotlpserver/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# @elastic/mockotlpserver Changelog

## unreleased

- Fix an alignment issue in the "gutter" of the trace-summary (waterfall) output
when 1-char units are used (i.e. any time unit above "ms").

## v0.6.2

- Fix Docker publishing (permissions, context dir).
Expand Down
4 changes: 3 additions & 1 deletion packages/mockotlpserver/lib/waterfall.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ function renderSpan(span, prefix = '') {
unit = 'd';
}
gutter = `${sign}${Math.floor(startOffset)}`;
gutter = `${' '.repeat(4 - gutter.length)}${gutter}${unit}`;
gutter = `${' '.repeat(4 - gutter.length)}${gutter}${unit}${' '.repeat(
2 - unit.length
)}`;
} else {
gutter = ' '.repeat(6);
}
Expand Down

0 comments on commit 53f16ac

Please sign in to comment.