-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show a trace viewer in the execution page with timeseries data #7889
base: master
Are you sure you want to change the base?
Conversation
5cba57a
to
a7368f6
Compare
a7368f6
to
31e2dd1
Compare
31e2dd1
to
c24e1ed
Compare
// | ||
// The format is documented here: | ||
// https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU | ||
package trace_events |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally tried using https://github.com/omaskery/teffy instead of writing this package, but ultimately didn't like how it turned out:
- The library nicely models the Trace Event Format from a correctness standpoint. It "makes invalid states unrepresentable" to a strict degree, splitting out the different "types" of events into separate structs rather than using a single flat struct with a "type" field (i.e. the
"ph"
/ "phase" field in the JSON object). But the library heavily relies on struct embedding, which I found overly verbose and confusing since it suggests nesting that doesn't actually exist in the format. (It's confusing both when reading the call-sites and when reading the library implementation.) The JSON representation is also hidden in a separate "io" package which made it harder to mentally map the structs to the actual Trace Event Format. For example, theCounter
event has aValues
field which actually maps to"args"
in the JSON representation, which was confusing to me and took a minute to grok. - The
StreamingWriter
implementation doesn't append newlines between each JSON object which makes it non-browser-friendly. In the browser we rely on the newline to separate objects, since the browser doesn't have a streaming JSON parser built in. (This is somewhat minor though and could be patched in if we really wanted it.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like @tylerwilliams has more opinions about the structure of file requests in buildbuddy_server
than i do, so i'm really just focusing on the ts stuff, which all seems fine, just some dumb little nits.
"stream" | ||
) | ||
.then((response) => { | ||
if (!response.body) throw new Error("failed to read profile: response body is null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
personal pet peeve: could be empty, probably is undefined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tsc says the type of response.body
is ReadableStream<Uint8Array<ArrayBufferLike>> | null
in this case, so I think this is correct. Checked === null
explicitly though to limit the type-narrowing magic here
} | ||
|
||
getExecutionId() { | ||
return this.props.search.get("executionId") || this.state.executionId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this condition feels backward to me? i guess they shouldn't mismatch and one just shows up later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a clarifying comment
})} | ||
{this.state.profile ? ( | ||
<TraceViewer profile={this.state.profile} fitToContent filterHidden /> | ||
) : this.state.profileLoading ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
order seems wrong to me here (i.e., we should always show a spinner if profileLoading == true
)--i assume it's because we always clear profile
when we have something pending.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, the logic is technically correct but I do think it's more clear to swap the order here (done)
@@ -62,11 +63,14 @@ const TIME_SERIES_EVENT_NAMES_AND_ARG_KEYS: Map<string, string> = new Map([ | |||
["System load average", "load"], | |||
["Network Up usage (total)", "system network up (Mbps)"], | |||
["Network Down usage (total)", "system network down (Mbps)"], | |||
|
|||
// Executor | |||
["CPU usage", "cpu"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe update the comment above to explain where these values come from + why we don't need "CPU Usage" for "Bazel" (which has "CPU usage (Bazel)") but do for "Executor"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some more detail to the comments but not sure if I totally understood the concern - lmk if it's still unclear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw I don't know the original context for this (maybe @luluz66 remembers) but I think we could potentially remove this explicit list and just render all of the timeseries, which are identified by "ph": "C"
("Counter") in the JSON objects. (Spans have "ph":"X"
and timeseries have "ph":"C"
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. this list is used as a filter when parsing trace events.
app/trace/trace_viewer_model.ts
Outdated
const panels = [ | ||
buildEventsPanel(trace.traceEvents, fitToContent), | ||
buildLinePlotsPanel(trace.traceEvents, fitToContent), | ||
].filter((panel) => panel.sections.length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does it mean to have a panel with no sections / why do we need to guard for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment
1528328
to
dffb288
Compare
dffb288
to
adaa8d3
Compare
ExecutedActionMetadata
and is streamed to the client over the/file/download
endpoint using the JSON Trace Event Format