Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into bz/embedded-jaeger-ui
Browse files Browse the repository at this point in the history
Signed-off-by: Bugen Zhao <[email protected]>
  • Loading branch information
BugenZhao committed Jan 4, 2024
2 parents c4cc84c + 0a95b8c commit 3579f74
Show file tree
Hide file tree
Showing 62 changed files with 1,332 additions and 635 deletions.
18 changes: 10 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 3 additions & 10 deletions dashboard/components/BackPressureTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import {
Th,
Thead,
Tr,
useToast,
} from "@chakra-ui/react"
import { sortBy } from "lodash"
import Head from "next/head"
import { Fragment, useEffect, useState } from "react"
import useErrorToast from "../hook/useErrorToast"
import { getActorBackPressures } from "../pages/api/metric"
import RateBar from "./RateBar"
import { Metrics } from "./metrics"
Expand All @@ -44,7 +44,7 @@ export default function BackPressureTable({
}) {
const [backPressuresMetrics, setBackPressuresMetrics] =
useState<BackPressuresMetrics>()
const toast = useToast()
const toast = useErrorToast()

useEffect(() => {
async function doFetch() {
Expand All @@ -58,14 +58,7 @@ export default function BackPressureTable({
setBackPressuresMetrics(metrics)
await new Promise((resolve) => setTimeout(resolve, 5000)) // refresh every 5 secs
} catch (e: any) {
toast({
title: "Error Occurred",
description: e.toString(),
status: "error",
duration: 5000,
isClosable: true,
})
console.error(e)
toast(e, "warning")
break
}
}
Expand Down
4 changes: 2 additions & 2 deletions dashboard/components/FragmentGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
generateBoxLinks,
layout,
} from "../lib/layout"
import { PlanNodeDatum } from "../pages/streaming_plan"
import { PlanNodeDatum } from "../pages/fragment_graph"
import BackPressureTable from "./BackPressureTable"

const ReactJson = loadable(() => import("react-json-view"))
Expand Down Expand Up @@ -218,7 +218,7 @@ export default function FragmentGraph({

text
.attr("fill", "black")
.text(({ id }) => `Fragment #${id}`)
.text(({ id }) => `Fragment ${id}`)
.attr("font-family", "inherit")
.attr("text-anchor", "end")
.attr("dy", ({ height }) => height - actorMarginY + 12)
Expand Down
4 changes: 2 additions & 2 deletions dashboard/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ function Layout({ children }: { children: React.ReactNode }) {
</Section>
<Section>
<NavTitle>Streaming</NavTitle>
<NavButton href="/streaming_graph/">Graph</NavButton>
<NavButton href="/streaming_plan/">Fragments</NavButton>
<NavButton href="/dependency_graph/">Dependency Graph</NavButton>
<NavButton href="/fragment_graph/">Fragment Graph</NavButton>
</Section>
<Section>
<NavTitle>Batch</NavTitle>
Expand Down
13 changes: 3 additions & 10 deletions dashboard/components/Relations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ import {
Thead,
Tr,
useDisclosure,
useToast,
} from "@chakra-ui/react"
import loadable from "@loadable/component"
import Head from "next/head"

import Link from "next/link"
import { Fragment, useEffect, useState } from "react"
import Title from "../components/Title"
import useErrorToast from "../hook/useErrorToast"
import extractColumnInfo from "../lib/extractInfo"
import { Relation, StreamingJob } from "../pages/api/streaming"
import {
Expand Down Expand Up @@ -121,22 +121,15 @@ export function Relations<R extends Relation>(
getRelations: () => Promise<R[]>,
extraColumns: Column<R>[]
) {
const toast = useToast()
const toast = useErrorToast()
const [relationList, setRelationList] = useState<R[]>([])

useEffect(() => {
async function doFetch() {
try {
setRelationList(await getRelations())
} catch (e: any) {
toast({
title: "Error Occurred",
description: e.toString(),
status: "error",
duration: 5000,
isClosable: true,
})
console.error(e)
toast(e)
}
}
doFetch()
Expand Down
47 changes: 47 additions & 0 deletions dashboard/hook/useErrorToast.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2024 RisingWave Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { AlertStatus, useToast } from "@chakra-ui/react"
import { useCallback } from "react"

export default function useErrorToast() {
const toast = useToast()

return useCallback(
(e: any, status: AlertStatus = "error") => {
let title: string
let description: string | undefined

if (e instanceof Error) {
title = e.message
description = e.cause?.toString()
} else {
title = e.toString()
}

toast({
title,
description,
status,
duration: 5000,
isClosable: true,
})

console.error(e)
},
[toast]
)
}
36 changes: 0 additions & 36 deletions dashboard/hook/useWindowSize.js

This file was deleted.

6 changes: 5 additions & 1 deletion dashboard/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ function App({ Component, pageProps }: AppProps) {
const [isLoading, setIsLoading] = useState(false)

useEffect(() => {
router.events.on("routeChangeStart", () => setIsLoading(true))
router.events.on("routeChangeStart", (url, { shallow }) => {
if (!shallow) {
setIsLoading(true)
}
})
router.events.on("routeChangeComplete", () => setIsLoading(false))
router.events.on("routeChangeError", () => setIsLoading(false))
}, [router.events])
Expand Down
4 changes: 3 additions & 1 deletion dashboard/pages/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class Api {
return data
} catch (e) {
console.error(e)
throw Error("Failed to fetch " + url)
throw Error(`Failed to fetch ${url}`, {
cause: e,
})
}
}
}
Expand Down
13 changes: 3 additions & 10 deletions dashboard/pages/api/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,20 @@
*
*/

import { useToast } from "@chakra-ui/react"
import { useEffect, useState } from "react"
import useErrorToast from "../../hook/useErrorToast"

export default function useFetch<T>(fetchFn: () => Promise<T>) {
const [response, setResponse] = useState<T>()
const toast = useToast()
const toast = useErrorToast()

useEffect(() => {
const fetchData = async () => {
try {
const res = await fetchFn()
setResponse(res)
} catch (e: any) {
toast({
title: "Error Occurred",
description: e.toString(),
status: "error",
duration: 5000,
isClosable: true,
})
console.error(e)
toast(e)
}
}
fetchData()
Expand Down
2 changes: 1 addition & 1 deletion dashboard/pages/await_tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default function AwaitTreeDump() {

result = `${title}\n\n${actorTraces}\n${rpcTraces}`
} catch (e: any) {
result = `${title}\n\nError: ${e.message}`
result = `${title}\n\nERROR: ${e.message}\n${e.cause}`
}

setDump(result)
Expand Down
22 changes: 4 additions & 18 deletions dashboard/pages/cluster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
SimpleGrid,
Text,
theme,
useToast,
VStack,
} from "@chakra-ui/react"
import { clone, reverse, sortBy } from "lodash"
Expand All @@ -32,6 +31,7 @@ import { Fragment, useCallback, useEffect, useState } from "react"
import { Area, AreaChart, ResponsiveContainer, XAxis, YAxis } from "recharts"
import { Metrics, MetricsSample } from "../components/metrics"
import Title from "../components/Title"
import useErrorToast from "../hook/useErrorToast"
import { WorkerNode } from "../proto/gen/common"
import {
getClusterInfoComputeNode,
Expand Down Expand Up @@ -142,22 +142,15 @@ export default function Cluster() {
const [frontendList, setFrontendList] = useState<WorkerNode[]>([])
const [computeNodeList, setComputeNodeList] = useState<WorkerNode[]>([])
const [metrics, setMetrics] = useState<ClusterNodeMetrics>()
const toast = useToast()
const toast = useErrorToast()

useEffect(() => {
async function doFetch() {
try {
setFrontendList(await getClusterInfoFrontend())
setComputeNodeList(await getClusterInfoComputeNode())
} catch (e: any) {
toast({
title: "Error Occurred",
description: e.toString(),
status: "error",
duration: 5000,
isClosable: true,
})
console.error(e)
toast(e)
}
}
doFetch()
Expand All @@ -177,14 +170,7 @@ export default function Cluster() {
setMetrics(metrics)
await new Promise((resolve) => setTimeout(resolve, 5000)) // refresh every 5 secs
} catch (e: any) {
toast({
title: "Error Occurred",
description: e.toString(),
status: "error",
duration: 5000,
isClosable: true,
})
console.error(e)
toast(e, "warning")
break
}
}
Expand Down
Loading

0 comments on commit 3579f74

Please sign in to comment.