Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/db layer metrics #616

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/moira-alert/moira"
"github.com/moira-alert/moira/api/handler"
"github.com/moira-alert/moira/cmd"
db "github.com/moira-alert/moira/database"
"github.com/moira-alert/moira/database/redis"
"github.com/moira-alert/moira/index"
logging "github.com/moira-alert/moira/logging/zerolog_adapter"
Expand Down Expand Up @@ -76,7 +77,8 @@ func main() {
defer telemetry.Stop()

databaseSettings := config.Redis.GetSettings()
database := redis.NewDatabase(logger, databaseSettings, redis.API)
redis := redis.NewDatabase(logger, databaseSettings, redis.API)
database := db.NewDatabaseWithMetrics(redis, "redis", &telemetry.Metrics)

// Start Index right before HTTP listener. Fail if index cannot start
searchIndex := index.NewSearchIndex(logger, database, telemetry.Metrics)
Expand Down
4 changes: 3 additions & 1 deletion cmd/checker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/moira-alert/moira/checker"
"github.com/moira-alert/moira/checker/worker"
"github.com/moira-alert/moira/cmd"
db "github.com/moira-alert/moira/database"
"github.com/moira-alert/moira/database/redis"
logging "github.com/moira-alert/moira/logging/zerolog_adapter"
"github.com/moira-alert/moira/metrics"
Expand Down Expand Up @@ -75,7 +76,8 @@ func main() {
defer telemetry.Stop()

databaseSettings := config.Redis.GetSettings()
database := redis.NewDatabase(logger, databaseSettings, redis.Checker)
redis := redis.NewDatabase(logger, databaseSettings, redis.Checker)
database := db.NewDatabaseWithMetrics(redis, "redis", &telemetry.Metrics)

remoteConfig := config.Remote.GetRemoteSourceSettings()
localSource := local.Create(database)
Expand Down
4 changes: 3 additions & 1 deletion cmd/filter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/moira-alert/moira"
"github.com/moira-alert/moira/cmd"
db "github.com/moira-alert/moira/database"
"github.com/moira-alert/moira/database/redis"
"github.com/moira-alert/moira/filter"
"github.com/moira-alert/moira/filter/connection"
Expand Down Expand Up @@ -78,7 +79,8 @@ func main() {
}

filterMetrics := metrics.ConfigureFilterMetrics(telemetry.Metrics)
database := redis.NewDatabase(logger, config.Redis.GetSettings(), redis.Filter)
redis := redis.NewDatabase(logger, config.Redis.GetSettings(), redis.Filter)
database := db.NewDatabaseWithMetrics(redis, "redis", &telemetry.Metrics)

retentionConfigFile, err := os.Open(config.Filter.RetentionConfig)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion cmd/notifier/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/moira-alert/moira"
"github.com/moira-alert/moira/cmd"
db "github.com/moira-alert/moira/database"
"github.com/moira-alert/moira/database/redis"
logging "github.com/moira-alert/moira/logging/zerolog_adapter"
"github.com/moira-alert/moira/metrics"
Expand Down Expand Up @@ -75,7 +76,8 @@ func main() {

notifierMetrics := metrics.ConfigureNotifierMetrics(telemetry.Metrics, serviceName)
databaseSettings := config.Redis.GetSettings()
database := redis.NewDatabase(logger, databaseSettings, redis.Notifier)
redis := redis.NewDatabase(logger, databaseSettings, redis.Notifier)
database := db.NewDatabaseWithMetrics(redis, "redis", &telemetry.Metrics)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"redis" is not a good prefix for metrics. We have a metrics prefix that is set in config files. Each service adds its own name to prefix. Let's use this as prefix


localSource := local.Create(database)
remoteConfig := config.Remote.GetRemoteSourceSettings()
Expand Down
Loading