-
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 #4 from samcm/metrics-jobs
chore(jobs): Break metrics up in to jobs
- Loading branch information
Showing
9 changed files
with
243 additions
and
203 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
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,84 @@ | ||
package jobs | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
) | ||
|
||
type SyncStatus struct { | ||
Percentage prometheus.Gauge | ||
EstimatedHighestSlot prometheus.Gauge | ||
HeadSlot prometheus.Gauge | ||
Distance prometheus.Gauge | ||
IsSyncing prometheus.Gauge | ||
} | ||
|
||
func NewSyncStatus(namespace string, constLabels map[string]string) SyncStatus { | ||
namespace = namespace + "_sync" | ||
return SyncStatus{ | ||
Percentage: prometheus.NewGauge( | ||
prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "percentage", | ||
Help: "How synced the node is with the network (0-100%).", | ||
ConstLabels: constLabels, | ||
}, | ||
), | ||
EstimatedHighestSlot: prometheus.NewGauge( | ||
prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "estimated_highest_slot", | ||
Help: "The estimated highest slot of the network.", | ||
ConstLabels: constLabels, | ||
}, | ||
), | ||
HeadSlot: prometheus.NewGauge( | ||
prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "head_slot", | ||
Help: "The current slot of the node.", | ||
ConstLabels: constLabels, | ||
}, | ||
), | ||
Distance: prometheus.NewGauge( | ||
prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "distance", | ||
Help: "The sync distance of the node.", | ||
ConstLabels: constLabels, | ||
}, | ||
), | ||
IsSyncing: prometheus.NewGauge( | ||
prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "is_syncing", | ||
Help: "1 if the node is in syncing state.", | ||
ConstLabels: constLabels, | ||
}, | ||
), | ||
} | ||
} | ||
|
||
func (s *SyncStatus) ObserveSyncPercentage(percent float64) { | ||
s.Percentage.Set(percent) | ||
} | ||
|
||
func (s *SyncStatus) ObserveSyncEstimatedHighestSlot(slot uint64) { | ||
s.EstimatedHighestSlot.Set(float64(slot)) | ||
} | ||
|
||
func (s *SyncStatus) ObserveSyncHeadSlot(slot uint64) { | ||
s.HeadSlot.Set(float64(slot)) | ||
} | ||
|
||
func (s *SyncStatus) ObserveSyncDistance(slots uint64) { | ||
s.Distance.Set(float64(slots)) | ||
} | ||
|
||
func (s *SyncStatus) ObserveSyncIsSyncing(syncing bool) { | ||
if syncing { | ||
s.IsSyncing.Set(1) | ||
return | ||
} | ||
|
||
s.IsSyncing.Set(0) | ||
} |
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
File renamed without changes.
Oops, something went wrong.