-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from samcm/feat/general-metrics
feat(network): Add General/Network level metrics
- Loading branch information
Showing
10 changed files
with
346 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package jobs | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
) | ||
|
||
type ForkMetrics struct { | ||
Forks prometheus.GaugeVec | ||
} | ||
|
||
func NewForkMetrics(namespace string, constLabels map[string]string) ForkMetrics { | ||
namespace = namespace + "_fork" | ||
return ForkMetrics{ | ||
Forks: *prometheus.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "epoch", | ||
Help: "The epoch for the fork.", | ||
ConstLabels: constLabels, | ||
}, | ||
[]string{ | ||
"fork", | ||
}, | ||
), | ||
} | ||
} | ||
|
||
func (f *ForkMetrics) ObserveFork(name string, epoch uint64) { | ||
f.Forks.WithLabelValues(name).Set(float64(epoch)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package jobs | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
) | ||
|
||
type GeneralMetrics struct { | ||
Slots prometheus.GaugeVec | ||
NodeVersion prometheus.GaugeVec | ||
NetworkdID prometheus.Gauge | ||
} | ||
|
||
func NewGeneralMetrics(namespace string, constLabels map[string]string) GeneralMetrics { | ||
return GeneralMetrics{ | ||
Slots: *prometheus.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "slot_number", | ||
Help: "The slot number of the beacon chain.", | ||
ConstLabels: constLabels, | ||
}, | ||
[]string{ | ||
"identifier", | ||
}, | ||
), | ||
NodeVersion: *prometheus.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "node_version", | ||
Help: "The version of the running beacon node.", | ||
ConstLabels: constLabels, | ||
}, | ||
[]string{ | ||
"version", | ||
}, | ||
), | ||
NetworkdID: prometheus.NewGauge( | ||
prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "network_id", | ||
Help: "The network id of the node.", | ||
ConstLabels: constLabels, | ||
}, | ||
), | ||
} | ||
} | ||
|
||
func (g *GeneralMetrics) ObserveSlot(identifier string, slot uint64) { | ||
g.Slots.WithLabelValues(identifier).Set(float64(slot)) | ||
} | ||
|
||
func (g *GeneralMetrics) ObserveNodeVersion(version string) { | ||
g.NodeVersion.WithLabelValues(version).Set(1) | ||
} | ||
|
||
func (g *GeneralMetrics) ObserveNetworkID(networkID uint64) { | ||
g.NetworkdID.Set(float64(networkID)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.