metrics

package
v0.33.3 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AvailabilityLabel = "availability"
	SyncLabel         = "sync/freshness"
	LatencyLabel      = "latency"
)
View Source
const (
	MetricsListenFlagName = "metrics-listen-address"
	RelayServerFlagName   = "relay-server-address"
	DisabledFlagOption    = "disabled"
)
View Source
const (
	RefererHeaderKey   = "Referer"
	OriginHeaderKey    = "Origin"
	UserAgentHeaderKey = "User-Agent"
)

Variables

View Source
var ReturnMaskedErrors = "false"

Functions

func SetVersionInner

func SetVersionInner(protocolVersionMetric *prometheus.GaugeVec, version string)

Types

type AggregatedMetric

type AggregatedMetric struct {
	TotalLatency uint64
	RelaysCount  int64
	SuccessCount int64
	TotalCu      uint64
	TimeStamp    time.Time
}

type ConsumerMetricsManager

type ConsumerMetricsManager struct {
	LatestBlockMetric   *prometheus.GaugeVec
	LatestProviderRelay *prometheus.GaugeVec
	// contains filtered or unexported fields
}

func NewConsumerMetricsManager

func NewConsumerMetricsManager(networkAddress string) *ConsumerMetricsManager

func (*ConsumerMetricsManager) ResetQOSMetrics

func (pme *ConsumerMetricsManager) ResetQOSMetrics()

func (*ConsumerMetricsManager) SetBlock

func (pme *ConsumerMetricsManager) SetBlock(block int64)

func (*ConsumerMetricsManager) SetEndpointsHealthChecksOkStatus added in v0.33.3

func (pme *ConsumerMetricsManager) SetEndpointsHealthChecksOkStatus(status bool)

func (*ConsumerMetricsManager) SetQOSMetrics

func (pme *ConsumerMetricsManager) SetQOSMetrics(chainId string, apiInterface string, providerAddress string, qos *pairingtypes.QualityOfServiceReport, qosExcellence *pairingtypes.QualityOfServiceReport, latestBlock int64, relays uint64)

func (*ConsumerMetricsManager) SetRelayMetrics

func (pme *ConsumerMetricsManager) SetRelayMetrics(relayMetric *RelayMetrics, err error)

func (*ConsumerMetricsManager) SetVersion

func (pme *ConsumerMetricsManager) SetVersion(version string)

func (*ConsumerMetricsManager) SetVirtualEpoch

func (pme *ConsumerMetricsManager) SetVirtualEpoch(virtualEpoch uint64)

type ConsumerRelayServerClient

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

func NewConsumerRelayServerClient

func NewConsumerRelayServerClient(endPointAddress string) *ConsumerRelayServerClient

func (*ConsumerRelayServerClient) SetRelayMetrics

func (cuc *ConsumerRelayServerClient) SetRelayMetrics(relayMetric *RelayMetrics)

type HealthMetrics

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

func NewHealthMetrics

func NewHealthMetrics(networkAddress string) *HealthMetrics

func (*HealthMetrics) SetAlertResults

func (pme *HealthMetrics) SetAlertResults(label string, fails uint64, unhealthy uint64, healthy uint64)

func (*HealthMetrics) SetFailedRun

func (pme *HealthMetrics) SetFailedRun(label string)

func (*HealthMetrics) SetLatestBlockData

func (pme *HealthMetrics) SetLatestBlockData(label string, data map[string]uint64)

func (*HealthMetrics) SetSuccess

func (pme *HealthMetrics) SetSuccess(label string)

type MetricService

type MetricService struct {
	AggregatedMetricMap *map[string]map[string]map[string]map[RelaySource]map[string]*AggregatedMetric
	MetricsChannel      chan RelayMetrics
	ReportUrl           string
	ReportAuthorization string
}

func NewMetricService

func NewMetricService() *MetricService

func (*MetricService) SendData

func (m *MetricService) SendData(data RelayMetrics)

func (*MetricService) SendEachProjectMetricData

