diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 10354e8..bdb37bd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,53 +3,52 @@ name: Release Build on: push: tags: - - '*' + - "*" jobs: - build: name: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version-file: "./go.mod" + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: "./go.mod" - - run: go install github.com/tcnksm/ghr@latest + - run: go install github.com/tcnksm/ghr@latest - - name: Build - run: | - VERSION=$(git describe --tag --abbrev=0) - REVISION=$(git rev-parse --short HEAD) - GOOS=linux GOARCH=amd64 go build \ - -o dist/sora_exporter_linux_amd64-${VERSION} \ - -ldflags "\ - -X github.com/prometheus/common/version.Version=${VERSION} \ - -X github.com/prometheus/common/version.Revision=${REVISION} \ - -X github.com/prometheus/common/version.Branch=main \ - -X github.com/prometheus/common/version.BuildUser=shiguredo \ - -X github.com/prometheus/common/version.BuildDate=$(date -u "+%Y-%m-%dT%H:%M:%SZ") \ - " \ - main.go - GOOS=linux GOARCH=arm64 go build \ - -o dist/sora_exporter_linux_arm64-${VERSION} \ - -ldflags "\ - -X github.com/prometheus/common/version.Version=${VERSION} \ - -X github.com/prometheus/common/version.Revision=${REVISION} \ - -X github.com/prometheus/common/version.Branch=main \ - -X github.com/prometheus/common/version.BuildUser=shiguredo \ - -X github.com/prometheus/common/version.BuildDate=$(date -u "+%Y-%m-%dT%H:%M:%SZ") \ - " \ - main.go - gzip dist/* - - name: Release - run: | - ghr -t "${{ secrets.GITHUB_TOKEN }}" \ - -u "${{ github.repository_owner }}" \ - -r "sora_exporter" \ - -n "${{ github.ref }}" \ - --replace "${GITHUB_REF##*/}" \ - dist/ + - name: Build + run: | + VERSION=$(git describe --tag --abbrev=0) + REVISION=$(git rev-parse --short HEAD) + GOOS=linux GOARCH=amd64 go build \ + -o dist/sora_exporter_linux_amd64-${VERSION} \ + -ldflags "\ + -X github.com/prometheus/common/version.Version=${VERSION} \ + -X github.com/prometheus/common/version.Revision=${REVISION} \ + -X github.com/prometheus/common/version.Branch=main \ + -X github.com/prometheus/common/version.BuildUser=shiguredo \ + -X github.com/prometheus/common/version.BuildDate=$(date -u "+%Y-%m-%dT%H:%M:%SZ") \ + " \ + main.go + GOOS=linux GOARCH=arm64 go build \ + -o dist/sora_exporter_linux_arm64-${VERSION} \ + -ldflags "\ + -X github.com/prometheus/common/version.Version=${VERSION} \ + -X github.com/prometheus/common/version.Revision=${REVISION} \ + -X github.com/prometheus/common/version.Branch=main \ + -X github.com/prometheus/common/version.BuildUser=shiguredo \ + -X github.com/prometheus/common/version.BuildDate=$(date -u "+%Y-%m-%dT%H:%M:%SZ") \ + " \ + main.go + gzip dist/* + - name: Release + run: | + ghr -t "${{ secrets.GITHUB_TOKEN }}" \ + -u "${{ github.repository_owner }}" \ + -r "sora_exporter" \ + -n "${{ github.ref }}" \ + --replace "${GITHUB_REF##*/}" \ + dist/ diff --git a/CHANGES.md b/CHANGES.md index be1dd1b..ede8629 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,13 @@ # CHANGES +## 2024.5.0 + +- [ADD] Sora の Stats Webhook の統計情報に対応する + - `sora_stats_webhook_total` メトリクスを追加し、ラベルに `successful` `failed` を設ける + - @tnamao +- [UPDATE] CI の `actions/setup-go` を `v5` に上げる + - @tnamao + ## 2024.4.0 - [CHANGE] クラスターリレーのメトリクス名を変更する @@ -10,7 +18,7 @@ - 送受信パケット数 - `sora_cluster_relay_received_packets` を `sora_cluster_relay_recived_packets_total` に変更する - `sora_cluster_relay_sent_packets` を `sora_cluster_relay_sent_packets_total` に変更する - @tnamao + - @tnamao ## 2024.3.0 diff --git a/collector/sora_api.go b/collector/sora_api.go index 09c1576..2d30d28 100644 --- a/collector/sora_api.go +++ b/collector/sora_api.go @@ -37,6 +37,8 @@ type soraWebhookReport struct { TotalFailedSessionWebhook int64 `json:"total_failed_session_webhook"` TotalSuccessfulEventWebhook int64 `json:"total_successful_event_webhook"` TotalFailedEventWebhook int64 `json:"total_failed_event_webhook"` + TotalSuccessfulStatsWebhook int64 `json:"total_successful_stats_webhook"` + TotalFailedStatsWebhook int64 `json:"total_failed_stats_webhook"` } type soraClientStatistics struct { diff --git a/collector/webhook.go b/collector/webhook.go index 44c5a89..d7c5cee 100644 --- a/collector/webhook.go +++ b/collector/webhook.go @@ -8,6 +8,7 @@ var ( totalAuthWebhook: newDescWithLabel("auth_webhook_total", "The total number of auth webhook.", []string{"state"}), totalSessionWebhook: newDescWithLabel("session_webhook_total", "The total number of session webhook.", []string{"state"}), totalEventWebhook: newDescWithLabel("event_webhook_total", "The total number of event webhook.", []string{"state"}), + totalStatsWebhook: newDescWithLabel("stats_webhook_total", "The total number of stats webhook.", []string{"state"}), } ) @@ -16,6 +17,7 @@ type WebhookMetrics struct { totalAuthWebhook *prometheus.Desc totalSessionWebhook *prometheus.Desc totalEventWebhook *prometheus.Desc + totalStatsWebhook *prometheus.Desc } func (m *WebhookMetrics) Describe(ch chan<- *prometheus.Desc) { @@ -23,6 +25,7 @@ func (m *WebhookMetrics) Describe(ch chan<- *prometheus.Desc) { ch <- m.totalAuthWebhook ch <- m.totalSessionWebhook ch <- m.totalEventWebhook + ch <- m.totalStatsWebhook } func (m *WebhookMetrics) Collect(ch chan<- prometheus.Metric, report soraWebhookReport) { @@ -34,4 +37,6 @@ func (m *WebhookMetrics) Collect(ch chan<- prometheus.Metric, report soraWebhook ch <- newCounter(m.totalSessionWebhook, float64(report.TotalFailedSessionWebhook), "failed") ch <- newCounter(m.totalEventWebhook, float64(report.TotalSuccessfulEventWebhook), "successful") ch <- newCounter(m.totalEventWebhook, float64(report.TotalFailedEventWebhook), "failed") + ch <- newCounter(m.totalStatsWebhook, float64(report.TotalSuccessfulStatsWebhook), "successful") + ch <- newCounter(m.totalStatsWebhook, float64(report.TotalFailedStatsWebhook), "failed") } diff --git a/main_test.go b/main_test.go index e8c88cc..40c1b1e 100644 --- a/main_test.go +++ b/main_test.go @@ -153,6 +153,7 @@ var ( "total_failed_connections": 0, "total_failed_event_webhook": 94, "total_failed_session_webhook": 95, + "total_failed_stats_webhook": 99, "total_ongoing_connections": 0, "total_received_invalid_turn_tcp_packet": 0, "total_session_created": 1, @@ -161,6 +162,7 @@ var ( "total_successful_connections": 2, "total_successful_event_webhook": 97, "total_successful_session_webhook": 98, + "total_successful_stats_webhook": 100, "total_turn_tcp_connections": 2, "total_turn_udp_connections": 0, "version": "2022.1.0-canary.28" @@ -398,6 +400,7 @@ func TestMinimumMetrics(t *testing.T) { "total_failed_connections": 100, "total_failed_event_webhook": 94, "total_failed_session_webhook": 95, + "total_failed_stats_webhook": 99, "total_ongoing_connections": 88, "total_received_invalid_turn_tcp_packet": 123, "total_session_created": 111, @@ -406,6 +409,7 @@ func TestMinimumMetrics(t *testing.T) { "total_successful_connections": 333, "total_successful_event_webhook": 97, "total_successful_session_webhook": 98, + "total_successful_stats_webhook": 100, "total_turn_tcp_connections": 444, "total_turn_udp_connections": 555, "version": "2022.1.0-canary.28" diff --git a/test/maximum.metrics b/test/maximum.metrics index e7330ef..1138339 100644 --- a/test/maximum.metrics +++ b/test/maximum.metrics @@ -191,6 +191,10 @@ sora_session_total{state="destroyed"} 0 # TYPE sora_session_webhook_total counter sora_session_webhook_total{state="failed"} 95 sora_session_webhook_total{state="successful"} 98 +# HELP sora_stats_webhook_total The total number of stats webhook. +# TYPE sora_stats_webhook_total counter +sora_stats_webhook_total{state="failed"} 99 +sora_stats_webhook_total{state="successful"} 100 # HELP sora_successful_auth_webhook_total The total number of successful auth webhook. # TYPE sora_successful_auth_webhook_total counter sora_successful_auth_webhook_total{state="allowed"} 91 diff --git a/test/minimum.metrics b/test/minimum.metrics index 6be8558..b88e5dd 100644 --- a/test/minimum.metrics +++ b/test/minimum.metrics @@ -45,6 +45,10 @@ sora_session_total{state="destroyed"} 222 # TYPE sora_session_webhook_total counter sora_session_webhook_total{state="failed"} 95 sora_session_webhook_total{state="successful"} 98 +# HELP sora_stats_webhook_total The total number of stats webhook. +# TYPE sora_stats_webhook_total counter +sora_stats_webhook_total{state="failed"} 99 +sora_stats_webhook_total{state="successful"} 100 # HELP sora_successful_auth_webhook_total The total number of successful auth webhook. # TYPE sora_successful_auth_webhook_total counter sora_successful_auth_webhook_total{state="allowed"} 91 diff --git a/test/sora_client_enabled.metrics b/test/sora_client_enabled.metrics index 6498602..0b2877a 100644 --- a/test/sora_client_enabled.metrics +++ b/test/sora_client_enabled.metrics @@ -76,6 +76,10 @@ sora_session_total{state="destroyed"} 0 # TYPE sora_session_webhook_total counter sora_session_webhook_total{state="failed"} 95 sora_session_webhook_total{state="successful"} 98 +# HELP sora_stats_webhook_total The total number of stats webhook. +# TYPE sora_stats_webhook_total counter +sora_stats_webhook_total{state="failed"} 99 +sora_stats_webhook_total{state="successful"} 100 # HELP sora_successful_auth_webhook_total The total number of successful auth webhook. # TYPE sora_successful_auth_webhook_total counter sora_successful_auth_webhook_total{state="allowed"} 91 diff --git a/test/sora_cluster_metrics_enabled.metrics b/test/sora_cluster_metrics_enabled.metrics index 15648b5..d62ef9a 100644 --- a/test/sora_cluster_metrics_enabled.metrics +++ b/test/sora_cluster_metrics_enabled.metrics @@ -78,6 +78,10 @@ sora_session_total{state="destroyed"} 0 # TYPE sora_session_webhook_total counter sora_session_webhook_total{state="failed"} 95 sora_session_webhook_total{state="successful"} 98 +# HELP sora_stats_webhook_total The total number of stats webhook. +# TYPE sora_stats_webhook_total counter +sora_stats_webhook_total{state="failed"} 99 +sora_stats_webhook_total{state="successful"} 100 # HELP sora_successful_auth_webhook_total The total number of successful auth webhook. # TYPE sora_successful_auth_webhook_total counter sora_successful_auth_webhook_total{state="allowed"} 91 diff --git a/test/sora_connection_error_enabled.metrics b/test/sora_connection_error_enabled.metrics index 0b816d8..105a911 100644 --- a/test/sora_connection_error_enabled.metrics +++ b/test/sora_connection_error_enabled.metrics @@ -52,6 +52,10 @@ sora_session_total{state="destroyed"} 0 # TYPE sora_session_webhook_total counter sora_session_webhook_total{state="failed"} 95 sora_session_webhook_total{state="successful"} 98 +# HELP sora_stats_webhook_total The total number of stats webhook. +# TYPE sora_stats_webhook_total counter +sora_stats_webhook_total{state="failed"} 99 +sora_stats_webhook_total{state="successful"} 100 # HELP sora_successful_auth_webhook_total The total number of successful auth webhook. # TYPE sora_successful_auth_webhook_total counter sora_successful_auth_webhook_total{state="allowed"} 91 diff --git a/test/sora_erlang_vm_enabled.metrics b/test/sora_erlang_vm_enabled.metrics index 45b94e5..0d91a4e 100644 --- a/test/sora_erlang_vm_enabled.metrics +++ b/test/sora_erlang_vm_enabled.metrics @@ -129,6 +129,10 @@ sora_session_total{state="destroyed"} 0 # TYPE sora_session_webhook_total counter sora_session_webhook_total{state="failed"} 95 sora_session_webhook_total{state="successful"} 98 +# HELP sora_stats_webhook_total The total number of stats webhook. +# TYPE sora_stats_webhook_total counter +sora_stats_webhook_total{state="failed"} 99 +sora_stats_webhook_total{state="successful"} 100 # HELP sora_successful_auth_webhook_total The total number of successful auth webhook. # TYPE sora_successful_auth_webhook_total counter sora_successful_auth_webhook_total{state="allowed"} 91