From b83310221e4cbcc8f3438e4abbe1288a8ce1c8a2 Mon Sep 17 00:00:00 2001 From: capossele <angelocapossele@gmail.com> Date: Fri, 12 Jun 2020 08:08:50 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/prometheus/info.go | 16 +--------------- plugins/prometheus/metrics.go | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/plugins/prometheus/info.go b/plugins/prometheus/info.go index 3f796c11..0fe3dd25 100644 --- a/plugins/prometheus/info.go +++ b/plugins/prometheus/info.go @@ -6,8 +6,7 @@ import ( ) var ( - infoApp *prometheus.GaugeVec - infoTips prometheus.Gauge + infoApp *prometheus.GaugeVec ) func init() { @@ -18,18 +17,5 @@ func init() { }, []string{"name", "version"}, ) - infoTips = prometheus.NewGauge(prometheus.GaugeOpts{ - Name: "iota_info_tips", - Help: "Number of tips.", - }) - infoApp.WithLabelValues(banner.AppName, banner.AppVersion).Set(1) - registry.MustRegister(infoApp) - registry.MustRegister(infoTips) - addCollect(collectInfo) -} - -func collectInfo() { - // Tips - infoTips.Set(0) } diff --git a/plugins/prometheus/metrics.go b/plugins/prometheus/metrics.go index 799379c4..7112f26e 100644 --- a/plugins/prometheus/metrics.go +++ b/plugins/prometheus/metrics.go @@ -1,12 +1,16 @@ package prometheus import ( + "github.com/iotaledger/goshimmer/dapps/valuetransfers" + "github.com/iotaledger/goshimmer/plugins/messagelayer" "github.com/iotaledger/goshimmer/plugins/metrics" "github.com/prometheus/client_golang/prometheus" ) var ( messagesPerSecond prometheus.Gauge + infoMessageTips prometheus.Gauge + infoValueTips prometheus.Gauge ) func init() { @@ -14,12 +18,27 @@ func init() { Name: "iota_messages_per_second", Help: "Number of messages per second.", }) + infoMessageTips = prometheus.NewGauge(prometheus.GaugeOpts{ + Name: "iota_info_message_tips", + Help: "Number of message tips.", + }) + infoValueTips = prometheus.NewGauge(prometheus.GaugeOpts{ + Name: "iota_info_value_tips", + Help: "Number of value tips.", + }) registry.MustRegister(messagesPerSecond) + registry.MustRegister(infoApp) + registry.MustRegister(infoMessageTips) addCollect(collectMetrics) } func collectMetrics() { + // MPS messagesPerSecond.Set(float64(metrics.ReceivedMessagesPerSecond())) + + // Tips + infoMessageTips.Set(float64(messagelayer.TipSelector.TipCount())) + infoValueTips.Set(float64(valuetransfers.TipManager().Size())) } -- GitLab