feat: add metric plugin (#361)

This commit is contained in:
boojack
2022-10-29 11:15:39 +08:00
committed by GitHub
parent 30daea0c4f
commit 95376f78f6
13 changed files with 157 additions and 5 deletions

View File

@ -8,6 +8,7 @@ import (
"context"
"fmt"
metric "github.com/usememos/memos/plugin/metrics"
"github.com/usememos/memos/server"
"github.com/usememos/memos/server/profile"
"github.com/usememos/memos/store"
@ -34,15 +35,20 @@ func run(profile *profile.Profile) error {
return fmt.Errorf("cannot open db: %w", err)
}
s := server.NewServer(profile)
serverInstance := server.NewServer(profile)
storeInstance := store.New(db.Db, profile)
s.Store = storeInstance
serverInstance.Store = storeInstance
metricCollector := server.NewMetricCollector(profile, storeInstance)
serverInstance.Collector = &metricCollector
println(greetingBanner)
fmt.Printf("Version %s has started at :%d\n", profile.Version, profile.Port)
metricCollector.Collect(ctx, &metric.Metric{
Name: "servive started",
})
return s.Run()
return serverInstance.Run()
}
func execute() error {