Skip to content

Commit

Permalink
Merge pull request #48 from shiguredo/feature/plumtree-hop-count
Browse files Browse the repository at this point in the history
cluster_relay_plumtree_received_gossip_hop_total メトリクス (Sora 2025.1.0 で導入予定) を追加する
  • Loading branch information
sile authored Jan 8, 2025
2 parents 8634632 + 802aa48 commit 840950c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Sora 2025.1.0 で Sora API の GetStatsReport API に追加される予定の多段リレー関連の以下のメトリクスを追加する
- `cluster_relay_plumtree_sent_gossip_total`
- `cluster_relay_plumtree_received_gossip_total`
- `cluster_relay_plumtree_received_gossip_hop_total`
- `cluster_relay_plumtree_sent_ihave_total`
- `cluster_relay_plumtree_received_ihave_total`
- `cluster_relay_plumtree_sent_graft_total`
Expand Down
26 changes: 15 additions & 11 deletions collector/cluster_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var (

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"}),
clusterRelayPlumtreeReceivedGossipHopTotal: newDescWithLabel("cluster_relay_plumtree_received_gossip_hop_total", "The total number of hop count 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"}),
Expand All @@ -41,17 +42,18 @@ type SoraClusterMetrics struct {
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
clusterRelayPlumtreeSentGossipTotal *prometheus.Desc
clusterRelayPlumtreeReceivedGossipTotal *prometheus.Desc
clusterRelayPlumtreeReceivedGossipHopTotal *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) {
Expand All @@ -65,6 +67,7 @@ func (m *SoraClusterMetrics) Describe(ch chan<- *prometheus.Desc) {
ch <- m.clusterRelaySentPacketsTotal
ch <- m.clusterRelayPlumtreeSentGossipTotal
ch <- m.clusterRelayPlumtreeReceivedGossipTotal
ch <- m.clusterRelayPlumtreeReceivedGossipHopTotal
ch <- m.clusterRelayPlumtreeSentIhaveTotal
ch <- m.clusterRelayPlumtreeReceivedIhaveTotal
ch <- m.clusterRelayPlumtreeSentGraftTotal
Expand Down Expand Up @@ -106,6 +109,7 @@ func (m *SoraClusterMetrics) Collect(ch chan<- prometheus.Metric, nodeList []sor

ch <- newCounter(m.clusterRelayPlumtreeSentGossipTotal, float64(relayNode.Plumtree.TotalSentGossip), relayNode.NodeName)
ch <- newCounter(m.clusterRelayPlumtreeReceivedGossipTotal, float64(relayNode.Plumtree.TotalReceivedGossip), relayNode.NodeName)
ch <- newCounter(m.clusterRelayPlumtreeReceivedGossipHopTotal, float64(relayNode.Plumtree.TotalReceivedGossipHop), 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)
Expand Down
23 changes: 12 additions & 11 deletions collector/sora_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,18 @@ type soraClusterRelay struct {
}

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"`
TotalSentGossip int64 `json:"total_sent_gossip"`
TotalReceivedGossip int64 `json:"total_received_gossip"`
TotalReceivedGossipHop int64 `json:"total_received_gossip_hop"`
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 {
Expand Down
2 changes: 2 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var (
"plumtree": {
"total_sent_gossip": 1,
"total_received_gossip": 2,
"total_received_gossip_hop": 4,
"total_sent_ihave": 3,
"total_received_ihave": 4,
"total_sent_graft": 5,
Expand All @@ -55,6 +56,7 @@ var (
"plumtree": {
"total_sent_gossip": 101,
"total_received_gossip": 102,
"total_received_gossip_hop": 150,
"total_sent_ihave": 103,
"total_received_ihave": 104,
"total_sent_graft": 105,
Expand Down
4 changes: 4 additions & 0 deletions test/maximum.metrics
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ sora_cluster_relay_plumtree_ignored_total{node_name="node-02"} 111
# 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_gossip_hop_total The total number of hop count of Plumtree GOSSIP messages received by the cluster relay.
# TYPE sora_cluster_relay_plumtree_received_gossip_hop_total counter
sora_cluster_relay_plumtree_received_gossip_hop_total{node_name="node-01"} 4
sora_cluster_relay_plumtree_received_gossip_hop_total{node_name="node-02"} 150
# 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
Expand Down
4 changes: 4 additions & 0 deletions test/sora_cluster_metrics_enabled.metrics
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ sora_cluster_relay_plumtree_ignored_total{node_name="node-02"} 111
# 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_gossip_hop_total The total number of hop count of Plumtree GOSSIP messages received by the cluster relay.
# TYPE sora_cluster_relay_plumtree_received_gossip_hop_total counter
sora_cluster_relay_plumtree_received_gossip_hop_total{node_name="node-01"} 4
sora_cluster_relay_plumtree_received_gossip_hop_total{node_name="node-02"} 150
# 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
Expand Down

0 comments on commit 840950c

Please sign in to comment.