Skip to content

Commit 61c227e

Browse files
committed
fix: hostd metrics
1 parent cf99504 commit 61c227e

File tree

11 files changed

+101
-36
lines changed

11 files changed

+101
-36
lines changed

.changeset/shiny-onions-unite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'hostd': minor
3+
---
4+
5+
The contracts metrics now show active, rejected, failed, renewed, finalized, and successful.

.changeset/spicy-boats-sneeze.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@siafoundation/hostd-types': minor
3+
'@siafoundation/hostd-js': minor
4+
'@siafoundation/hostd-react': minor
5+
---
6+
7+
The metrics API types now include all available fields.

.changeset/sweet-meals-flash.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@siafoundation/hostd-types': minor
3+
'@siafoundation/hostd-js': minor
4+
'@siafoundation/hostd-react': minor
5+
---
6+
7+
The metrics APIs now include wallet with balance and immatureBalance. Closes https://github.com/SiaFoundation/hostd/issues/450

apps/hostd/components/Home/HomeContracts.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ export function HomeContracts() {
3434
isLoading={contracts.isLoading}
3535
enabledModes={['latest', 'average']}
3636
/>
37+
<DatumCardConfigurable
38+
category="contracts"
39+
label="Renewed contracts"
40+
color={contracts.config.data['renewed'].color}
41+
value={contracts.stats['renewed']}
42+
valueFormat={(v) => v.toFixed(0)}
43+
defaultMode="latest"
44+
isLoading={contracts.isLoading}
45+
enabledModes={['latest', 'average']}
46+
/>
3747
<DatumCardConfigurable
3848
category="contracts"
3949
label="Failed contracts"

apps/hostd/config/charts.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,26 @@ import { colors } from '@siafoundation/design-system'
22

33
export const chartConfigs = {
44
// states
5-
successful: {
6-
color: colors.green[600],
7-
},
85
active: {
96
color: colors.amber[600],
107
// pattern: true,
118
},
12-
pending: {
13-
color: colors.amber[600],
14-
pattern: true,
15-
},
169
rejected: {
1710
color: colors.red[600],
1811
// pattern: true,
1912
},
2013
failed: {
2114
color: colors.red[600],
2215
},
16+
renewed: {
17+
color: colors.blue[600],
18+
},
19+
finalized: {
20+
color: colors.yellow[600],
21+
},
22+
successful: {
23+
color: colors.green[600],
24+
},
2325
// potential: {
2426
// color: colors.amber[600],
2527
// pattern: true,

apps/hostd/contexts/metrics/index.tsx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,10 @@ function useMetricsMain() {
381381
metricsPeriod.data
382382
?.map((m) => ({
383383
active: m.contracts.active,
384-
failed: m.contracts.failed,
385-
pending: m.contracts.pending,
386384
rejected: m.contracts.rejected,
385+
failed: m.contracts.failed,
386+
renewed: m.contracts.renewed,
387+
finalized: m.contracts.finalized,
387388
successful: m.contracts.successful,
388389
timestamp: new Date(m.timestamp).getTime(),
389390
}))
@@ -395,13 +396,28 @@ function useMetricsMain() {
395396
data,
396397
stats,
397398
config: {
398-
enabledGraph: ['successful', 'active', 'pending', 'rejected', 'failed'],
399-
enabledTip: ['successful', 'active', 'pending', 'rejected', 'failed'],
399+
enabledGraph: [
400+
'active',
401+
'rejected',
402+
'failed',
403+
'renewed',
404+
'finalized',
405+
'successful',
406+
],
407+
enabledTip: [
408+
'active',
409+
'rejected',
410+
'failed',
411+
'renewed',
412+
'finalized',
413+
'successful',
414+
],
400415
data: {
401416
active: chartConfigs.active,
402-
failed: chartConfigs.failed,
403-
pending: chartConfigs.pending,
404417
rejected: chartConfigs.rejected,
418+
failed: chartConfigs.failed,
419+
renewed: chartConfigs.renewed,
420+
finalized: chartConfigs.finalized,
405421
successful: chartConfigs.successful,
406422
},
407423
format: (v) => `${v} contracts`,

apps/hostd/contexts/metrics/types.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ export type PricingKeys =
3030
| 'storage'
3131

3232
export type ContractsKeys =
33-
| 'failed'
34-
| 'rejected'
35-
| 'pending'
3633
| 'active'
34+
| 'rejected'
35+
| 'failed'
36+
| 'renewed'
37+
| 'finalized'
3738
| 'successful'
3839

3940
export type StorageKeys =

apps/hostd/contexts/transactions/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ function useTransactionsMain() {
160160
(metrics.data || [])
161161
.map((t) => {
162162
return {
163-
sc: Number(t.balance),
163+
sc: Number(t.wallet.balance),
164164
timestamp: new Date(t.timestamp).getTime(),
165165
}
166166
})

internal/cluster/bin/clusterd

30 MB
Binary file not shown.

libs/hostd-types/src/api.ts

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -231,27 +231,25 @@ type Revenue = {
231231
registryWrite: string
232232
}
233233

234-
// Data is a collection of metrics related to data usage.
235-
type Data = {
234+
type DataRHPMetrics = {
236235
// Ingress returns the number of bytes received by the host.
237236
ingress: number
238237
// Egress returns the number of bytes sent by the host.
239238
egress: number
240239
}
241240

242-
// Contracts is a collection of metrics related to contracts.
243-
type Contracts = {
244-
pending: number
241+
type ContractMetrics = {
245242
active: number
246243
rejected: number
247244
failed: number
245+
renewed: number
246+
finalized: number
248247
successful: number
249248
lockedCollateral: string
250249
riskedCollateral: string
251250
}
252251

253-
// Pricing is a collection of metrics related to the host's pricing settings.
254-
type Pricing = {
252+
type PricingMetrics = {
255253
contractPrice: string
256254
ingressPrice: string
257255
egressPrice: string
@@ -261,44 +259,54 @@ type Pricing = {
261259
collateralMultiplier: number
262260
}
263261

264-
// Registry is a collection of metrics related to the host's registry.
265-
type Registry = {
262+
type RegistryMetrics = {
266263
entries: number
267264
maxEntries: number
268265

269266
reads: number
270267
writes: number
271268
}
272269

273-
// Storage is a collection of metrics related to storage.
274-
type Storage = {
270+
type StorageMetrics = {
275271
totalSectors: number
276272
physicalSectors: number
273+
lostSectors: number
277274
contractSectors: number
278275
tempSectors: number
279276
reads: number
280277
writes: number
278+
sectorCacheHits: number
279+
sectorCacheMisses: number
281280
}
282281

283-
// RevenueMetrics is a collection of metrics related to revenue.
284282
type RevenueMetrics = {
285283
potential: Revenue
286284
earned: Revenue
287285
}
288286

289-
// DataMetrics is a collection of metrics related to data usage.
290287
type DataMetrics = {
291-
rhp: Data
288+
rhp: DataRHPMetrics
289+
}
290+
291+
type AccountMetrics = {
292+
active: number
293+
balance: string
294+
}
295+
296+
type WalletMetrics = {
297+
balance: string
298+
immatureBalance: string
292299
}
293300

294301
export type Metrics = {
302+
accounts: AccountMetrics
295303
revenue: RevenueMetrics
296-
pricing: Pricing
297-
contracts: Contracts
298-
storage: Storage
299-
registry: Registry
304+
pricing: PricingMetrics
305+
contracts: ContractMetrics
306+
storage: StorageMetrics
307+
registry: RegistryMetrics
300308
data: DataMetrics
301-
balance: string
309+
wallet: WalletMetrics
302310
timestamp: string
303311
}
304312

libs/renterd-types/src/bus.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,15 @@ export type WalletSignPayload = {
189189
}
190190
export type WalletSignResponse = Transaction
191191

192+
export type WalletSendParams = void
193+
export type WalletSendPayload = {
194+
address: string
195+
amount: Currency
196+
subtractMinerFee: boolean
197+
useUnconfirmed: boolean
198+
}
199+
export type WalletSendResponse = Transaction
200+
192201
export type WalletRedistributeParams = void
193202
export type WalletRedistributePayload = {
194203
amount: Currency

0 commit comments

Comments
 (0)