Documentation ¶
Overview ¶
Package pubsubmon implements a PeerMonitor component for IPFS Cluster that uses PubSub to send and receive metrics.
Index ¶
- Constants
- Variables
- type Config
- type Monitor
- func (mon *Monitor) Alerts() <-chan api.Alert
- func (mon *Monitor) LatestForPeer(ctx context.Context, name string, pid peer.ID) api.Metric
- func (mon *Monitor) LatestMetrics(ctx context.Context, name string) []api.Metric
- func (mon *Monitor) LogMetric(ctx context.Context, m api.Metric) error
- func (mon *Monitor) MetricNames(ctx context.Context) []string
- func (mon *Monitor) PublishMetric(ctx context.Context, m api.Metric) error
- func (mon *Monitor) SetClient(c *rpc.Client)
- func (mon *Monitor) Shutdown(ctx context.Context) error
- type PeersFunc
Constants ¶
const (
DefaultCheckInterval = 15 * time.Second
)
Default values for this Config.
Variables ¶
var PubsubTopic = "monitor.metrics"
PubsubTopic specifies the topic used to publish Cluster metrics.
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config allows to initialize a Monitor and customize some parameters.
func (*Config) ApplyEnvVars ¶
ApplyEnvVars fills in any Config fields found as environment variables.
func (*Config) LoadJSON ¶
LoadJSON sets the fields of this Config to the values defined by the JSON representation of it, as generated by ToJSON.
func (*Config) ToDisplayJSON ¶
ToDisplayJSON returns JSON config as a string.
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor is a component in charge of monitoring peers, logging metrics and detecting failures
func New ¶
func New( ctx context.Context, cfg *Config, psub *pubsub.PubSub, peers PeersFunc, ) (*Monitor, error)
New creates a new PubSub monitor, using the given host, config and PeersFunc. The PeersFunc can be nil. In this case, no metric filtering is done based on peers (any peer is considered part of the peerset).
func (*Monitor) Alerts ¶
Alerts returns a channel on which alerts are sent when the monitor detects a failure.
func (*Monitor) LatestForPeer ¶
LatestForPeer returns the latest metric received for a peer (it may have expired). It returns nil if no metric exists.
func (*Monitor) LatestMetrics ¶
LatestMetrics returns last known VALID metrics of a given type. A metric is only valid if it has not expired and belongs to a current cluster peer.
func (*Monitor) MetricNames ¶
MetricNames lists all metric names.
func (*Monitor) PublishMetric ¶
PublishMetric broadcasts a metric to all current cluster peers.