metrics

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

README

This package contains code related to the node's host metrics system.

The metrics package heavily uses geths own metric package.

  • golang Package here
  • Documentation here

Add metrics

Instrumentation can be added and used as the following example shows:


import gethmetrics "github.com/ethereum/go-ethereum/metrics"

type SomeStruct struct {
        ...
        someMeter gethmetrics.Meter
        someGauge gethmetrics.Gauge
}

// registry should be passed down from the parent package
func New(registry gethmetrics.Registry) *SomeStruct {
	return &SomeStruct {
            someMeter : gethmetrics.NewRegisteredMeter("some/metric/path", registry),
            someGauge : gethmetrics.NewRegisteredGauge("some/metric/path", registry), 
        }
}

func (s *SomeStruct) Do()  {
	//some other code
        s.someMeter.Update(Some_Value)
	s.someGauge.Inc(1)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service provides the metrics for the host it registers the gethmetrics Registry and handles the metrics server

func New

func New(enabled bool, port uint, logger gethlog.Logger) *Service

func (*Service) CollectProcessMetrics

func (m *Service) CollectProcessMetrics()

CollectProcessMetrics collect process and system metrics this method is an adapted copy of eth/metrics/metrics.go@CollectProcessMetrics method

func (*Service) Registry

func (m *Service) Registry() gethmetrics.Registry

Registry returns the registry for the metrics service

func (*Service) Start

func (m *Service) Start()

Start starts the metrics server

func (*Service) Stop

func (m *Service) Stop()

Jump to

Keyboard shortcuts

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