-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/ui: add first stage of redesigned tracez page
Begins to implement https://www.figma.com/file/LUptGAxt5x1idq6eZLA50o/BulkIO-Traces?node-id=59%3A7958 When complete, the new pages will offer: - A robust route structure and full redux integration for better navigation. - Denser information display. - More information display, i.e. start time/duration, and expanding mutliple tag groups. - A new span details page, which will include child span information. For now, this page is behind a new route with no entrypoint. It implements the core route structure, redux selectors and API calls. Left for later PRs are Take Snapshot, the Span Details page, pagination, search filtering, and View Raw JSON. Release note: None
- Loading branch information
Showing
13 changed files
with
829 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// 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 { cockroach } from "@cockroachlabs/crdb-protobuf-client"; | ||
import { fetchData } from "src/api"; | ||
import TakeTracingSnapshotRequest = cockroach.server.serverpb.TakeTracingSnapshotRequest; | ||
|
||
export type ListTracingSnapshotsRequestMessage = | ||
cockroach.server.serverpb.ListTracingSnapshotsRequest; | ||
export type ListTracingSnapshotsResponseMessage = | ||
cockroach.server.serverpb.ListTracingSnapshotsResponse; | ||
|
||
export type TakeTracingSnapshotRequestMessage = TakeTracingSnapshotRequest; | ||
export type TakeTracingSnapshotResponseMessage = | ||
cockroach.server.serverpb.TakeTracingSnapshotResponse; | ||
|
||
export type GetTracingSnapshotRequestMessage = | ||
cockroach.server.serverpb.GetTracingSnapshotRequest; | ||
export type GetTracingSnapshotResponseMessage = | ||
cockroach.server.serverpb.GetTracingSnapshotResponse; | ||
|
||
export type Span = cockroach.server.serverpb.ITracingSpan; | ||
export type Snapshot = cockroach.server.serverpb.ITracingSnapshot; | ||
|
||
export type GetTraceRequestMessage = cockroach.server.serverpb.GetTraceRequest; | ||
export type GetTraceResponseMessage = | ||
cockroach.server.serverpb.GetTraceResponse; | ||
|
||
const API_PREFIX = "_admin/v1"; | ||
|
||
export function listTracingSnapshots(): Promise<ListTracingSnapshotsResponseMessage> { | ||
return fetchData( | ||
cockroach.server.serverpb.ListTracingSnapshotsResponse, | ||
`${API_PREFIX}/trace_snapshots`, | ||
null, | ||
null, | ||
"30M", // 30 minute timeout. | ||
); | ||
} | ||
|
||
export function takeTracingSnapshot(): Promise<TakeTracingSnapshotResponseMessage> { | ||
const req = new TakeTracingSnapshotRequest(); | ||
return fetchData( | ||
cockroach.server.serverpb.TakeTracingSnapshotResponse, | ||
`${API_PREFIX}/trace_snapshots`, | ||
req as any, | ||
null, | ||
"30M", | ||
); | ||
} | ||
|
||
export function getTracingSnapshot( | ||
snapshotID: number, | ||
): Promise<GetTracingSnapshotResponseMessage> { | ||
return fetchData( | ||
cockroach.server.serverpb.GetTracingSnapshotResponse, | ||
`${API_PREFIX}/trace_snapshots/${snapshotID}`, | ||
null, | ||
null, | ||
"30M", | ||
); | ||
} | ||
|
||
export function getTraceForSnapshot( | ||
req: GetTraceRequestMessage, | ||
): Promise<GetTraceResponseMessage> { | ||
return fetchData( | ||
cockroach.server.serverpb.GetTraceResponse, | ||
`${API_PREFIX}/traces`, | ||
req as any, | ||
null, | ||
"30M", | ||
); | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// 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. | ||
|
||
export * from "./snapshot"; |
70 changes: 70 additions & 0 deletions
70
pkg/ui/workspaces/cluster-ui/src/tracez/snapshot.module.scss
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// 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 "src/core/index.module.scss"; | ||
|
||
.snapshots-page { | ||
display: flex; | ||
flex-flow: column; | ||
height: 100%; | ||
} | ||
|
||
.no-results { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100%; | ||
} | ||
|
||
.table-row { | ||
vertical-align: top; | ||
height: 4px; // Override the default row-wrapper height of 70px. | ||
} | ||
|
||
.table-cell { | ||
padding: 4px 0px 4px 16px; // For vertical, override default of 16px. | ||
} | ||
|
||
.operation-cell { | ||
padding: 4px 0px 4px 0px; // For vertical, override default of 16px. | ||
} | ||
|
||
.icon-cell { | ||
padding: 4px 4px 4px 0px; | ||
margin: 0px; | ||
display: flex; | ||
justify-content: right; | ||
} | ||
|
||
.table-cell-duration { | ||
padding: 4px 16px; // For vertical, override default of 16px. | ||
display: flex; | ||
justify-content: right; | ||
min-width: 22ch; | ||
} | ||
|
||
.tag-group-cell { | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
|
||
.tag-cell { | ||
gap: 4px; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.plus-minus { | ||
border-style: solid; | ||
border-width: 1px; | ||
height: 12px; | ||
width: 12px; | ||
margin-top: 4px; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// 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. | ||
|
||
export * from "./snapshotPage"; | ||
export * from "./spanTable"; |
86 changes: 86 additions & 0 deletions
86
pkg/ui/workspaces/cluster-ui/src/tracez/snapshot/snapshotPage.spec.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// 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 { SnapshotPage, SnapshotPageProps } from "./snapshotPage"; | ||
import { render } from "@testing-library/react"; | ||
import React from "react"; | ||
import { MemoryRouter } from "react-router-dom"; | ||
import * as H from "history"; | ||
|
||
import { SortSetting } from "../../sortedtable"; | ||
import { cockroach } from "@cockroachlabs/crdb-protobuf-client"; | ||
import GetTracingSnapshotResponse = cockroach.server.serverpb.GetTracingSnapshotResponse; | ||
|
||
const getMockSnapshotPageProps = (): SnapshotPageProps => { | ||
const history = H.createHashHistory(); | ||
return { | ||
location: history.location, | ||
history, | ||
match: { | ||
url: "", | ||
path: history.location.pathname, | ||
isExact: false, | ||
params: {}, | ||
}, | ||
refreshSnapshot: (id: number): void => {}, | ||
refreshSnapshots: (): void => {}, | ||
setSort: (value: SortSetting): void => {}, | ||
snapshotError: undefined, | ||
snapshotLoading: false, | ||
snapshots: undefined, | ||
snapshotsError: undefined, | ||
snapshotsLoading: false, | ||
sort: undefined, | ||
snapshot: null, | ||
}; | ||
}; | ||
|
||
describe("Snapshot", () => { | ||
it("renders expected snapshot table columns", () => { | ||
const props = getMockSnapshotPageProps(); | ||
props.snapshot = GetTracingSnapshotResponse.fromObject({ | ||
snapshot: { | ||
spans: [{ span_id: 1 }], | ||
}, | ||
}); | ||
const { getByText } = render( | ||
<MemoryRouter> | ||
<SnapshotPage {...props} /> | ||
</MemoryRouter>, | ||
); | ||
const expectedColumnTitles = [ | ||
"Span", | ||
"Start Time (UTC)", | ||
"Duration", | ||
"Expandable Tags", | ||
"Tags", | ||
]; | ||
|
||
for (const columnTitle of expectedColumnTitles) { | ||
getByText(columnTitle); | ||
} | ||
}); | ||
|
||
it("renders a message when the table is empty", () => { | ||
const { getByText } = render( | ||
<MemoryRouter> | ||
<SnapshotPage {...getMockSnapshotPageProps()} /> | ||
</MemoryRouter>, | ||
); | ||
const expectedText = [ | ||
"No spans to show", | ||
"Spans provide debug information.", | ||
]; | ||
|
||
for (const text of expectedText) { | ||
getByText(text); | ||
} | ||
}); | ||
}); |
Oops, something went wrong.