From 1426e7173d28eb381ce4d8063b70049a851aee51 Mon Sep 17 00:00:00 2001 From: Takeru Ohta Date: Thu, 19 Dec 2024 11:29:27 +0900 Subject: [PATCH] =?UTF-8?q?plumtree=20=E9=96=A2=E9=80=A3=E3=81=AE=E3=83=A1?= =?UTF-8?q?=E3=83=88=E3=83=AA=E3=82=AF=E3=82=B9=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- collector/cluster_node.go | 47 +++++++++++++++++++++++ collector/sora_api.go | 25 +++++++++--- main_test.go | 30 ++++++++++++++- test/maximum.metrics | 44 +++++++++++++++++++++ test/sora_cluster_metrics_enabled.metrics | 44 +++++++++++++++++++++ 5 files changed, 183 insertions(+), 7 deletions(-) diff --git a/collector/cluster_node.go b/collector/cluster_node.go index 3d28529..b82c31c 100644 --- a/collector/cluster_node.go +++ b/collector/cluster_node.go @@ -15,6 +15,18 @@ var ( clusterRelaySentBytesTotal: newDescWithLabel("cluster_relay_sent_bytes_total", "The total number of bytes sent by the cluster relay.", []string{"node_name"}), clusterRelayReceivedPacketsTotal: newDescWithLabel("cluster_relay_received_packets_total", "The total number of packets received by the cluster relay.", []string{"node_name"}), clusterRelaySentPacketsTotal: newDescWithLabel("cluster_relay_sent_packets_total", "The total number of packets sent by the cluster relay.", []string{"node_name"}), + + clusterRelayPlumtreeSentGossipTotal: newDescWithLabel("cluster_relay_plumtree_sent_gossip_total", "The total number of Plumtree GOSSIP messages sent by the cluster relay.", []string{"node_name"}), + clusterRelayPlumtreeReceivedGossipTotal: newDescWithLabel("cluster_relay_plumtree_received_gossip_total", "The total number of Plumtree GOSSIP messages received by the cluster relay.", []string{"node_name"}), + clusterRelayPlumtreeSentIhaveTotal: newDescWithLabel("cluster_relay_plumtree_sent_ihave_total", "The total number of Plumtree IHAVE messages sent by the cluster relay.", []string{"node_name"}), + clusterRelayPlumtreeReceivedIhaveTotal: newDescWithLabel("cluster_relay_plumtree_received_ihave_total", "The total number of Plumtree IHAVE messages received by the cluster relay.", []string{"node_name"}), + clusterRelayPlumtreeSentGraftTotal: newDescWithLabel("cluster_relay_plumtree_sent_graft_total", "The total number of Plumtree GRAFT messages sent by the cluster relay.", []string{"node_name"}), + clusterRelayPlumtreeReceivedGraftTotal: newDescWithLabel("cluster_relay_plumtree_received_graft_total", "The total number of Plumtree GRAFT messages received by the cluster relay.", []string{"node_name"}), + clusterRelayPlumtreeSentPruneTotal: newDescWithLabel("cluster_relay_plumtree_sent_prune_total", "The total number of Plumtree PRUNE messages sent by the cluster relay.", []string{"node_name"}), + clusterRelayPlumtreeReceivedPruneTotal: newDescWithLabel("cluster_relay_plumtree_received_prune_total", "The total number of Plumtree PRUNE messages received by the cluster relay.", []string{"node_name"}), + clusterRelayPlumtreeGraftMissTotal: newDescWithLabel("cluster_relay_plumtree_graft_miss_total", "The total number of Plumtree GRAFT messages missed by the cluster relay.", []string{"node_name"}), + clusterRelayPlumtreeSkippedSendTotal: newDescWithLabel("cluster_relay_plumtree_skipped_send_total", "The total number of Plumtree messages whose sending was skipped by the cluster relay.", []string{"node_name"}), + clusterRelayPlumtreeIgnoredTotal: newDescWithLabel("cluster_relay_plumtree_ignored_total", "The total number of Plumtree messages received but ignored by the cluster relay.", []string{"node_name"}), } ) @@ -28,6 +40,18 @@ type SoraClusterMetrics struct { clusterRelaySentBytesTotal *prometheus.Desc clusterRelayReceivedPacketsTotal *prometheus.Desc clusterRelaySentPacketsTotal *prometheus.Desc + + clusterRelayPlumtreeSentGossipTotal *prometheus.Desc + clusterRelayPlumtreeReceivedGossipTotal *prometheus.Desc + clusterRelayPlumtreeSentIhaveTotal *prometheus.Desc + clusterRelayPlumtreeReceivedIhaveTotal *prometheus.Desc + clusterRelayPlumtreeSentGraftTotal *prometheus.Desc + clusterRelayPlumtreeReceivedGraftTotal *prometheus.Desc + clusterRelayPlumtreeSentPruneTotal *prometheus.Desc + clusterRelayPlumtreeReceivedPruneTotal *prometheus.Desc + clusterRelayPlumtreeGraftMissTotal *prometheus.Desc + clusterRelayPlumtreeSkippedSendTotal *prometheus.Desc + clusterRelayPlumtreeIgnoredTotal *prometheus.Desc } func (m *SoraClusterMetrics) Describe(ch chan<- *prometheus.Desc) { @@ -39,6 +63,17 @@ func (m *SoraClusterMetrics) Describe(ch chan<- *prometheus.Desc) { ch <- m.clusterRelaySentBytesTotal ch <- m.clusterRelayReceivedPacketsTotal ch <- m.clusterRelaySentPacketsTotal + ch <- m.clusterRelayPlumtreeSentGossipTotal + ch <- m.clusterRelayPlumtreeReceivedGossipTotal + ch <- m.clusterRelayPlumtreeSentIhaveTotal + ch <- m.clusterRelayPlumtreeReceivedIhaveTotal + ch <- m.clusterRelayPlumtreeSentGraftTotal + ch <- m.clusterRelayPlumtreeReceivedGraftTotal + ch <- m.clusterRelayPlumtreeSentPruneTotal + ch <- m.clusterRelayPlumtreeReceivedPruneTotal + ch <- m.clusterRelayPlumtreeGraftMissTotal + ch <- m.clusterRelayPlumtreeSkippedSendTotal + ch <- m.clusterRelayPlumtreeIgnoredTotal } func (m *SoraClusterMetrics) Collect(ch chan<- prometheus.Metric, nodeList []soraClusterNode, report soraClusterReport, clusterRelaies []soraClusterRelay) { @@ -68,5 +103,17 @@ func (m *SoraClusterMetrics) Collect(ch chan<- prometheus.Metric, nodeList []sor ch <- newCounter(m.clusterRelaySentBytesTotal, float64(relayNode.TotalSentByteSize), relayNode.NodeName) ch <- newCounter(m.clusterRelayReceivedPacketsTotal, float64(relayNode.TotalReceived), relayNode.NodeName) ch <- newCounter(m.clusterRelaySentPacketsTotal, float64(relayNode.TotalSent), relayNode.NodeName) + + ch <- newCounter(m.clusterRelayPlumtreeSentGossipTotal, float64(relayNode.Plumtree.TotalSentGossip), relayNode.NodeName) + ch <- newCounter(m.clusterRelayPlumtreeReceivedGossipTotal, float64(relayNode.Plumtree.TotalReceivedGossip), relayNode.NodeName) + ch <- newCounter(m.clusterRelayPlumtreeSentIhaveTotal, float64(relayNode.Plumtree.TotalSentIhave), relayNode.NodeName) + ch <- newCounter(m.clusterRelayPlumtreeReceivedIhaveTotal, float64(relayNode.Plumtree.TotalReceivedIhave), relayNode.NodeName) + ch <- newCounter(m.clusterRelayPlumtreeSentGraftTotal, float64(relayNode.Plumtree.TotalSentGraft), relayNode.NodeName) + ch <- newCounter(m.clusterRelayPlumtreeReceivedGraftTotal, float64(relayNode.Plumtree.TotalReceivedGraft), relayNode.NodeName) + ch <- newCounter(m.clusterRelayPlumtreeSentPruneTotal, float64(relayNode.Plumtree.TotalSentPrune), relayNode.NodeName) + ch <- newCounter(m.clusterRelayPlumtreeReceivedPruneTotal, float64(relayNode.Plumtree.TotalReceivedPrune), relayNode.NodeName) + ch <- newCounter(m.clusterRelayPlumtreeGraftMissTotal, float64(relayNode.Plumtree.TotalGraftMiss), relayNode.NodeName) + ch <- newCounter(m.clusterRelayPlumtreeSkippedSendTotal, float64(relayNode.Plumtree.TotalSkippedSend), relayNode.NodeName) + ch <- newCounter(m.clusterRelayPlumtreeIgnoredTotal, float64(relayNode.Plumtree.TotalIgnored), relayNode.NodeName) } } diff --git a/collector/sora_api.go b/collector/sora_api.go index aa92016..a07f5a4 100644 --- a/collector/sora_api.go +++ b/collector/sora_api.go @@ -170,11 +170,26 @@ type soraClusterNode struct { } type soraClusterRelay struct { - NodeName string `json:"node_name"` - TotalReceivedByteSize int64 `json:"total_received_byte_size"` - TotalSentByteSize int64 `json:"total_sent_byte_size"` - TotalReceived int64 `json:"total_received"` - TotalSent int64 `json:"total_sent"` + NodeName string `json:"node_name"` + TotalReceivedByteSize int64 `json:"total_received_byte_size"` + TotalSentByteSize int64 `json:"total_sent_byte_size"` + TotalReceived int64 `json:"total_received"` + TotalSent int64 `json:"total_sent"` + Plumtree soraClusterRelayPlumtree `json:"plumtree"` +} + +type soraClusterRelayPlumtree struct { + TotalSentGossip int64 `json:"total_sent_gossip"` + TotalReceivedGossip int64 `json:"total_received_gossip"` + TotalSentIhave int64 `json:"total_sent_ihave"` + TotalReceivedIhave int64 `json:"total_received_ihave"` + TotalSentGraft int64 `json:"total_sent_graft"` + TotalReceivedGraft int64 `json:"total_received_graft"` + TotalSentPrune int64 `json:"total_sent_prune"` + TotalReceivedPrune int64 `json:"total_received_prune"` + TotalGraftMiss int64 `json:"total_graft_miss"` + TotalSkippedSend int64 `json:"total_skipped_send"` + TotalIgnored int64 `json:"total_ignored"` } type soraLicenseInfo struct { diff --git a/main_test.go b/main_test.go index 3ec7c00..0f208a6 100644 --- a/main_test.go +++ b/main_test.go @@ -31,14 +31,40 @@ var ( "total_received_byte_size": 11, "total_sent_byte_size": 12, "total_received": 13, - "total_sent": 14 + "total_sent": 14, + "plumtree": { + "total_sent_gossip": 1, + "total_received_gossip": 2, + "total_sent_ihave": 3, + "total_received_ihave": 4, + "total_sent_graft": 5, + "total_received_graft": 6, + "total_sent_prune": 7, + "total_received_prune": 8, + "total_graft_miss": 9, + "total_skipped_send": 10, + "total_ignored": 11 + } }, { "node_name": "node-02", "total_received_byte_size": 21, "total_sent_byte_size": 22, "total_received": 23, - "total_sent": 24 + "total_sent": 24, + "plumtree": { + "total_sent_gossip": 101, + "total_received_gossip": 102, + "total_sent_ihave": 103, + "total_received_ihave": 104, + "total_sent_graft": 105, + "total_received_graft": 106, + "total_sent_prune": 107, + "total_received_prune": 108, + "total_graft_miss": 109, + "total_skipped_send": 110, + "total_ignored": 111 + } } ], "erlang_vm": { diff --git a/test/maximum.metrics b/test/maximum.metrics index 8f93f55..c2393d2 100644 --- a/test/maximum.metrics +++ b/test/maximum.metrics @@ -38,6 +38,50 @@ sora_cluster_relay_sent_bytes_total{node_name="node-02"} 22 # TYPE sora_cluster_relay_sent_packets_total counter sora_cluster_relay_sent_packets_total{node_name="node-01"} 14 sora_cluster_relay_sent_packets_total{node_name="node-02"} 24 +# HELP sora_cluster_relay_plumtree_graft_miss_total The total number of Plumtree GRAFT messages missed by the cluster relay. +# TYPE sora_cluster_relay_plumtree_graft_miss_total counter +sora_cluster_relay_plumtree_graft_miss_total{node_name="node-01"} 9 +sora_cluster_relay_plumtree_graft_miss_total{node_name="node-02"} 109 +# HELP sora_cluster_relay_plumtree_ignored_total The total number of Plumtree messages received but ignored by the cluster relay. +# TYPE sora_cluster_relay_plumtree_ignored_total counter +sora_cluster_relay_plumtree_ignored_total{node_name="node-01"} 11 +sora_cluster_relay_plumtree_ignored_total{node_name="node-02"} 111 +# HELP sora_cluster_relay_plumtree_received_gossip_total The total number of Plumtree GOSSIP messages received by the cluster relay. +# TYPE sora_cluster_relay_plumtree_received_gossip_total counter +sora_cluster_relay_plumtree_received_gossip_total{node_name="node-01"} 2 +sora_cluster_relay_plumtree_received_gossip_total{node_name="node-02"} 102 +# HELP sora_cluster_relay_plumtree_received_graft_total The total number of Plumtree GRAFT messages received by the cluster relay. +# TYPE sora_cluster_relay_plumtree_received_graft_total counter +sora_cluster_relay_plumtree_received_graft_total{node_name="node-01"} 6 +sora_cluster_relay_plumtree_received_graft_total{node_name="node-02"} 106 +# HELP sora_cluster_relay_plumtree_received_ihave_total The total number of Plumtree IHAVE messages received by the cluster relay. +# TYPE sora_cluster_relay_plumtree_received_ihave_total counter +sora_cluster_relay_plumtree_received_ihave_total{node_name="node-01"} 4 +sora_cluster_relay_plumtree_received_ihave_total{node_name="node-02"} 104 +# HELP sora_cluster_relay_plumtree_received_prune_total The total number of Plumtree PRUNE messages received by the cluster relay. +# TYPE sora_cluster_relay_plumtree_received_prune_total counter +sora_cluster_relay_plumtree_received_prune_total{node_name="node-01"} 8 +sora_cluster_relay_plumtree_received_prune_total{node_name="node-02"} 108 +# HELP sora_cluster_relay_plumtree_sent_gossip_total The total number of Plumtree GOSSIP messages sent by the cluster relay. +# TYPE sora_cluster_relay_plumtree_sent_gossip_total counter +sora_cluster_relay_plumtree_sent_gossip_total{node_name="node-01"} 1 +sora_cluster_relay_plumtree_sent_gossip_total{node_name="node-02"} 101 +# HELP sora_cluster_relay_plumtree_sent_graft_total The total number of Plumtree GRAFT messages sent by the cluster relay. +# TYPE sora_cluster_relay_plumtree_sent_graft_total counter +sora_cluster_relay_plumtree_sent_graft_total{node_name="node-01"} 5 +sora_cluster_relay_plumtree_sent_graft_total{node_name="node-02"} 105 +# HELP sora_cluster_relay_plumtree_sent_ihave_total The total number of Plumtree IHAVE messages sent by the cluster relay. +# TYPE sora_cluster_relay_plumtree_sent_ihave_total counter +sora_cluster_relay_plumtree_sent_ihave_total{node_name="node-01"} 3 +sora_cluster_relay_plumtree_sent_ihave_total{node_name="node-02"} 103 +# HELP sora_cluster_relay_plumtree_sent_prune_total The total number of Plumtree PRUNE messages sent by the cluster relay. +# TYPE sora_cluster_relay_plumtree_sent_prune_total counter +sora_cluster_relay_plumtree_sent_prune_total{node_name="node-01"} 7 +sora_cluster_relay_plumtree_sent_prune_total{node_name="node-02"} 107 +# HELP sora_cluster_relay_plumtree_skipped_send_total The total number of Plumtree messages whose sending was skipped by the cluster relay. +# TYPE sora_cluster_relay_plumtree_skipped_send_total counter +sora_cluster_relay_plumtree_skipped_send_total{node_name="node-01"} 10 +sora_cluster_relay_plumtree_skipped_send_total{node_name="node-02"} 110 # HELP sora_client_type_total The total number of connections by Sora client types # TYPE sora_client_type_total counter sora_client_type_total{client="android_sdk",state="failed"} 1 diff --git a/test/sora_cluster_metrics_enabled.metrics b/test/sora_cluster_metrics_enabled.metrics index 88999b1..e3f6867 100644 --- a/test/sora_cluster_metrics_enabled.metrics +++ b/test/sora_cluster_metrics_enabled.metrics @@ -38,6 +38,50 @@ sora_cluster_relay_sent_bytes_total{node_name="node-02"} 22 # TYPE sora_cluster_relay_sent_packets_total counter sora_cluster_relay_sent_packets_total{node_name="node-01"} 14 sora_cluster_relay_sent_packets_total{node_name="node-02"} 24 +# HELP sora_cluster_relay_plumtree_graft_miss_total The total number of Plumtree GRAFT messages missed by the cluster relay. +# TYPE sora_cluster_relay_plumtree_graft_miss_total counter +sora_cluster_relay_plumtree_graft_miss_total{node_name="node-01"} 9 +sora_cluster_relay_plumtree_graft_miss_total{node_name="node-02"} 109 +# HELP sora_cluster_relay_plumtree_ignored_total The total number of Plumtree messages received but ignored by the cluster relay. +# TYPE sora_cluster_relay_plumtree_ignored_total counter +sora_cluster_relay_plumtree_ignored_total{node_name="node-01"} 11 +sora_cluster_relay_plumtree_ignored_total{node_name="node-02"} 111 +# HELP sora_cluster_relay_plumtree_received_gossip_total The total number of Plumtree GOSSIP messages received by the cluster relay. +# TYPE sora_cluster_relay_plumtree_received_gossip_total counter +sora_cluster_relay_plumtree_received_gossip_total{node_name="node-01"} 2 +sora_cluster_relay_plumtree_received_gossip_total{node_name="node-02"} 102 +# HELP sora_cluster_relay_plumtree_received_graft_total The total number of Plumtree GRAFT messages received by the cluster relay. +# TYPE sora_cluster_relay_plumtree_received_graft_total counter +sora_cluster_relay_plumtree_received_graft_total{node_name="node-01"} 6 +sora_cluster_relay_plumtree_received_graft_total{node_name="node-02"} 106 +# HELP sora_cluster_relay_plumtree_received_ihave_total The total number of Plumtree IHAVE messages received by the cluster relay. +# TYPE sora_cluster_relay_plumtree_received_ihave_total counter +sora_cluster_relay_plumtree_received_ihave_total{node_name="node-01"} 4 +sora_cluster_relay_plumtree_received_ihave_total{node_name="node-02"} 104 +# HELP sora_cluster_relay_plumtree_received_prune_total The total number of Plumtree PRUNE messages received by the cluster relay. +# TYPE sora_cluster_relay_plumtree_received_prune_total counter +sora_cluster_relay_plumtree_received_prune_total{node_name="node-01"} 8 +sora_cluster_relay_plumtree_received_prune_total{node_name="node-02"} 108 +# HELP sora_cluster_relay_plumtree_sent_gossip_total The total number of Plumtree GOSSIP messages sent by the cluster relay. +# TYPE sora_cluster_relay_plumtree_sent_gossip_total counter +sora_cluster_relay_plumtree_sent_gossip_total{node_name="node-01"} 1 +sora_cluster_relay_plumtree_sent_gossip_total{node_name="node-02"} 101 +# HELP sora_cluster_relay_plumtree_sent_graft_total The total number of Plumtree GRAFT messages sent by the cluster relay. +# TYPE sora_cluster_relay_plumtree_sent_graft_total counter +sora_cluster_relay_plumtree_sent_graft_total{node_name="node-01"} 5 +sora_cluster_relay_plumtree_sent_graft_total{node_name="node-02"} 105 +# HELP sora_cluster_relay_plumtree_sent_ihave_total The total number of Plumtree IHAVE messages sent by the cluster relay. +# TYPE sora_cluster_relay_plumtree_sent_ihave_total counter +sora_cluster_relay_plumtree_sent_ihave_total{node_name="node-01"} 3 +sora_cluster_relay_plumtree_sent_ihave_total{node_name="node-02"} 103 +# HELP sora_cluster_relay_plumtree_sent_prune_total The total number of Plumtree PRUNE messages sent by the cluster relay. +# TYPE sora_cluster_relay_plumtree_sent_prune_total counter +sora_cluster_relay_plumtree_sent_prune_total{node_name="node-01"} 7 +sora_cluster_relay_plumtree_sent_prune_total{node_name="node-02"} 107 +# HELP sora_cluster_relay_plumtree_skipped_send_total The total number of Plumtree messages whose sending was skipped by the cluster relay. +# TYPE sora_cluster_relay_plumtree_skipped_send_total counter +sora_cluster_relay_plumtree_skipped_send_total{node_name="node-01"} 10 +sora_cluster_relay_plumtree_skipped_send_total{node_name="node-02"} 110 # HELP sora_connections_total The total number of connections created. # TYPE sora_connections_total counter sora_connections_total{state="created"} 2