mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-01 03:03:10 -06:00
Add version & monolith stats
This commit is contained in:
parent
e1eaa74f8b
commit
5ffb386a25
|
|
@ -31,6 +31,7 @@ func SyncAPI(base *basepkg.BaseDendrite, cfg *config.Dendrite) {
|
||||||
base.PublicClientAPIMux, userAPI, rsAPI,
|
base.PublicClientAPIMux, userAPI, rsAPI,
|
||||||
base.KeyServerHTTPClient(),
|
base.KeyServerHTTPClient(),
|
||||||
federation, &cfg.SyncAPI, cfg,
|
federation, &cfg.SyncAPI, cfg,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
|
|
||||||
base.SetupAndServeHTTP(
|
base.SetupAndServeHTTP(
|
||||||
|
|
|
||||||
|
|
@ -72,5 +72,6 @@ func (m *Monolith) AddAllPublicRoutes(process *process.ProcessContext, csMux, ss
|
||||||
syncapi.AddPublicRoutes(
|
syncapi.AddPublicRoutes(
|
||||||
process, csMux, m.UserAPI, m.RoomserverAPI,
|
process, csMux, m.UserAPI, m.RoomserverAPI,
|
||||||
m.KeyAPI, m.FedClient, &m.Config.SyncAPI, m.Config,
|
m.KeyAPI, m.FedClient, &m.Config.SyncAPI, m.Config,
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
"github.com/matrix-org/dendrite/internal"
|
||||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
|
@ -55,6 +56,7 @@ func AddPublicRoutes(
|
||||||
federation *gomatrixserverlib.FederationClient,
|
federation *gomatrixserverlib.FederationClient,
|
||||||
cfg *config.SyncAPI,
|
cfg *config.SyncAPI,
|
||||||
baseCfg *config.Dendrite,
|
baseCfg *config.Dendrite,
|
||||||
|
isMonolith bool,
|
||||||
) {
|
) {
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
js := jetstream.Prepare(&cfg.Matrix.JetStream)
|
js := jetstream.Prepare(&cfg.Matrix.JetStream)
|
||||||
|
|
@ -119,7 +121,7 @@ func AddPublicRoutes(
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add config
|
// TODO: add config
|
||||||
go startPhoneHomeCollector(startTime, baseCfg, syncDB, userAPI)
|
go startPhoneHomeCollector(startTime, baseCfg, syncDB, userAPI, isMonolith)
|
||||||
|
|
||||||
routing.Setup(router, requestPool, syncDB, userAPI, federation, rsAPI, cfg)
|
routing.Setup(router, requestPool, syncDB, userAPI, federation, rsAPI, cfg)
|
||||||
}
|
}
|
||||||
|
|
@ -132,6 +134,7 @@ type phoneHomeStats struct {
|
||||||
startTime time.Time
|
startTime time.Time
|
||||||
cfg *config.Dendrite
|
cfg *config.Dendrite
|
||||||
db storage.Database
|
db storage.Database
|
||||||
|
isMonolith bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type timestampToRUUsage struct {
|
type timestampToRUUsage struct {
|
||||||
|
|
@ -139,7 +142,7 @@ type timestampToRUUsage struct {
|
||||||
usage syscall.Rusage
|
usage syscall.Rusage
|
||||||
}
|
}
|
||||||
|
|
||||||
func startPhoneHomeCollector(startTime time.Time, cfg *config.Dendrite, syncDB storage.Database, userAPI userapi.UserInternalAPI) {
|
func startPhoneHomeCollector(startTime time.Time, cfg *config.Dendrite, syncDB storage.Database, userAPI userapi.UserInternalAPI, isMonolith bool) {
|
||||||
|
|
||||||
p := phoneHomeStats{
|
p := phoneHomeStats{
|
||||||
stats: make(map[string]interface{}),
|
stats: make(map[string]interface{}),
|
||||||
|
|
@ -148,6 +151,7 @@ func startPhoneHomeCollector(startTime time.Time, cfg *config.Dendrite, syncDB s
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
db: syncDB,
|
db: syncDB,
|
||||||
userAPI: userAPI,
|
userAPI: userAPI,
|
||||||
|
isMonolith: isMonolith,
|
||||||
}
|
}
|
||||||
|
|
||||||
// start initial run after 5min
|
// start initial run after 5min
|
||||||
|
|
@ -169,6 +173,8 @@ func startPhoneHomeCollector(startTime time.Time, cfg *config.Dendrite, syncDB s
|
||||||
func (p *phoneHomeStats) collect() {
|
func (p *phoneHomeStats) collect() {
|
||||||
p.stats = make(map[string]interface{})
|
p.stats = make(map[string]interface{})
|
||||||
p.stats["servername"] = p.serverName
|
p.stats["servername"] = p.serverName
|
||||||
|
p.stats["monolith"] = p.isMonolith
|
||||||
|
p.stats["version"] = internal.VersionString()
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.TODO(), time.Minute*1)
|
ctx, cancel := context.WithTimeout(context.TODO(), time.Minute*1)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ GROUP BY client_type
|
||||||
`
|
`
|
||||||
|
|
||||||
const countUserByAccountTypeSQL = `
|
const countUserByAccountTypeSQL = `
|
||||||
SELECT COUNT(*) FROM account_accounts WHERE account_type = $1
|
SELECT COUNT(*) FROM account_accounts WHERE account_type = ANY($1)
|
||||||
`
|
`
|
||||||
|
|
||||||
const countRegisteredUserByTypeStmt = `
|
const countRegisteredUserByTypeStmt = `
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue