metrics

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: May 19, 2020 License: Apache-2.0, MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeartbeatProtocol = "fil/heartbeat/1.0.0"
)

HeartbeatProtocol is the libp2p protocol used for the heartbeat service

Variables

This section is empty.

Functions

func RegisterJaeger

func RegisterJaeger(name string, cfg *config.TraceConfig) error

RegisterJaeger registers the jaeger endpoint with opencensus and names the tracer `name`.

func RegisterPrometheusEndpoint

func RegisterPrometheusEndpoint(cfg *config.MetricsConfig) error

RegisterPrometheusEndpoint registers and serves prometheus metrics

Types

type Float64Timer

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

Float64Timer contains a opencensus measurement and view

func NewTimerMs

func NewTimerMs(name, desc string, tagKeys ...tag.Key) *Float64Timer

NewTimerMs creates a Float64Timer with units of milliseconds and a default set of aggregation bounds for latencies up to a few seconds.

func NewTimerWithBuckets

func NewTimerWithBuckets(name, desc, unit string, bounds []float64, tagKeys ...tag.Key) *Float64Timer

NewTimerWithBuckets creates a Float64Timer wrapping an opencensus float64 measurement.

func (*Float64Timer) Start

func (t *Float64Timer) Start(ctx context.Context) *Stopwatch

Start starts a timer and returns a Stopwatch.

type Heartbeat

type Heartbeat struct {
	// Head represents the heaviest tipset the nodes is mining on
	Head string
	// Height represents the current height of the Tipset
	Height abi.ChainEpoch
	// Nickname is the nickname given to the filecoin node by the user
	Nickname string

	// Address of this node's active miner. Can be empty - will return the zero address
	MinerAddress address.Address

	// CID of this chain's genesis block.
	GenesisCID cid.Cid
}

Heartbeat contains the information required to determine the current state of a node. Heartbeats are used for aggregating information about nodes in a log aggregator to support alerting and devnet visualization.

type HeartbeatService

type HeartbeatService struct {
	Host       host.Host
	GenesisCID cid.Cid
	Config     *config.HeartbeatConfig

	// A function that returns the heaviest tipset
	HeadGetter func() (block.TipSet, error)

	// A function that returns the miner's address
	MinerAddressGetter func() address.Address
	// contains filtered or unexported fields
}

HeartbeatService is responsible for sending heartbeats.

func NewHeartbeatService

func NewHeartbeatService(h host.Host, genesisCID cid.Cid, hbc *config.HeartbeatConfig, hg func() (block.TipSet, error), options ...HeartbeatServiceOption) *HeartbeatService

NewHeartbeatService returns a HeartbeatService

func (*HeartbeatService) Beat

func (hbs *HeartbeatService) Beat(ctx context.Context) Heartbeat

Beat will create a heartbeat.

func (*HeartbeatService) Connect

func (hbs *HeartbeatService) Connect(ctx context.Context) error

Connect will connects to `hbs.Config.BeatTarget` or returns an error

func (*HeartbeatService) Run

func (hbs *HeartbeatService) Run(ctx context.Context) error

Run is called once the heartbeat service connects to the aggregator. Run send the actual heartbeat. Run will block until `ctx` is 'Done`. An error will be returned if Run encounters an error when sending the heartbeat and the connection to the aggregator will be closed.

func (*HeartbeatService) SetStream

func (hbs *HeartbeatService) SetStream(s net.Stream)

SetStream sets the stream on the HeartbeatService. Safe for concurrent access.

func (*HeartbeatService) Start

func (hbs *HeartbeatService) Start(ctx context.Context)

Start starts the heartbeat service by, starting the connection loop. The connection loop will attempt to connected to the aggregator service, once a successful connection is made with the aggregator service hearbeats will be sent to it. If the connection is broken the heartbeat service will attempt to reconnect via the connection loop. Start will not return until context `ctx` is 'Done'.

func (*HeartbeatService) Stream

func (hbs *HeartbeatService) Stream() net.Stream

Stream returns the HeartbeatService stream. Safe for concurrent access. Stream is a libp2p connection that heartbeat messages are sent over to an aggregator.

type HeartbeatServiceOption

type HeartbeatServiceOption func(service *HeartbeatService)

HeartbeatServiceOption is the type of the heartbeat service's functional options.

func WithMinerAddressGetter

func WithMinerAddressGetter(ag func() address.Address) HeartbeatServiceOption

WithMinerAddressGetter returns an option that can be used to set the miner address getter.

type Int64Counter

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

Int64Counter wraps an opencensus int64 measure that is uses as a counter.

func NewInt64Counter

func NewInt64Counter(name, desc string) *Int64Counter

NewInt64Counter creates a new Int64Counter with demensionless units.

func (*Int64Counter) Inc

func (c *Int64Counter) Inc(ctx context.Context, v int64)

Inc increments the counter by value `v`.

type Int64Gauge

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

Int64Gauge wraps an opencensus int64 measure that is uses as a gauge.

func NewInt64Gauge

func NewInt64Gauge(name, desc string, keys ...tag.Key) *Int64Gauge

NewInt64Gauge creates a new Int64Gauge with demensionless units.

func (*Int64Gauge) Set

func (c *Int64Gauge) Set(ctx context.Context, v int64)

Set sets the value of the gauge to value `v`.

type JSONFormatter

type JSONFormatter struct {
}

JSONFormatter implements go-logging Formatter for JSON encoded logs

func (*JSONFormatter) Format

func (jf *JSONFormatter) Format(calldepth int, r *oldlogging.Record, w io.Writer) error

Format implements go-logging Formatter

type Stopwatch

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

Stopwatch contains a start time and a recorder, when stopped it record the duration since start time began via its recorder function.

func (*Stopwatch) Stop

func (sw *Stopwatch) Stop(ctx context.Context) time.Duration

Stop rounds the time since Start was called to milliseconds and records the value in the corresponding opencensus view.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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