From fbf833a7a3197bca2e35c21673ae1f122891fe99 Mon Sep 17 00:00:00 2001 From: Alex Freska Date: Tue, 28 Nov 2023 14:14:03 -0500 Subject: [PATCH] fix: hostd metrics min zero, remove registry --- .changeset/cool-beds-hunt.md | 5 ++ .changeset/dull-birds-push.md | 5 ++ .changeset/swift-kiwis-clean.md | 5 ++ apps/hostd/components/Home/HomeOperations.tsx | 20 ------ apps/hostd/components/Home/HomeRevenue.tsx | 38 ++++------ apps/hostd/components/Home/HomeStorage.tsx | 18 +++-- apps/hostd/contexts/metrics/index.tsx | 71 +++++-------------- apps/hostd/contexts/metrics/types.tsx | 14 +--- 8 files changed, 58 insertions(+), 118 deletions(-) create mode 100644 .changeset/cool-beds-hunt.md create mode 100644 .changeset/dull-birds-push.md create mode 100644 .changeset/swift-kiwis-clean.md diff --git a/.changeset/cool-beds-hunt.md b/.changeset/cool-beds-hunt.md new file mode 100644 index 000000000..93afb4d1b --- /dev/null +++ b/.changeset/cool-beds-hunt.md @@ -0,0 +1,5 @@ +--- +'hostd': minor +--- + +Revenue metrics no longer show negative potential on the bar graph. diff --git a/.changeset/dull-birds-push.md b/.changeset/dull-birds-push.md new file mode 100644 index 000000000..55210b6f7 --- /dev/null +++ b/.changeset/dull-birds-push.md @@ -0,0 +1,5 @@ +--- +'hostd': minor +--- + +Metrics no longer include registry related data. diff --git a/.changeset/swift-kiwis-clean.md b/.changeset/swift-kiwis-clean.md new file mode 100644 index 000000000..e44fad18a --- /dev/null +++ b/.changeset/swift-kiwis-clean.md @@ -0,0 +1,5 @@ +--- +'hostd': minor +--- + +Earned revenue stat cards are now clearly labeled as earned. diff --git a/apps/hostd/components/Home/HomeOperations.tsx b/apps/hostd/components/Home/HomeOperations.tsx index 604cf3965..f15e566e2 100644 --- a/apps/hostd/components/Home/HomeOperations.tsx +++ b/apps/hostd/components/Home/HomeOperations.tsx @@ -35,26 +35,6 @@ export function HomeOperations() { enabledModes={['total', 'average', 'latest']} format={humanNumber} /> - - + - - + >(() => { - const data = formatChartData( + const dataWithNegatives = formatChartData( metricsPeriod.data?.map((m) => ({ storagePotential: Number(m.revenue.potential.storage), ingressPotential: Number(m.revenue.potential.ingress), egressPotential: Number(m.revenue.potential.egress), - registryReadPotential: Number(m.revenue.potential.registryRead), - registryWritePotential: Number(m.revenue.potential.registryWrite), rpcPotential: Number(m.revenue.potential.rpc), storage: Number(m.revenue.earned.storage), ingress: Number(m.revenue.earned.ingress), egress: Number(m.revenue.earned.egress), - registryRead: Number(m.revenue.earned.registryRead), - registryWrite: Number(m.revenue.earned.registryWrite), rpc: Number(m.revenue.earned.rpc), // not enabled on graph, but used for stats potential: new BigNumber(m.revenue.potential.storage) .plus(m.revenue.potential.ingress) .plus(m.revenue.potential.egress) - .plus(m.revenue.potential.registryRead) - .plus(m.revenue.potential.registryWrite) .plus(m.revenue.potential.rpc) .toNumber(), earned: new BigNumber(m.revenue.earned.storage) .plus(m.revenue.earned.ingress) .plus(m.revenue.earned.egress) - .plus(m.revenue.earned.registryRead) - .plus(m.revenue.earned.registryWrite) .plus(m.revenue.earned.rpc) .toNumber(), timestamp: new Date(m.timestamp).getTime(), })), 'delta' ) - const stats = computeChartStats(data) + const stats = computeChartStats(dataWithNegatives) + const dataWithoutNegatives = dataWithNegatives.map((m) => ({ + storagePotential: Math.max(m.storagePotential, 0), + ingressPotential: Math.max(m.ingressPotential, 0), + egressPotential: Math.max(m.egressPotential, 0), + rpcPotential: Math.max(m.rpcPotential, 0), + storage: Math.max(m.storage, 0), + ingress: Math.max(m.ingress, 0), + egress: Math.max(m.egress, 0), + rpc: Math.max(m.rpc, 0), + timestamp: new Date(m.timestamp).getTime(), + })) return { - data, + data: dataWithoutNegatives, stats, config: { enabledGraph: [ @@ -161,28 +164,16 @@ function useMetricsMain() { 'ingressPotential', 'egress', 'egressPotential', - 'registryRead', - 'registryReadPotential', - 'registryWrite', - 'registryWritePotential', 'rpc', 'rpcPotential', ], enabledTip: [ - // include the totals in the tip - 'potential', - 'earned', - 'storage', 'storagePotential', 'ingress', 'ingressPotential', 'egress', 'egressPotential', - 'registryRead', - 'registryReadPotential', - 'registryWrite', - 'registryWritePotential', 'rpc', 'rpcPotential', ], @@ -426,8 +417,6 @@ function useMetricsMain() { metricsPeriod.data ?.map((m) => ({ maxSectors: MiBToBytes(m.storage.totalSectors).times(4).toNumber(), - registryEntries: m.registry.entries * 113, - maxRegistryEntries: m.registry.maxEntries * 113, tempSectors: MiBToBytes(m.storage.tempSectors).times(4).toNumber(), physicalSectors: MiBToBytes(m.storage.physicalSectors) .times(4) @@ -449,17 +438,13 @@ function useMetricsMain() { 'contractSectors', 'physicalSectors', 'tempSectors', - 'registryEntries', 'maxSectors', - 'maxRegistryEntries', ], enabledTip: [ 'contractSectors', 'physicalSectors', 'tempSectors', - 'registryEntries', 'maxSectors', - 'maxRegistryEntries', ], categories: ['storage used', 'storage capacity'], data: { @@ -468,21 +453,11 @@ function useMetricsMain() { 'storage capacity', 'sectors' ), - maxRegistryEntries: configCategoryLabel( - chartConfigs.capacityRegistry, - 'storage capacity', - 'registry' - ), physicalSectors: configCategoryLabel( chartConfigs.storagePhysical, 'storage used', 'sectors physical' ), - registryEntries: configCategoryLabel( - chartConfigs.registry, - 'storage used', - 'registry (max)' - ), tempSectors: configCategoryLabel( chartConfigs.sectorsTemp, 'storage used', @@ -511,8 +486,6 @@ function useMetricsMain() { metricsPeriod.data?.map((m) => ({ storageReads: m.storage.reads, storageWrites: m.storage.writes, - registryReads: m.registry.reads, - registryWrites: m.registry.writes, timestamp: new Date(m.timestamp).getTime(), })), 'delta' @@ -522,21 +495,9 @@ function useMetricsMain() { data, stats, config: { - enabledGraph: [ - 'storageReads', - 'storageWrites', - 'registryReads', - 'registryWrites', - ], - enabledTip: [ - 'storageReads', - 'storageWrites', - 'registryReads', - 'registryWrites', - ], + enabledGraph: ['storageReads', 'storageWrites'], + enabledTip: ['storageReads', 'storageWrites'], data: { - registryReads: chartConfigs.registryReads, - registryWrites: chartConfigs.registryWrites, storageReads: chartConfigs.storageReads, storageWrites: chartConfigs.storageWrites, }, diff --git a/apps/hostd/contexts/metrics/types.tsx b/apps/hostd/contexts/metrics/types.tsx index 2f9705d64..076d907a6 100644 --- a/apps/hostd/contexts/metrics/types.tsx +++ b/apps/hostd/contexts/metrics/types.tsx @@ -5,14 +5,8 @@ import { } from '@siafoundation/design-system' export type RevenueKeys = - | 'potential' - | 'earned' | 'rpcPotential' | 'rpc' - | 'registryWritePotential' - | 'registryWrite' - | 'registryReadPotential' - | 'registryRead' | 'egressPotential' | 'egress' | 'ingressPotential' @@ -47,18 +41,12 @@ export type StorageKeys = | 'physicalSectors' | 'tempSectors' | 'contractSectors' - | 'registryEntries' - | 'maxRegistryEntries' export type StorageCategories = 'storage used' | 'storage capacity' export type BandwidthKeys = 'ingress' | 'egress' -export type OperationsKeys = - | 'storageReads' - | 'storageWrites' - | 'registryReads' - | 'registryWrites' +export type OperationsKeys = 'storageReads' | 'storageWrites' export type BandwidthCategories = 'ingress' | 'egress'