Skip to content

Commit

Permalink
Show historical stats for node until we get realtime feed running
Browse files Browse the repository at this point in the history
  • Loading branch information
tumppi committed Feb 6, 2025
1 parent 660621c commit 8d7d17e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 13 additions & 3 deletions src/components/Stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ const defaultMetricEntry = {

export function NodeStats({ nodeId }: NodeStatsProps) {
const [metricKey, setMetricKey] = useState<NodeMetricKey>('broadcastMessagesPerSecond')

const [interval, setInterval] = useState<Interval>('realtime')

const reports = useSortedOperatorNodeMetricEntries({
Expand All @@ -447,8 +446,19 @@ export function NodeStats({ nodeId }: NodeStatsProps) {
[reports, metricKey],
)

const { broadcastMessagesPerSecond, broadcastBytesPerSecond, receiveBytesPerSecond } =
useRecentOperatorNodeMetricEntry(nodeId) || defaultMetricEntry
const recentMetrics = useRecentOperatorNodeMetricEntry(nodeId)

// Get last values from historical data if there is no realtime metrics
const lastMetrics = useMemo(() => {
if (recentMetrics) {
return recentMetrics
}

const lastReport = reports[reports.length - 1]
return lastReport || defaultMetricEntry
}, [recentMetrics, reports])

const { broadcastMessagesPerSecond, broadcastBytesPerSecond, receiveBytesPerSecond } = lastMetrics

return (
<>
Expand Down
2 changes: 0 additions & 2 deletions src/utils/streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ export function useSortedOperatorNodeMetricEntries(

const partition = useStreamPartitionFromNodeId(nodeId, stream)

console.log('partition', partition)

return useStreamMessagesOrderedByTime<NodeMetricReport>(
{
streamId,
Expand Down

0 comments on commit 8d7d17e

Please sign in to comment.