metrics

package
v0.7.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

README

Metrics component

We use Prometheus monitoring system and time series database for collecting and store metrics.

Package metrics is based on Prometheus golang client. It contains metrics collectors of entire project. Component starts http server on http://0.0.0.0:8080/metrics by default(can be changed in configuration)

If you want to add metrics in your component code, you need to describe it as global collector variable in this package. Each global collector must be registered in constructor NewMetrics()

When you creating collector, you need to fill Opts structure. You should to read this guide before choosing Opts.Name

Collector types
Labels

Labels is used to create query with filters. For example, when we count total number of sent packets, then we can make query with filter by packet type in report. Generally, You don't need to use Opts.ConstLabels. This field is used for labels, which not be changed in runtime(e. g. for app version).

You should create a metricVec using specific method for particular collector type.

// NetworkPacketSentTotal is total number of sent packets metric
var NetworkPacketSentTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
	Name:      "packet_sent_total",
	Help:      "Total number of sent packets",
	Namespace: insolarNamespace,
	Subsystem: "network",
}, []string{"packetType"})
Using collectors in your code

Collectors are thread safe, you can manipulate with it from any goroutine.

// labeled counter usage example
metrics.NetworkPacketSentTotal.WithLabelValues(packet.Type.String()).Inc()

Documentation

Overview

Package metrics is a gateway for Prometheus monitoring system, it based on Prometheus golang client. Package contains metrics collectors descriptions of entire project. Component starts http server on http://0.0.0.0:8080/metrics by default(can be changed in configuration)

Example:

	// starts metrics server
	cfg := configuration.NewMetrics()
	m, _ := NewMetrics(cfg)
    m.Start(nil)

    // manipulate with network metrics
	NetworkMessageSentTotal.Inc()
	NetworkPacketSentTotal.WithLabelValues("ping").Add(55)

Index

Constants

This section is empty.

Variables

View Source
var ErrBind = errors.New("Failed to bind")

ErrBind special case for Start method. We can use it for easier check in metrics creation code.

View Source
var GopluginContractExecutionTime = prometheus.NewSummaryVec(prometheus.SummaryOpts{
	Name:       "contract_execution_time",
	Help:       "Time spent on execution contract, measured in goplugin",
	Namespace:  insolarNamespace,
	Subsystem:  "goplugin",
	Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.95: 0.005, 0.99: 0.001},
}, []string{"method"})
View Source
var InsgorundCallsTotal = prometheus.NewCounter(prometheus.CounterOpts{
	Name:      "call_contract_method_total",
	Help:      "Total number of calls contracts methods",
	Namespace: insgorundNamespace,
})
View Source
var InsgorundContractExecutionTime = prometheus.NewSummaryVec(prometheus.SummaryOpts{
	Name:       "contract_execution_time",
	Help:       "Time spent on execution contract",
	Namespace:  insgorundNamespace,
	Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.95: 0.005, 0.99: 0.001},
}, []string{"method"})
View Source
var LocallyDeliveredParcelsTotal = prometheus.NewCounterVec(
	prometheus.CounterOpts{
		Namespace: insolarNamespace,
		Subsystem: "messagebus",
		Name:      "locally_delivered_parcels_total",
		Help:      "Total number of parcels delivered to the same machine",
	},
	[]string{"messageType"},
)
View Source
var NetworkConnections = prometheus.NewGauge(prometheus.GaugeOpts{
	Name:      "connections",
	Help:      "Current network transport connections count",
	Namespace: insolarNamespace,
	Subsystem: "network",
})

NetworkConnections is current network transport connections count metric

View Source
var NetworkFutures = prometheus.NewGaugeVec(prometheus.GaugeOpts{
	Name:      "futures",
	Help:      "Current network transport futures count",
	Namespace: insolarNamespace,
	Subsystem: "network",
}, []string{"packetType"})

NetworkFutures is current network transport futures count metric

View Source
var NetworkPacketReceivedTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
	Name:      "packet_received_total",
	Help:      "Total number of received packets",
	Namespace: insolarNamespace,
	Subsystem: "network",
}, []string{"packetType"})

NetworkPacketReceivedTotal is is total number of received packets metric

View Source
var NetworkPacketSentTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
	Name:      "packet_sent_total",
	Help:      "Total number of sent packets",
	Namespace: insolarNamespace,
	Subsystem: "network",
}, []string{"packetType"})

NetworkPacketSentTotal is total number of sent packets metric

View Source
var NetworkParcelReceivedTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
	Name:      "parcel_received_total",
	Help:      "Total number of received parcels",
	Namespace: insolarNamespace,
	Subsystem: "network",
}, []string{"messageType"})

NetworkParcelReceivedTotal is total number of received messages metric

View Source
var NetworkParcelSentTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
	Name:      "parcel_sent_total",
	Help:      "Total number of sent parcels",
	Namespace: insolarNamespace,
	Subsystem: "network",
}, []string{"messageType"})

NetworkParcelSentTotal is total number of sent messages metric

View Source
var ParcelsReplySizeBytes = prometheus.NewSummaryVec(
	prometheus.SummaryOpts{
		Namespace:  insolarNamespace,
		Subsystem:  "messagebus",
		Name:       "parcels_reply_size_bytes",
		Help:       "Size of replies to parcels",
		Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.95: 0.005, 0.99: 0.001},
	},
	[]string{"messageType"},
)
View Source
var ParcelsSentSizeBytes = prometheus.NewSummaryVec(
	prometheus.SummaryOpts{
		Namespace:  insolarNamespace,
		Subsystem:  "messagebus",
		Name:       "parcels_sent_size_bytes",
		Help:       "Size of sent parcels",
		Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.95: 0.005, 0.99: 0.001},
	},
	[]string{"messageType"},
)
View Source
var ParcelsSentTotal = prometheus.NewCounterVec(
	prometheus.CounterOpts{
		Namespace: insolarNamespace,
		Subsystem: "messagebus",
		Name:      "parcels_sent_total",
		Help:      "Total number of parcels sent",
	},
	[]string{"messageType"},
)
View Source
var ParcelsTime = prometheus.NewSummaryVec(
	prometheus.SummaryOpts{
		Namespace:  insolarNamespace,
		Subsystem:  "messagebus",
		Name:       "parcels_time",
		Help:       "Time spent on sending parcels",
		Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.95: 0.005, 0.99: 0.001},
	},
	[]string{"messageType"},
)

Functions

func GetInsgorundRegistry added in v0.7.5

func GetInsgorundRegistry() *prometheus.Registry

func GetInsolarRegistry added in v0.7.5

func GetInsolarRegistry() *prometheus.Registry

GetInsolarRegistry creates and registers Insolar global metrics

func IsAddrInUse added in v0.6.3

func IsAddrInUse(err error) bool

IsAddrInUse checks error text for well known phrase.

func IsServerClosed added in v0.6.3

func IsServerClosed(err error) bool

IsServerClosed checks error text for well known phrase.

Types

type Metrics

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

Metrics is a component which serve metrics data to Prometheus.

func NewMetrics

func NewMetrics(ctx context.Context, cfg configuration.Metrics, registry *prometheus.Registry) (*Metrics, error)

NewMetrics creates new Metrics component.

func (*Metrics) AddrString added in v0.6.3

func (m *Metrics) AddrString() string

AddrString returns listener address.

func (*Metrics) Start

func (m *Metrics) Start(ctx context.Context) error

Start is implementation of core.Component interface.

func (*Metrics) Stop

func (m *Metrics) Stop(ctx context.Context) error

Stop is implementation of core.Component interface.

Jump to

Keyboard shortcuts

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