func (m *MetricService) SendEachProjectMetricData()

type ProviderMetrics

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

func NewProviderMetrics

func NewProviderMetrics(specID, apiInterface string, totalCUServicedMetric *prometheus.CounterVec,
	totalCUPaidMetric *prometheus.CounterVec,
	totalRelaysServicedMetric *prometheus.CounterVec,
	totalErroredMetric *prometheus.CounterVec,
	consumerQoSMetric *prometheus.GaugeVec,
) *ProviderMetrics

func (*ProviderMetrics) AddError

func (pm *ProviderMetrics) AddError()

func (*ProviderMetrics) AddPayment

func (pm *ProviderMetrics) AddPayment(cu uint64)

func (*ProviderMetrics) AddRelay

func (pm *ProviderMetrics) AddRelay(consumerAddress string, cu uint64, qos *pairingtypes.QualityOfServiceReport)

type ProviderMetricsManager

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

func NewProviderMetricsManager

func NewProviderMetricsManager(networkAddress string) *ProviderMetricsManager

func (*ProviderMetricsManager) AddPayment

func (pme *ProviderMetricsManager) AddPayment(specID string, cu uint64)

func (*ProviderMetricsManager) AddProviderMetrics

func (pme *ProviderMetricsManager) AddProviderMetrics(specID, apiInterface string) *ProviderMetrics

func (*ProviderMetricsManager) SetBlock

func (pme *ProviderMetricsManager) SetBlock(latestLavaBlock int64)

func (*ProviderMetricsManager) SetDisabledChain

func (pme *ProviderMetricsManager) SetDisabledChain(specID string, apInterface string)

func (*ProviderMetricsManager) SetEnabledChain

func (pme *ProviderMetricsManager) SetEnabledChain(specID string, apInterface string)

func (*ProviderMetricsManager) SetLatestBlock

func (pme *ProviderMetricsManager) SetLatestBlock(specID string, block uint64)

func (*ProviderMetricsManager) SetLatestBlockFetchError

func (pme *ProviderMetricsManager) SetLatestBlockFetchError(specID string)

func (*ProviderMetricsManager) SetLatestBlockFetchSuccess

func (pme *ProviderMetricsManager) SetLatestBlockFetchSuccess(specID string)

func (*ProviderMetricsManager) SetSpecificBlockFetchError

func (pme *ProviderMetricsManager) SetSpecificBlockFetchError(specID string)

func (*ProviderMetricsManager) SetSpecificBlockFetchSuccess

func (pme *ProviderMetricsManager) SetSpecificBlockFetchSuccess(specID string)

func (*ProviderMetricsManager) SetVersion

func (pme *ProviderMetricsManager) SetVersion(version string)

func (*ProviderMetricsManager) SetVirtualEpoch

func (pme *ProviderMetricsManager) SetVirtualEpoch(virtualEpoch uint64)

type RPCConsumerLogs

type RPCConsumerLogs struct {
	MetricService   *MetricService
	StoreMetricData bool
	// contains filtered or unexported fields
}

func NewRPCConsumerLogs

func NewRPCConsumerLogs(consumerMetricsManager *ConsumerMetricsManager, consumerRelayServerClient *ConsumerRelayServerClient) (*RPCConsumerLogs, error)

func (*RPCConsumerLogs) AddMetricForGrpc

func (rpccl *RPCConsumerLogs) AddMetricForGrpc(data *RelayMetrics, err error, metadataValues *metadata.MD)

func (*RPCConsumerLogs) AddMetricForHttp

func (rpccl *RPCConsumerLogs) AddMetricForHttp(data *RelayMetrics, err error, headers map[string][]string)

func (*RPCConsumerLogs) AddMetricForWebSocket

func (rpccl *RPCConsumerLogs) AddMetricForWebSocket(data *RelayMetrics, err error, c *websocket.Conn)

func (*RPCConsumerLogs) AnalyzeWebSocketErrorAndWriteMessage

