Skip to content

trace: OpenTelemetry waterfall renderer - #40

Merged
achille-roussel merged 2 commits into
mainfrom
traces
May 21, 2026
Merged

trace: OpenTelemetry waterfall renderer#40
achille-roussel merged 2 commits into
mainfrom
traces

Conversation

@achille-roussel

Copy link
Copy Markdown
Contributor

Summary

Adds a stripes/trace sub-package that renders OpenTelemetry trace data as a terminal waterfall, registered under application/vnd.opentelemetry.trace (binary +protobuf and +json).

  • Input: TracesData, ResourceSpans, ScopeSpans, or Span — binary protobuf or protojson.
  • Structured API: Write / Format / New over iter.Seq[*tracev1.ResourceSpans], with FromTracesData / FromResourceSpans / FromScopeSpans / FromSpans adapters; byte-stream NewRenderer / NewJSONRenderer mirror the protobuf package.
  • CLI: --format=trace, -v/--verbose, and --format=auto routing when --schema or a messageType MIME parameter names an OTLP trace type.

Rendering

Each trace_id is its own block:

  • Multi-line header: top rule, Key: value metadata (Trace, Root, Duration, Spans, Errors), a Services legend table (swatch, name, self-time wall-clock coverage, ratio, span/error counts), and a full-width tick-mark time axis.
  • One row per span: span-number │ tree+kind+name │ duration │ start-delta │ bar.
  • Bars are real characters (survive copy-paste), coloured by an HSL hash of service.name; lightness fades with tree depth (softened so deep rows stay legible). Right edge uses eighth-block sub-cell precision.
  • Error spans overlay a bold red ERROR <first-line-of-message> on the bar (left-aligned), with the bar hue showing through as the text background where they overlap.
  • -v appends a Spans section: one detail tile per span (span N · name · service, attributes, status message, events), correlated to the chart by span number.

Test plan

  • go test ./... passes
  • gofmt clean
  • Benchmarks added (trace/bench_test.go, b.ReportAllocs())
  • CLI testscript updated (detect_otlp_messagetype.txtar) — auto-routes to the waterfall; --format=protobuf --schema=… still gets the prototext view
  • Manual: stripes s3://…/*.binpb renders the waterfall for a real OTLP trace

🤖 Generated with Claude Code

achille-roussel and others added 2 commits May 20, 2026 20:00
Add a stripes/trace sub-package that renders OTLP TracesData (and
ResourceSpans/ScopeSpans/Span, binary or protojson) as a terminal
waterfall, plus a structured Go API (Write/Format/New over
iter.Seq[*tracev1.ResourceSpans] with FromXxx adapters) and
byte-stream renderers wired into the stripes registry under
application/vnd.opentelemetry.trace.

Each trace_id renders as its own block: a multi-line header (rule,
key/value metadata, a Services legend table, and a tick-mark time
axis) followed by one row per span — span number, tree+kind+name,
duration, start-delta, and a bar made of real █ characters (so it
survives copy-paste). Service colour comes from an HSL hash of
service.name; lightness fades with tree depth, softened so deep
rows stay legible. Error spans overlay a bold red "ERROR <msg>" on
the bar. The -v flag adds a trailing "Spans" section with one
detail tile per span, correlated to the chart by span number.

CLI: --format=trace, -v/--verbose, and --format=auto routing when
--schema or a messageType MIME parameter names an OTLP trace type.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Staticcheck (U1000) flagged both: renderBar builds the bar style
inline from serviceColorAtDepth, and the header metadata no longer
pluralizes the Spans/Errors labels.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@achille-roussel
achille-roussel merged commit 28e7152 into main May 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant