Skip to content

Commit

Permalink
Merge #93207 #94661
Browse files Browse the repository at this point in the history
93207: pkg/ui: Add span details component to tracez_v2. r=benbardin a=benbardin

This PR adds the "span details" and "raw trace" screens to the new tracez_v2 page. Previously, only the "snapshot details (i.e. list spans) screen existed on that page. The detailed span information page is where users will go to dig in to the specifics of a span. In particular, we'll display accumulated data on child spans of that page, helping navigate to problem segments more easily.

Note that this PR brings the v2 page up to feature parity with the v1 page. Though the redesign is not yet complete, we'll be able to turn down the v1 page after this lands.

This PR also modifies the route structure a little to encapsulate better.

Release note: None

<img width="1583" alt="Screen Shot 2022-12-07 at 1 52 26 PM" src="https://user-images.githubusercontent.com/261508/206270214-9708e298-cc8e-4a69-9554-8bfb8555277c.png">

<img width="1583" alt="Screen Shot 2022-12-07 at 1 51 59 PM" src="https://user-images.githubusercontent.com/261508/206270152-8d0a36f0-c64d-40bd-a47e-1573039e33ac.png">

<img width="1664" alt="Screen Shot 2022-12-05 at 12 12 41 PM" src="https://user-images.githubusercontent.com/261508/206269949-a62130c7-53cf-4655-84ae-8f6c42d4e66e.png">

Informs #83679

94661: coldata: fix recent flaky behavior r=yuzefovich a=yuzefovich

In a just merged b353d18 when addressing the PR feedback I introduced a possibility of a crash in tests. In particular, this can occur if we choose to randomize `coldata.BatchSize` value larger than the default (or if the test explicitly overrides it). The problem is that `BatchSize()` can return different values in `init()` of `coldata` package and during the test runs, so we now use `MaxBatchSize` where applicable.

Epic: None

Release note: None

Co-authored-by: Ben Bardin <[email protected]>
Co-authored-by: Yahor Yuzefovich <[email protected]>
  • Loading branch information
3 people committed Jan 3, 2023
3 parents c533c2b + c793ceb + f1a608e commit 5c892eb
Show file tree
Hide file tree
Showing 13 changed files with 995 additions and 213 deletions.
8 changes: 4 additions & 4 deletions pkg/col/coldata/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ func (b *Bytes) elementsAsBytes(n int) []byte {
var zeroInt32Slice []int32

func init() {
zeroInt32Slice = make([]int32, BatchSize())
zeroInt32Slice = make([]int32, MaxBatchSize)
}

// Serialize converts b into the "arrow-like" (which is arrow-compatible)
Expand All @@ -579,12 +579,12 @@ func init() {
// buffer = [<b.elements as []byte><b.buffer]
// offsets = [0, 0, ..., 0, len(<b.elements as []byte>), len(<b.elements as []byte>) + len(buffer)]
//
// Note: it is assumed that n is not larger than BatchSize().
// Note: it is assumed that n is not larger than MaxBatchSize.
func (b *Bytes) Serialize(n int, dataScratch []byte, offsetsScratch []int32) ([]byte, []int32) {
if buildutil.CrdbTestBuild {
if n > BatchSize() {
if n > MaxBatchSize {
colexecerror.InternalError(errors.AssertionFailedf(
"too many bytes elements to serialize: %d vs BatchSize() of %d", n, BatchSize(),
"too many bytes elements to serialize: %d vs MaxBatchSize of %d", n, MaxBatchSize,
))
}
}
Expand Down
43 changes: 38 additions & 5 deletions pkg/ui/workspaces/cluster-ui/src/api/tracezApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import { cockroach } from "@cockroachlabs/crdb-protobuf-client";
import { fetchData } from "src/api";

import Long from "long";
export type ListTracingSnapshotsRequest =
cockroach.server.serverpb.ListTracingSnapshotsRequest;
export type ListTracingSnapshotsResponse =
Expand All @@ -29,9 +29,15 @@ export type GetTracingSnapshotResponse =
export type Span = cockroach.server.serverpb.ITracingSpan;
export type Snapshot = cockroach.server.serverpb.ITracingSnapshot;

export type GetTraceRequest = cockroach.server.serverpb.GetTraceRequest;
export const GetTraceRequest = cockroach.server.serverpb.GetTraceRequest;
export type GetTraceResponse = cockroach.server.serverpb.GetTraceResponse;

export const SetTraceRecordingTypeRequest =
cockroach.server.serverpb.SetTraceRecordingTypeRequest;
export type SetTraceRecordingTypeResponse =
cockroach.server.serverpb.SetTraceRecordingTypeResponse;
export type RecordingMode = cockroach.util.tracing.tracingpb.RecordingMode;

const API_PREFIX = "_admin/v1";

export function listTracingSnapshots(
Expand All @@ -58,6 +64,8 @@ export function takeTracingSnapshot(
);
}

// This is getting plugged into our redux libraries, which want calls with a
// single argument. So wrap the two arguments in a request object.
export function getTracingSnapshot(req: {
nodeID: string;
snapshotID: number;
Expand All @@ -70,14 +78,39 @@ export function getTracingSnapshot(req: {
);
}

export function getTraceForSnapshot(req: {
// This is getting plugged into our redux libraries, which want calls with a
// single argument. So wrap the two arguments in a request object.
export function getRawTrace(req: {
nodeID: string;
req: GetTraceRequest;
snapshotID: number;
traceID: Long;
}): Promise<GetTraceResponse> {
const rpcReq = new GetTraceRequest({
snapshot_id: Long.fromNumber(req.snapshotID),
trace_id: req.traceID,
});
return fetchData(
cockroach.server.serverpb.GetTraceResponse,
`${API_PREFIX}/traces?remote_node_id=${req.nodeID}`,
cockroach.server.serverpb.GetTraceRequest,
req.req as any,
rpcReq as any,
);
}

export function setTraceRecordingType(
nodeID: string,
traceID: Long,
recordingMode: RecordingMode,
): Promise<SetTraceRecordingTypeResponse> {
const req = new SetTraceRecordingTypeRequest({
trace_id: traceID,
recording_mode: recordingMode,
});
return fetchData(
cockroach.server.serverpb.SetTraceRecordingTypeResponse,
// TODO(davidh): Consider making this endpoint just POST to `/traces/{trace_ID}`
`${API_PREFIX}/settracerecordingtype?remote_node_id=${nodeID}`,
cockroach.server.serverpb.SetTraceRecordingTypeRequest,
req as any,
);
}
63 changes: 62 additions & 1 deletion pkg/ui/workspaces/cluster-ui/src/tracez/snapshot.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
display: flex;
flex-flow: column;
height: 100%;
font-family: $font-family--base;
}

.no-results {
Expand Down Expand Up @@ -66,6 +67,7 @@

.table-title-time {
width: 20ch;
margin-right: 4px;
}

.tag-group {
Expand Down Expand Up @@ -104,7 +106,66 @@
padding-top: 1px;
}

.icon-gray {
fill: lightgray;
height: 10px;
width: 10px;
padding-top: 1px;
}

.section {
flex: 0 0 auto;
padding: 12px 24px 140px 0px;
padding: 12px 24px 12px 0px;
}

.span-section {
background-color: $colors--neutral-0;
padding: 12px;
margin-right: 12px;
margin-bottom: 12px;
}

.bottom-padding {
padding-bottom: 140px;
}

.span-snapshot-key {
font-family: $font-family--bold;
}

.span-snapshot-key-value {
padding-bottom: 4px;
}

.span-snapshot-column {
min-width: fit-content;
}

.span-snapshot-columns {
display: flex;
flex-direction: row;
gap: 24px;
}

.span-header-columns {
display: flex;
flex-direction: row;
padding-bottom: 12px;
padding-right: 12px;
align-items: center;
}

.span-details-title {
color: $colors--neutral-7;
font-family: $font-family--semi-bold;
font-style: normal;
font-stretch: normal;
font-size: 20px;
padding-bottom: 0px;
margin-bottom: 0px;
width: 100%;
}

.span-details-raw-trace-button {
flex-shrink: 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright 2022 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

import { GetTraceResponse } from "src/api";
import Long from "long";
import { Loading } from "src/loading";
import React, { useEffect } from "react";
import classNames from "classnames/bind";
import styles from "../snapshot.module.scss";
const cx = classNames.bind(styles);

export const RawTraceComponent: React.FC<{
nodeID: string;
snapshotID: number;
traceID: Long;
rawTrace: GetTraceResponse;
rawTraceLoading: boolean;
rawTraceError?: Error;
refreshRawTrace: (req: {
nodeID: string;
snapshotID: number;
traceID: Long;
}) => void;
}> = props => {
const {
nodeID,
snapshotID,
traceID,
rawTrace,
rawTraceLoading,
rawTraceError,
refreshRawTrace,
} = props;

useEffect(() => {
if (!(nodeID && snapshotID && traceID)) {
return;
}
refreshRawTrace({
nodeID,
snapshotID,
traceID,
});
}, [nodeID, snapshotID, traceID, refreshRawTrace]);

return (
<Loading
loading={rawTraceLoading}
page={"raw trace"}
error={rawTraceError}
render={() => {
return (
<>
<section
data-testid="raw-trace-component"
className={cx("span-section")}
>
<pre>{rawTrace?.serialized_recording}</pre>
</section>
<div className={cx("bottom-padding")} />
</>
);
}}
/>
);
};
Loading

0 comments on commit 5c892eb

Please sign in to comment.