metrics

package
v0.1.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Contracts

type Contracts struct {
	Pending    uint64 `json:"pending"`
	Active     uint64 `json:"active"`
	Rejected   uint64 `json:"rejected"`
	Failed     uint64 `json:"failed"`
	Successful uint64 `json:"successful"`
}

Contracts is a collection of metrics related to contracts.

type Data

type Data struct {
	// Ingress returns the number of bytes received by the host.
	Ingress uint64 `json:"ingress"`
	// Egress returns the number of bytes sent by the host.
	Egress uint64 `json:"egress"`
}

Data is a collection of metrics related to data usage.

type DataMetrics

type DataMetrics struct {
	RHP2 Data `json:"rhp2"`
	RHP3 Data `json:"rhp3"`
}

DataMetrics is a collection of metrics related to data usage.

type Interval

type Interval uint8

Interval is the interval at which metrics should be aggregated.

const (
	Interval15Minutes Interval = iota
	IntervalHourly
	IntervalDaily
	IntervalWeekly
	IntervalMonthly
	IntervalYearly
)

intervals at which metrics should be aggregated.

func (Interval) String

func (i Interval) String() string

String returns the interval as a string

func (*Interval) UnmarshalText

func (i *Interval) UnmarshalText(buf []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type MetricManager

type MetricManager struct {
	// contains filtered or unexported fields
}

A MetricManager retrieves metrics from a store

func NewManager

func NewManager(store Store) *MetricManager

NewManager returns a new MetricManager

func (*MetricManager) Metrics

func (mm *MetricManager) Metrics(timestamp time.Time) (m Metrics, err error)

Metrics returns the current metrics for the host.

func (*MetricManager) PeriodMetrics

func (mm *MetricManager) PeriodMetrics(start time.Time, periods int, interval Interval) ([]Metrics, error)

PeriodMetrics returns metrics for n periods starting at start.

type Metrics

type Metrics struct {
	Revenue   RevenueMetrics `json:"revenue"`
	Pricing   Pricing        `json:"pricing"`
	Contracts Contracts      `json:"contracts"`
	Storage   Storage        `json:"storage"`
	Registry  Registry       `json:"registry"`
	Data      DataMetrics    `json:"data"`
	Balance   types.Currency `json:"balance"`
	Timestamp time.Time      `json:"timestamp"`
}

Metrics is a collection of metrics for the host.

type Pricing

type Pricing struct {
	ContractPrice     types.Currency `json:"contractPrice"`
	IngressPrice      types.Currency `json:"ingressPrice"`
	EgressPrice       types.Currency `json:"egressPrice"`
	BaseRPCPrice      types.Currency `json:"baseRPCPrice"`
	SectorAccessPrice types.Currency `json:"sectorAccessPrice"`
	StoragePrice      types.Currency `json:"storagePrice"`
	Collateral        types.Currency `json:"collateral"`
}

Pricing is a collection of metrics related to the host's pricing settings.

type Registry

type Registry struct {
	Entries    uint64 `json:"entries"`
	MaxEntries uint64 `json:"maxEntries"`

	Reads  uint64 `json:"reads"`
	Writes uint64 `json:"writes"`
}

Registry is a collection of metrics related to the host's registry.

type Revenue

type Revenue struct {
	RPC           types.Currency `json:"rpc"`
	Storage       types.Currency `json:"storage"`
	Ingress       types.Currency `json:"ingress"`
	Egress        types.Currency `json:"egress"`
	RegistryRead  types.Currency `json:"registryRead"`
	RegistryWrite types.Currency `json:"registryWrite"`
}

Revenue is a collection of metrics related to revenue.

type RevenueMetrics

type RevenueMetrics struct {
	Potential Revenue `json:"potential"`
	Earned    Revenue `json:"earned"`
}

RevenueMetrics is a collection of metrics related to revenue.

type Storage

type Storage struct {
	TotalSectors    uint64 `json:"totalSectors"`
	PhysicalSectors uint64 `json:"physicalSectors"`
	ContractSectors uint64 `json:"contractSectors"`
	TempSectors     uint64 `json:"tempSectors"`

	Reads  uint64 `json:"reads"`
	Writes uint64 `json:"writes"`
}

Storage is a collection of metrics related to storage.

type Store

type Store interface {
	// PeriodMetrics returns metrics for n periods starting at start.
	PeriodMetrics(start time.Time, n int, interval Interval) (period []Metrics, err error)
	// Metrics returns aggregated metrics for the host as of the timestamp.
	Metrics(time.Time) (m Metrics, err error)
}

A Store retrieves metrics

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL