Skip to content

Commit

Permalink
fix: hostd metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Aug 26, 2024
1 parent cf99504 commit f08a206
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 20 deletions.
7 changes: 7 additions & 0 deletions .changeset/spicy-boats-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@siafoundation/hostd-types': minor
'@siafoundation/hostd-js': minor
'@siafoundation/hostd-react': minor
---

The metrics API types now include all available fields.
7 changes: 7 additions & 0 deletions .changeset/sweet-meals-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@siafoundation/hostd-types': minor
'@siafoundation/hostd-js': minor
'@siafoundation/hostd-react': minor
---

The metrics APIs now include wallet with balance and immatureBalance.
2 changes: 1 addition & 1 deletion apps/hostd/contexts/transactions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function useTransactionsMain() {
(metrics.data || [])
.map((t) => {
return {
sc: Number(t.balance),
sc: Number(t.wallet.balance),
timestamp: new Date(t.timestamp).getTime(),
}
})
Expand Down
Binary file added internal/cluster/bin/clusterd
Binary file not shown.
47 changes: 28 additions & 19 deletions libs/hostd-types/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,27 +231,26 @@ type Revenue = {
registryWrite: string
}

// Data is a collection of metrics related to data usage.
type Data = {
type DataRHPMetrics = {
// Ingress returns the number of bytes received by the host.
ingress: number
// Egress returns the number of bytes sent by the host.
egress: number
}

// Contracts is a collection of metrics related to contracts.
type Contracts = {
pending: number
type ContractMetrics = {
active: number
rejected: number
failed: number
renewed: number
finalized: number
successful: number
pending: number // TODO: remove?
lockedCollateral: string
riskedCollateral: string
}

// Pricing is a collection of metrics related to the host's pricing settings.
type Pricing = {
type PricingMetrics = {
contractPrice: string
ingressPrice: string
egressPrice: string
Expand All @@ -261,44 +260,54 @@ type Pricing = {
collateralMultiplier: number
}

// Registry is a collection of metrics related to the host's registry.
type Registry = {
type RegistryMetrics = {
entries: number
maxEntries: number

reads: number
writes: number
}

// Storage is a collection of metrics related to storage.
type Storage = {
type StorageMetrics = {
totalSectors: number
physicalSectors: number
lostSectors: number
contractSectors: number
tempSectors: number
reads: number
writes: number
sectorCacheHits: number
sectorCacheMisses: number
}

// RevenueMetrics is a collection of metrics related to revenue.
type RevenueMetrics = {
potential: Revenue
earned: Revenue
}

// DataMetrics is a collection of metrics related to data usage.
type DataMetrics = {
rhp: Data
rhp: DataRHPMetrics
}

type AccountMetrics = {
active: number
balance: string
}

type WalletMetrics = {
balance: string
immatureBalance: string
}

export type Metrics = {
accounts: AccountMetrics
revenue: RevenueMetrics
pricing: Pricing
contracts: Contracts
storage: Storage
registry: Registry
pricing: PricingMetrics
contracts: ContractMetrics
storage: StorageMetrics
registry: RegistryMetrics
data: DataMetrics
balance: string
wallet: WalletMetrics
timestamp: string
}

Expand Down

0 comments on commit f08a206

Please sign in to comment.