func (rpccl *RPCConsumerLogs) AnalyzeWebSocketErrorAndWriteMessage(c *websocket.Conn, mt int, err error, msgSeed string, msg []byte, rpcType string, timeTaken time.Duration)

Websocket healthy disconnections throw "websocket: close 1005 (no status)" error, We dont want to alert error monitoring for that purpses.

func (*RPCConsumerLogs) GetMessageSeed

func (rpccl *RPCConsumerLogs) GetMessageSeed() string

func (*RPCConsumerLogs) GetUniqueGuidResponseForError

func (rpccl *RPCConsumerLogs) GetUniqueGuidResponseForError(responseError error, msgSeed string) string

Input will be masked with a random GUID if returnMaskedErrors is set to true

func (*RPCConsumerLogs) LogRequestAndResponse

func (rpccl *RPCConsumerLogs) LogRequestAndResponse(module string, hasError bool, method, path, req, resp, msgSeed string, timeTaken time.Duration, err error)

func (*RPCConsumerLogs) LogStartTransaction

func (rpccl *RPCConsumerLogs) LogStartTransaction(name string) func()

func (*RPCConsumerLogs) LogTestMode

func (rpccl *RPCConsumerLogs) LogTestMode(fiberCtx *fiber.Ctx)

func (*RPCConsumerLogs) SendMetrics

func (rpccl *RPCConsumerLogs) SendMetrics(data *RelayMetrics, err error, origin string)

type RelayAnalyticsDTO

type RelayAnalyticsDTO struct {
	ProjectHash  string
	Timestamp    string
	ChainID      string
	APIType      string
	Latency      uint64
	SuccessCount int64
	RelayCounts  int64
	TotalCu      uint64
	Source       RelaySource
	Origin       string
}

type RelayMetrics

type RelayMetrics struct {
	ProjectHash  string
	Timestamp    time.Time
	ChainID      string
	APIType      string
	Latency      int64
	Success      bool
	ComputeUnits uint64
	Source       RelaySource
	Origin       string
}

func NewRelayAnalytics

func NewRelayAnalytics(projectHash, chainId, apiType string) *RelayMetrics

type RelaySource

type RelaySource int
const (
	SdkSource RelaySource = iota + 1
	GatewaySource
	BadgesSource
)

type RelaysMonitor

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

func NewRelaysMonitor

func NewRelaysMonitor(interval time.Duration, chainID, apiInterface string) *RelaysMonitor

func (*RelaysMonitor) IsHealthy

func (sem *RelaysMonitor) IsHealthy() bool

func (*RelaysMonitor) LogRelay

func (sem *RelaysMonitor) LogRelay()

func (*RelaysMonitor) SetRelaySender

func (sem *RelaysMonitor) SetRelaySender(relaySender func() (bool, error))

func (*RelaysMonitor) Start

func (sem *RelaysMonitor) Start(ctx context.Context)

type RelaysMonitorAggregator

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

func NewRelaysMonitorAggregator

func NewRelaysMonitorAggregator(interval time.Duration, rpcConsumerLogs *ConsumerMetricsManager) *RelaysMonitorAggregator

func (*RelaysMonitorAggregator) RegisterRelaysMonitor

func (rma *RelaysMonitorAggregator) RegisterRelaysMonitor(rpcEndpointKey string, relaysMonitor *RelaysMonitor)

func (*RelaysMonitorAggregator) StartMonitoring

func (rma *RelaysMonitorAggregator) StartMonitoring(ctx context.Context)

type UpdateMetricsRequest

type UpdateMetricsRequest struct {
	RecordDate      string `json:"RecordDate"`
	Hash            string `json:"Hash"`
	Chain           string `json:"Chain"`
	ApiType         string `json:"ApiType"`
	RelaysInc       uint64 `json:"RelaysInc"`
	CuInc           int    `json:"CuInc"`
	LatencyToAdd    uint64 `json:"LatencyToAdd"`
	LatencyAvgCount int    `json:"LatencyAvgCount"`
}

Jump to

Keyboard shortcuts

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