Skip to content

Commit

Permalink
Move enabling metric persistence to core module prep phase
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed Oct 12, 2023
1 parent 48bccad commit 5616d98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 1 addition & 8 deletions core/base/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ package base

import (
_ "github.com/safing/portbase/config"
"github.com/safing/portbase/log"
"github.com/safing/portbase/metrics"
"github.com/safing/portbase/modules"
_ "github.com/safing/portbase/rng"
)

var module *modules.Module

func init() {
module = modules.Register("base", nil, start, nil, "database", "config", "rng", "metrics")
module = modules.Register("base", nil, start, nil, "database", "config", "rng")

// For prettier subsystem graph, printed with --print-subsystem-graph
/*
Expand All @@ -33,11 +31,6 @@ func start() error {
return err
}

// Set metrics storage key and load them from db.
if err := metrics.EnableMetricPersistence("core:metrics/storage"); err != nil {
log.Warningf("core: failed to load persisted metrics from db: %s", err)
}

registerLogCleaner()

return nil
Expand Down
9 changes: 8 additions & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"
"time"

"github.com/safing/portbase/log"
"github.com/safing/portbase/metrics"
"github.com/safing/portbase/modules"
"github.com/safing/portbase/modules/subsystems"
_ "github.com/safing/portmaster/broadcasts"
Expand All @@ -27,7 +29,7 @@ var (
)

func init() {
module = modules.Register("core", prep, start, nil, "base", "subsystems", "status", "updates", "api", "notifications", "ui", "netenv", "network", "netquery", "interception", "compat", "broadcasts")
module = modules.Register("core", prep, start, nil, "base", "subsystems", "status", "updates", "api", "notifications", "ui", "netenv", "network", "netquery", "interception", "compat", "broadcasts", "metrics")
subsystems.Register(
"core",
"Core",
Expand Down Expand Up @@ -60,6 +62,11 @@ func prep() error {
return err
}

// Enable persistent metrics.
if err := metrics.EnableMetricPersistence("core:metrics/storage"); err != nil {
log.Warningf("core: failed to enable persisted metrics: %s", err)
}

return nil
}

Expand Down

0 comments on commit 5616d98

Please sign in to comment.