Skip to content

Commit

Permalink
gerge branch 'release/2024.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
tnamao committed Mar 29, 2024
2 parents 83028b4 + 9d3c947 commit 9f78142
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 3 deletions.
17 changes: 17 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# CHANGES

## 2024.3.0

- [UPDATE] Go を 1.22 に上げる
- @tnamao
- [ADD] `sora_client``obs_studio_whep` に対応する
- @tnamao
- [ADD] Sora のクラスターリレー機能のメトリクスを追加する
- GetStatsReport API の `cluster_relay` 以下の統計情報を、起動オプションの `--sora.cluster-metrics` を有効にした時のみ収集する
- 次のメトリクスを送受信しているノード単位で返す
- 送受信バイト数
- `sora_cluster_relay_received_bytes`
- `sora_cluster_relay_sent_bytes`
- 送受信パケット数
- `sora_cluster_relay_received_packets`
- `sora_cluster_relay_sent_packets`
- @tnamao

## 2024.2.0

- [ADD] `sora_license_expired_at_timestamp_seconds` メトリクスを追加する
Expand Down
2 changes: 2 additions & 0 deletions collector/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func (m *ClientMetrics) Collect(ch chan<- prometheus.Metric, report soraClientRe
ch <- newCounter(m.totalSoraClientConnections, float64(report.TotalFailedSoraClientType.SoraJsSdk), "js_sdk", "failed")
ch <- newCounter(m.totalSoraClientConnections, float64(report.TotalFailedSoraClientType.SoraUnitySdk), "unity_sdk", "failed")
ch <- newCounter(m.totalSoraClientConnections, float64(report.TotalFailedSoraClientType.ObsStudioWhip), "obs_studio_whip", "failed")
ch <- newCounter(m.totalSoraClientConnections, float64(report.TotalFailedSoraClientType.ObsStudioWhep), "obs_studio_whep", "failed")
ch <- newCounter(m.totalSoraClientConnections, float64(report.TotalFailedSoraClientType.SoraPythonSdk), "python_sdk", "failed")
ch <- newCounter(m.totalSoraClientConnections, float64(report.TotalFailedSoraClientType.Unknown), "unknown", "failed")
ch <- newCounter(m.totalSoraClientConnections, float64(report.TotalFailedSoraClientType.WebrtcLoadTestingToolZakuro), "zakuro", "failed")
Expand All @@ -38,6 +39,7 @@ func (m *ClientMetrics) Collect(ch chan<- prometheus.Metric, report soraClientRe
ch <- newCounter(m.totalSoraClientConnections, float64(report.TotalSuccessfulSoraClientType.SoraJsSdk), "js_sdk", "successful")
ch <- newCounter(m.totalSoraClientConnections, float64(report.TotalSuccessfulSoraClientType.SoraUnitySdk), "unity_sdk", "successful")
ch <- newCounter(m.totalSoraClientConnections, float64(report.TotalSuccessfulSoraClientType.ObsStudioWhip), "obs_studio_whip", "successful")
ch <- newCounter(m.totalSoraClientConnections, float64(report.TotalSuccessfulSoraClientType.ObsStudioWhep), "obs_studio_whep", "successful")
ch <- newCounter(m.totalSoraClientConnections, float64(report.TotalSuccessfulSoraClientType.SoraPythonSdk), "python_sdk", "successful")
ch <- newCounter(m.totalSoraClientConnections, float64(report.TotalSuccessfulSoraClientType.Unknown), "unknown", "successful")
ch <- newCounter(m.totalSoraClientConnections, float64(report.TotalSuccessfulSoraClientType.WebrtcLoadTestingToolZakuro), "zakuro", "successful")
Expand Down
23 changes: 22 additions & 1 deletion collector/cluster_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ var (
raftState: newDescWithLabel("cluster_raft_state", "The current Raft state. The state name is indicated by the label 'state'. The value of this metric is always set to 1.", []string{"state"}),
raftTerm: newDesc("cluster_raft_term", "The current Raft term."),
raftCommitIndex: newDesc("cluster_raft_commit_index", "The latest committed Raft log index."),

clusterRelayReceivedBytes: newDescWithLabel("cluster_relay_received_bytes", "The total number of bytes received by the cluster relay.", []string{"node_name"}),
clusterRelaySentBytes: newDescWithLabel("cluster_relay_sent_bytes", "The total number of bytes sent by the cluster relay.", []string{"node_name"}),
clusterRelayReceivedPackets: newDescWithLabel("cluster_relay_received_packets", "The total number of packets received by the cluster relay.", []string{"node_name"}),
clusterRelaySentPackets: newDescWithLabel("cluster_relay_sent_packets", "The total number of packets sent by the cluster relay.", []string{"node_name"}),
}
)

Expand All @@ -18,16 +23,25 @@ type SoraClusterMetrics struct {
raftState *prometheus.Desc
raftTerm *prometheus.Desc
raftCommitIndex *prometheus.Desc

clusterRelayReceivedBytes *prometheus.Desc
clusterRelaySentBytes *prometheus.Desc
clusterRelayReceivedPackets *prometheus.Desc
clusterRelaySentPackets *prometheus.Desc
}

func (m *SoraClusterMetrics) Describe(ch chan<- *prometheus.Desc) {
ch <- m.clusterNode
ch <- m.raftState
ch <- m.raftTerm
ch <- m.raftCommitIndex
ch <- m.clusterRelayReceivedBytes
ch <- m.clusterRelaySentBytes
ch <- m.clusterRelayReceivedPackets
ch <- m.clusterRelaySentPackets
}

func (m *SoraClusterMetrics) Collect(ch chan<- prometheus.Metric, nodeList []soraClusterNode, report soraClusterReport) {
func (m *SoraClusterMetrics) Collect(ch chan<- prometheus.Metric, nodeList []soraClusterNode, report soraClusterReport, clusterRelaies []soraClusterRelay) {
for _, node := range nodeList {
value := 0.0
if node.Connected {
Expand All @@ -42,4 +56,11 @@ func (m *SoraClusterMetrics) Collect(ch chan<- prometheus.Metric, nodeList []sor
ch <- newGauge(m.raftState, 1.0, report.RaftState)
ch <- newCounter(m.raftTerm, float64(report.RaftTerm))
ch <- newCounter(m.raftCommitIndex, float64(report.RaftCommitIndex))

for _, relayNode := range clusterRelaies {
ch <- newCounter(m.clusterRelayReceivedBytes, float64(relayNode.TotalReceivedByteSize), relayNode.NodeName)
ch <- newCounter(m.clusterRelaySentBytes, float64(relayNode.TotalSentByteSize), relayNode.NodeName)
ch <- newCounter(m.clusterRelayReceivedPackets, float64(relayNode.TotalReceived), relayNode.NodeName)
ch <- newCounter(m.clusterRelaySentPackets, float64(relayNode.TotalSent), relayNode.NodeName)
}
}
2 changes: 1 addition & 1 deletion collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) {
c.ErlangVMMetrics.Collect(ch, report.ErlangVMReport)
}
if c.EnableSoraClusterMetrics {
c.SoraClusterMetrics.Collect(ch, nodeList, report.ClusterReport)
c.SoraClusterMetrics.Collect(ch, nodeList, report.ClusterReport, report.ClusterRelay)
}
}

Expand Down
10 changes: 10 additions & 0 deletions collector/sora_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type soraGetStatsReport struct {
SoraConnectionErrorReport soraConnectionErrorReport `json:"error,omitempty"`
ErlangVMReport erlangVMReport `json:"erlang_vm,omitempty"`
ClusterReport soraClusterReport `json:"cluster,omitempty"`
ClusterRelay []soraClusterRelay `json:"cluster_relay,omitempty"`
}

type soraConnectionReport struct {
Expand Down Expand Up @@ -47,6 +48,7 @@ type soraClientStatistics struct {
SoraJsSdk int64 `json:"sora_js_sdk"`
SoraUnitySdk int64 `json:"sora_unity_sdk"`
ObsStudioWhip int64 `json:"obs_studio_whip"`
ObsStudioWhep int64 `json:"obs_studio_whep"`
SoraPythonSdk int64 `json:"sora_python_sdk"`
Unknown int64 `json:"unknown"`
WebrtcLoadTestingToolZakuro int64 `json:"webrtc_load_testing_tool_zakuro"`
Expand Down Expand Up @@ -142,6 +144,14 @@ type soraClusterNode struct {
Connected bool `json:"connected"`
}

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"`
}

type soraLicenseInfo struct {
ExpiredAt string `json:"expired_at"`
MaxConnections int64 `json:"max_connections"`
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/shiguredo/sora_exporter

go 1.21
go 1.22

require (
github.com/alecthomas/kingpin/v2 v2.3.2
Expand Down
18 changes: 18 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ var (
"raft_state": "follower",
"raft_term": 3
},
"cluster_relay": [
{
"node_name": "node-01",
"total_received_byte_size": 11,
"total_sent_byte_size": 12,
"total_received": 13,
"total_sent": 14
},
{
"node_name": "node-02",
"total_received_byte_size": 21,
"total_sent_byte_size": 22,
"total_received": 23,
"total_sent": 24
}
],
"erlang_vm": {
"memory": {
"total": 1234,
Expand Down Expand Up @@ -105,6 +121,7 @@ var (
"sora_js_sdk": 3,
"sora_unity_sdk": 4,
"obs_studio_whip": 10,
"obs_studio_whep": 13,
"sora_python_sdk": 11,
"unknown": 5,
"webrtc_load_testing_tool_zakuro": 8,
Expand All @@ -119,6 +136,7 @@ var (
"sora_js_sdk": 33,
"sora_unity_sdk": 44,
"obs_studio_whip": 1010,
"obs_studio_whep": 1313,
"sora_python_sdk": 1111,
"unknown": 55,
"webrtc_load_testing_tool_zakuro": 88,
Expand Down
18 changes: 18 additions & 0 deletions test/maximum.metrics
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ sora_cluster_raft_state{state="follower"} 1
# HELP sora_cluster_raft_term The current Raft term.
# TYPE sora_cluster_raft_term counter
sora_cluster_raft_term 3
# HELP sora_cluster_relay_received_bytes The total number of bytes received by the cluster relay.
# TYPE sora_cluster_relay_received_bytes counter
sora_cluster_relay_received_bytes{node_name="node-01"} 11
sora_cluster_relay_received_bytes{node_name="node-02"} 21
# HELP sora_cluster_relay_received_packets The total number of packets received by the cluster relay.
# TYPE sora_cluster_relay_received_packets counter
sora_cluster_relay_received_packets{node_name="node-01"} 13
sora_cluster_relay_received_packets{node_name="node-02"} 23
# HELP sora_cluster_relay_sent_bytes The total number of bytes sent by the cluster relay.
# TYPE sora_cluster_relay_sent_bytes counter
sora_cluster_relay_sent_bytes{node_name="node-01"} 12
sora_cluster_relay_sent_bytes{node_name="node-02"} 22
# HELP sora_cluster_relay_sent_packets The total number of packets sent by the cluster relay.
# TYPE sora_cluster_relay_sent_packets counter
sora_cluster_relay_sent_packets{node_name="node-01"} 14
sora_cluster_relay_sent_packets{node_name="node-02"} 24
# 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
Expand All @@ -40,6 +56,8 @@ sora_client_type_total{client="momo",state="failed"} 6
sora_client_type_total{client="momo",state="successful"} 66
sora_client_type_total{client="unity_sdk",state="failed"} 4
sora_client_type_total{client="unity_sdk",state="successful"} 44
sora_client_type_total{client="obs_studio_whep",state="failed"} 13
sora_client_type_total{client="obs_studio_whep",state="successful"} 1313
sora_client_type_total{client="obs_studio_whip",state="failed"} 10
sora_client_type_total{client="obs_studio_whip",state="successful"} 1010
sora_client_type_total{client="python_sdk",state="failed"} 11
Expand Down
2 changes: 2 additions & 0 deletions test/sora_client_enabled.metrics
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ sora_client_type_total{client="momo",state="failed"} 6
sora_client_type_total{client="momo",state="successful"} 66
sora_client_type_total{client="unity_sdk",state="failed"} 4
sora_client_type_total{client="unity_sdk",state="successful"} 44
sora_client_type_total{client="obs_studio_whep",state="failed"} 13
sora_client_type_total{client="obs_studio_whep",state="successful"} 1313
sora_client_type_total{client="obs_studio_whip",state="failed"} 10
sora_client_type_total{client="obs_studio_whip",state="successful"} 1010
sora_client_type_total{client="python_sdk",state="failed"} 11
Expand Down
16 changes: 16 additions & 0 deletions test/sora_cluster_metrics_enabled.metrics
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ sora_cluster_raft_state{state="follower"} 1
# HELP sora_cluster_raft_term The current Raft term.
# TYPE sora_cluster_raft_term counter
sora_cluster_raft_term 3
# HELP sora_cluster_relay_received_bytes The total number of bytes received by the cluster relay.
# TYPE sora_cluster_relay_received_bytes counter
sora_cluster_relay_received_bytes{node_name="node-01"} 11
sora_cluster_relay_received_bytes{node_name="node-02"} 21
# HELP sora_cluster_relay_received_packets The total number of packets received by the cluster relay.
# TYPE sora_cluster_relay_received_packets counter
sora_cluster_relay_received_packets{node_name="node-01"} 13
sora_cluster_relay_received_packets{node_name="node-02"} 23
# HELP sora_cluster_relay_sent_bytes The total number of bytes sent by the cluster relay.
# TYPE sora_cluster_relay_sent_bytes counter
sora_cluster_relay_sent_bytes{node_name="node-01"} 12
sora_cluster_relay_sent_bytes{node_name="node-02"} 22
# HELP sora_cluster_relay_sent_packets The total number of packets sent by the cluster relay.
# TYPE sora_cluster_relay_sent_packets counter
sora_cluster_relay_sent_packets{node_name="node-01"} 14
sora_cluster_relay_sent_packets{node_name="node-02"} 24
# HELP sora_connections_total The total number of connections created.
# TYPE sora_connections_total counter
sora_connections_total{state="created"} 2
Expand Down

0 comments on commit 9f78142

Please sign in to comment.