mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
fix(metrics): write system metrics on start (#3641)
* fix(metrics): write system metrics on start * add broken basic auth test * refactor: simplify Prometheus instantiation Signed-off-by: Deluan <deluan@navidrome.org> * fix: basic authentication Signed-off-by: Deluan <deluan@navidrome.org> * refactor: move magic strings to constants Signed-off-by: Deluan <deluan@navidrome.org> * refactor: simplify prometheus http handler Signed-off-by: Deluan <deluan@navidrome.org> * add artist metadata to aggregrate sql --------- Signed-off-by: Deluan <deluan@navidrome.org> Co-authored-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
537e2fc033
commit
3179966270
10 changed files with 142 additions and 77 deletions
|
@ -53,6 +53,7 @@ type scanner struct {
|
|||
pls core.Playlists
|
||||
broker events.Broker
|
||||
cacheWarmer artwork.CacheWarmer
|
||||
metrics metrics.Metrics
|
||||
}
|
||||
|
||||
type scanStatus struct {
|
||||
|
@ -62,7 +63,7 @@ type scanStatus struct {
|
|||
lastUpdate time.Time
|
||||
}
|
||||
|
||||
func GetInstance(ds model.DataStore, playlists core.Playlists, cacheWarmer artwork.CacheWarmer, broker events.Broker) Scanner {
|
||||
func GetInstance(ds model.DataStore, playlists core.Playlists, cacheWarmer artwork.CacheWarmer, broker events.Broker, metrics metrics.Metrics) Scanner {
|
||||
return singleton.GetInstance(func() *scanner {
|
||||
s := &scanner{
|
||||
ds: ds,
|
||||
|
@ -73,6 +74,7 @@ func GetInstance(ds model.DataStore, playlists core.Playlists, cacheWarmer artwo
|
|||
status: map[string]*scanStatus{},
|
||||
lock: &sync.RWMutex{},
|
||||
cacheWarmer: cacheWarmer,
|
||||
metrics: metrics,
|
||||
}
|
||||
s.loadFolders()
|
||||
return s
|
||||
|
@ -210,10 +212,10 @@ func (s *scanner) RescanAll(ctx context.Context, fullRescan bool) error {
|
|||
}
|
||||
if hasError {
|
||||
log.Error(ctx, "Errors while scanning media. Please check the logs")
|
||||
metrics.WriteAfterScanMetrics(ctx, s.ds, false)
|
||||
s.metrics.WriteAfterScanMetrics(ctx, false)
|
||||
return ErrScanError
|
||||
}
|
||||
metrics.WriteAfterScanMetrics(ctx, s.ds, true)
|
||||
s.metrics.WriteAfterScanMetrics(ctx, true)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue