trace: OpenTelemetry waterfall renderer - #40
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
stripes/tracesub-package that renders OpenTelemetry trace data as a terminal waterfall, registered underapplication/vnd.opentelemetry.trace(binary+protobufand+json).TracesData,ResourceSpans,ScopeSpans, orSpan— binary protobuf or protojson.Write/Format/Newoveriter.Seq[*tracev1.ResourceSpans], withFromTracesData/FromResourceSpans/FromScopeSpans/FromSpansadapters; byte-streamNewRenderer/NewJSONRenderermirror the protobuf package.--format=trace,-v/--verbose, and--format=autorouting when--schemaor amessageTypeMIME parameter names an OTLP trace type.Rendering
Each
trace_idis its own block:Key: valuemetadata (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.span-number │ tree+kind+name │ duration │ start-delta │ bar.█characters (survive copy-paste), coloured by an HSL hash ofservice.name; lightness fades with tree depth (softened so deep rows stay legible). Right edge uses eighth-block sub-cell precision.ERROR <first-line-of-message>on the bar (left-aligned), with the bar hue showing through as the text background where they overlap.-vappends 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 ./...passesgofmtcleantrace/bench_test.go,b.ReportAllocs())detect_otlp_messagetype.txtar) — auto-routes to the waterfall;--format=protobuf --schema=…still gets the prototext viewstripes s3://…/*.binpbrenders the waterfall for a real OTLP trace🤖 Generated with Claude Code