Browse Source

chore(ursrv): count database engines

Jakob Borg 1 month ago
parent
commit
3da449cfa3
2 changed files with 14 additions and 0 deletions
  1. 7 0
      cmd/infra/ursrv/serve/serve.go
  2. 7 0
      lib/ur/contract/contract.go

+ 7 - 0
cmd/infra/ursrv/serve/serve.go

@@ -381,6 +381,13 @@ func (s *server) addReport(rep *contract.Report) bool {
 	rep.DistOS = rep.OS
 	rep.DistArch = rep.Arch
 
+	if strings.HasPrefix(rep.Version, "v2.") {
+		rep.Database.ModernCSQLite = strings.Contains(rep.LongVersion, "modernc-sqlite")
+		rep.Database.MattnSQLite = !rep.Database.ModernCSQLite
+	} else {
+		rep.Database.LevelDB = true
+	}
+
 	_, loaded := s.reports.LoadAndStore(rep.UniqueID, rep)
 	return loaded
 }

+ 7 - 0
lib/ur/contract/contract.go

@@ -188,6 +188,13 @@ type Report struct {
 	DistDist string `json:"distDist" metric:"distribution,gaugeVec:distribution"`
 	DistOS   string `json:"distOS" metric:"distribution,gaugeVec:os"`
 	DistArch string `json:"distArch" metric:"distribution,gaugeVec:arch"`
+
+	// Database counts
+	Database struct {
+		ModernCSQLite bool `json:"modernCSQLite" metric:"database_engine{engine=modernc-sqlite},gauge"`
+		MattnSQLite   bool `json:"mattnSQLite" metric:"database_engine{engine=mattn-sqlite},gauge"`
+		LevelDB       bool `json:"levelDB" metric:"database_engine{engine=leveldb},gauge"`
+	} `json:"database"`
 }
 
 func New() *Report {