Skip to content

Commit

Permalink
Merge branch 'release/2022.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
voluntas committed Jun 9, 2022
2 parents 1df7f23 + 691e2d7 commit a44445a
Show file tree
Hide file tree
Showing 30 changed files with 954 additions and 1,491 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -53,7 +53,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -67,4 +67,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release Build

on:
push:
tags:
- '*'

jobs:

build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '^1.18'

- run: go install github.com/tcnksm/ghr@latest

- name: Build
run: |
GOOS=linux GOARCH=amd64 go build -o dist/kohaku_linux_amd64 cmd/kohaku/main.go
GOOS=darwin GOARCH=amd64 go build -o dist/kohaku_darwin_amd64 cmd/kohaku/main.go
GOOS=darwin GOARCH=arm64 go build -o dist/kohaku_darwin_arm64 cmd/kohaku/main.go
gzip dist/*
- name: Release
run: |
ghr -t "${{ secrets.GITHUB_TOKEN }}" -u "${{ github.repository_owner }}" -r "kohaku" --replace "${GITHUB_REF##*/}" dist/
11 changes: 6 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@ jobs:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.17.5
go-version: "^1.18"

- run: go version

- run: go fmt .

- uses: dominikh/staticcheck-action@v1.1.0
- uses: dominikh/staticcheck-action@v1.2.0
with:
version: "2021.1.2"
version: "2022.1"
install-go: false

- name: Test
run: GIN_MODE=release make test
Expand Down
21 changes: 21 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@

## develop

## 2021.2.0

- [CHANGE] kohaku の設定ファイルのパス指定のデフォルトを ../config.yaml から ./config.yaml に変更する
- @Hexa
- [CHANGE] query.sql と schema.sql を db/ 以下へ移動
- @voluntas
- [CHANGE] sqlc のコード生成を gen/sqlc 以下へ移動
- @voluntas
- [CHANGE] echo 化
- @Hexa @voluntas
- [CHANGE] Erlang VM 関連の統計を削除する
- [Sora exporter](https://github.com/shiguredo/sora_exporter) で対応したため不要になった
- @voluntas
- [UPDATE] テスト用 TimescaleDB を latest:pg14 に変更する
- @Hexa
- [UPDATE] Github Actions go のバージョンを v3 にあげる
- バージョンを `^1.18` にする
- @Hexa
- [UPDATE] Github Actions chekcout のバージョンを v3 にあげる
- @Hexa

## 2021.1.0

**祝リリース**
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ clean:
rm -rf ./kohaku.log

test:
go test -v
go test -race -v
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@ Please read https://github.com/shiguredo/oss/blob/master/README.en.md before use

## WebRTC Stats Collector Kohaku について

Kohaku はクライアントと Sora の統計情報を Sora から HTTP/2 経由で受け取り、整理してタイムシリーズデータベースに格納するゲートウェイです。現時点ではタイムシリーズデータベースは TimescaleDB のみに対応しています。

## 特徴

- Sora から HTTP/2 経由でクライアントや Sora の統計情報を受け取り TimescaleDB (TSDB) に格納します
- [WebRTC 統計 API](https://www.w3.org/TR/webrtc-stats/) に対応しています
- ブラウザは最新 Chrome / Firefox / Safari / Edge へ対応
- Sora SDK は iOS / Android / Unity すべてに対応
- WebRTC Native Client Momo に対応
- クライアントは Sora に統計情報を送るだけでよくなるため、どこかのサーバに対して接続などが不要になります
- すべての統計情報を Sora の Channel ID と Connection ID と関連付けて保存するため問題の追跡がしやすくなります

## 使ってみる

Kohaku を使ってみたい人は [USE.md](https://github.com/shiguredo/kohaku/blob/develop/doc/USE.md) をお読みください。

## 開発ログ

[時雨堂 WebRTC Stats Collector Kohaku 開発ログ](https://gist.github.com/voluntas/f162f7f513ef83051e46dc405cad6a04)

## ライセンス
Expand Down Expand Up @@ -47,3 +65,8 @@ limitations under the License.
**詳細は Discord やメールなどでお気軽にお問い合わせください**

- AWS Timestream 対応

## 記事

- [\[備忘録\] WebRTC Stats Collector Kohakuを触ってみた](https://zenn.dev/adaniya/articles/1a06e22a23927b)
- 導入からグラフ化までを一通り試した良記事
40 changes: 12 additions & 28 deletions collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,30 @@ package kohaku
import (
"net/http"

"github.com/gin-gonic/gin"
"github.com/labstack/echo/v4"
zlog "github.com/rs/zerolog/log"
)

// TODO: ログレベル、ログメッセージを変更する
func (s *Server) collector(c *gin.Context) {
t := c.Request.Header.Get("x-sora-stats-exporter-type")
func (s *Server) collector(c echo.Context) error {
t := c.Request().Header.Get("x-sora-stats-exporter-type")
switch t {
case "connection.user-agent":
// TODO(v): validator 処理
stats := new(soraConnectionStats)
if err := c.Bind(stats); err != nil {
zlog.Debug().Str("type", t).Err(err).Msg("")
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
zlog.Debug().Str("type", t).Err(err).Send()
return echo.NewHTTPError(http.StatusBadRequest, err.Error())
}
if err := s.collectorUserAgentStats(c, *stats); err != nil {
zlog.Warn().Str("type", t).Err(err).Msg("")
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
c.Status(http.StatusNoContent)
return
case "node.erlang-vm":
stats := new(soraNodeErlangVMStats)
if err := c.Bind(stats); err != nil {
zlog.Debug().Str("type", t).Err(err).Msg("")
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
if err := c.Validate(stats); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, err.Error())
}

if err := s.collectorSoraNodeErlangVMStats(c, *stats); err != nil {
zlog.Warn().Str("type", t).Err(err).Msg("")
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
if err := s.collectorUserAgentStats(c, *stats); err != nil {
zlog.Warn().Str("type", t).Err(err).Send()
return echo.NewHTTPError(http.StatusBadRequest, err.Error())
}
c.Status(http.StatusNoContent)
return
return c.NoContent(http.StatusNoContent)
default:
zlog.Warn().Str("type", t).Msgf("UNEXPECTED-TYPE")
c.Status(http.StatusBadRequest)
return echo.NewHTTPError(http.StatusBadRequest)
}
}
Loading

0 comments on commit a44445a

Please sign in to comment.