Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hostd metrics min zero, remove registry #423

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cool-beds-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'hostd': minor
---

Revenue metrics no longer show negative potential on the bar graph.
5 changes: 5 additions & 0 deletions .changeset/dull-birds-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'hostd': minor
---

Metrics no longer include registry related data.
5 changes: 5 additions & 0 deletions .changeset/swift-kiwis-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'hostd': minor
---

Earned revenue stat cards are now clearly labeled as earned.
20 changes: 0 additions & 20 deletions apps/hostd/components/Home/HomeOperations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,6 @@ export function HomeOperations() {
enabledModes={['total', 'average', 'latest']}
format={humanNumber}
/>
<DatumCardConfigurable
category="operations"
label="registry reads"
color={operations.config.data['registryReads'].color}
value={operations.stats['registryReads']}
defaultMode="total"
isLoading={operations.isLoading}
enabledModes={['total', 'average', 'latest']}
format={humanNumber}
/>
<DatumCardConfigurable
category="operations"
label="registry writes"
color={operations.config.data['registryWrites'].color}
value={operations.stats['registryWrites']}
defaultMode="total"
isLoading={operations.isLoading}
enabledModes={['total', 'average', 'latest']}
format={humanNumber}
/>
</DatumScrollArea>
<ChartXY
id="operations"
Expand Down
38 changes: 12 additions & 26 deletions apps/hostd/components/Home/HomeRevenue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Heading,
DatumCardConfigurable,
DatumScrollArea,
Separator,
} from '@siafoundation/design-system'
import { useMetrics } from '../../contexts/metrics'

Expand All @@ -16,61 +17,46 @@ export function HomeRevenue() {
<DatumScrollArea bleed>
<DatumCardConfigurable
category="revenue"
label="earned revenue"
color={revenue.config.data['earned'].color}
sc={revenue.stats['earned']}
label="potential - all"
color={revenue.config.data['potential'].color}
sc={revenue.stats['potential']}
defaultMode="total"
isLoading={revenue.isLoading}
showChange={false}
/>
<Separator variant="vertical" />
<DatumCardConfigurable
category="revenue"
label="potential revenue"
color={revenue.config.data['potential'].color}
sc={revenue.stats['potential']}
label="earned - all"
color={revenue.config.data['earned'].color}
sc={revenue.stats['earned']}
defaultMode="total"
isLoading={revenue.isLoading}
showChange={false}
/>
<DatumCardConfigurable
category="revenue"
label="storage"
label="earned - storage"
color={revenue.config.data['storage'].color}
sc={revenue.stats['storage']}
defaultMode="total"
isLoading={revenue.isLoading}
/>
<DatumCardConfigurable
category="revenue"
label="egress"
label="earned - egress"
color={revenue.config.data['egress'].color}
sc={revenue.stats['egress']}
defaultMode="total"
isLoading={revenue.isLoading}
/>
<DatumCardConfigurable
category="revenue"
label="ingress"
label="earned - ingress"
color={revenue.config.data['ingress'].color}
sc={revenue.stats['ingress']}
defaultMode="total"
isLoading={revenue.isLoading}
/>
<DatumCardConfigurable
category="revenue"
label="registry read"
color={revenue.config.data['registryRead'].color}
sc={revenue.stats['registryRead']}
defaultMode="total"
isLoading={revenue.isLoading}
/>
<DatumCardConfigurable
category="revenue"
label="registry write"
color={revenue.config.data['registryWrite'].color}
sc={revenue.stats['registryWrite']}
defaultMode="total"
isLoading={revenue.isLoading}
/>
</DatumScrollArea>
<ChartXY
id="revenue"
Expand Down
18 changes: 14 additions & 4 deletions apps/hostd/components/Home/HomeStorage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function HomeStorage() {
<DatumScrollArea>
<DatumCardConfigurable
category="storage"
label="storage (physical)"
label="storage - physical"
color={storage.config.data['physicalSectors'].color}
value={storage.stats['physicalSectors']}
defaultMode="latest"
Expand All @@ -26,9 +26,19 @@ export function HomeStorage() {
/>
<DatumCardConfigurable
category="storage"
label="registry"
color={storage.config.data['registryEntries'].color}
value={storage.stats['registryEntries']}
label="storage - contract"
color={storage.config.data['contractSectors'].color}
value={storage.stats['contractSectors']}
defaultMode="latest"
isLoading={storage.isLoading}
enabledModes={['latest', 'average']}
format={humanBytes}
/>
<DatumCardConfigurable
category="storage"
label="storage - temp"
color={storage.config.data['tempSectors'].color}
value={storage.stats['tempSectors']}
defaultMode="latest"
isLoading={storage.isLoading}
enabledModes={['latest', 'average']}
Expand Down
71 changes: 16 additions & 55 deletions apps/hostd/contexts/metrics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,42 +116,45 @@ function useMetricsMain() {
})

const revenue = useMemo<Chart<RevenueKeys, RevenueCategories>>(() => {
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: [
Expand All @@ -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',
],
Expand Down Expand Up @@ -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)
Expand All @@ -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: {
Expand All @@ -468,21 +453,11 @@ function useMetricsMain() {
'storage capacity',
'sectors'
),
maxRegistryEntries: configCategoryLabel<StorageCategories>(
chartConfigs.capacityRegistry,
'storage capacity',
'registry'
),
physicalSectors: configCategoryLabel<StorageCategories>(
chartConfigs.storagePhysical,
'storage used',
'sectors physical'
),
registryEntries: configCategoryLabel<StorageCategories>(
chartConfigs.registry,
'storage used',
'registry (max)'
),
tempSectors: configCategoryLabel<StorageCategories>(
chartConfigs.sectorsTemp,
'storage used',
Expand Down Expand Up @@ -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'
Expand All @@ -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,
},
Expand Down
14 changes: 1 addition & 13 deletions apps/hostd/contexts/metrics/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ import {
} from '@siafoundation/design-system'

export type RevenueKeys =
| 'potential'
| 'earned'
| 'rpcPotential'
| 'rpc'
| 'registryWritePotential'
| 'registryWrite'
| 'registryReadPotential'
| 'registryRead'
| 'egressPotential'
| 'egress'
| 'ingressPotential'
Expand Down Expand Up @@ -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'

Expand Down