Skip to content

Commit ebe893f

Browse files
invis-bitflyguybrush
authored andcommitted
refactor(monitoring): allow disabling of certain healthz checks over config
1 parent 083773c commit ebe893f

File tree

5 files changed

+24
-10
lines changed

5 files changed

+24
-10
lines changed

backend/pkg/api/data_access/healthz.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/gobitfly/beaconchain/pkg/commons/log"
1111
"github.com/gobitfly/beaconchain/pkg/commons/utils"
1212
"github.com/gobitfly/beaconchain/pkg/monitoring/constants"
13+
monitoringServices "github.com/gobitfly/beaconchain/pkg/monitoring/services"
1314
)
1415

1516
type HealthzRepository interface {
@@ -128,10 +129,7 @@ func (d *DataAccessService) GetHealthz(ctx context.Context, showAll bool) types.
128129
for _, result := range results {
129130
response.Reports[result.EventId] = append(response.Reports[result.EventId], result)
130131
}
131-
requiredEvents := constants.RequiredEvents
132-
if utils.Config.DeploymentType == "production" {
133-
requiredEvents = append(requiredEvents, constants.ProductionRequiredEvents...)
134-
}
132+
requiredEvents := monitoringServices.GetRequiredEvents()
135133
for _, id := range requiredEvents {
136134
if _, ok := response.Reports[string(id)]; !ok {
137135
response.Reports[string(id)] = []types.HealthzResult{

backend/pkg/exporter/modules/pubkey_tags.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import (
1212

1313
func UpdatePubkeyTag() {
1414
log.Infof("Started Pubkey Tags Updater")
15+
delay := time.Minute * 10
1516
for {
1617
start := time.Now()
17-
r := monitoringServices.NewStatusReport(constants.Event_ExporterLegacyPubkeyTags, constants.Default, time.Second*12)
18+
r := monitoringServices.NewStatusReport(constants.Event_ExporterLegacyPubkeyTags, delay, time.Second*12)
1819
r(constants.Running, nil)
1920
tx, err := db.WriterDb.Beginx()
2021
if err != nil {
@@ -45,6 +46,6 @@ func UpdatePubkeyTag() {
4546
r(constants.Success, map[string]string{"took": time.Since(start).String(), "took_raw": time.Since(start).String()})
4647
metrics.TaskDuration.WithLabelValues("validator_pubkey_tag_updater").Observe(time.Since(start).Seconds())
4748

48-
time.Sleep(time.Minute * 10)
49+
time.Sleep(delay)
4950
}
5051
}

backend/pkg/exporter/modules/rocketpool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func (rp *RocketpoolExporter) Run() error {
191191

192192
for {
193193
t0 := time.Now()
194-
r := monitoringServices.NewStatusReport(constants.Event_ExporterLegacyRocketPool, constants.Default, time.Second*12)
194+
r := monitoringServices.NewStatusReport(constants.Event_ExporterLegacyRocketPool, time.Hour*4, rp.UpdateInterval) // currently takes 2h40m on mainnet...
195195
r(constants.Running, nil)
196196
var err error
197197
err = rp.Update(count)

backend/pkg/monitoring/constants/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package constants
22

3-
import "time"
3+
import (
4+
"time"
5+
)
46

57
// status enum
68
type StatusType string
@@ -69,8 +71,6 @@ var ProductionRequiredEvents = []Event{
6971
Event_ExporterLegacyNetworkLiveness,
7072
Event_ExporterLegacySyncCommittees,
7173
Event_ExporterLegacySyncCommitteesCount,
72-
Event_ExporterLegacyRocketPool,
73-
Event_ExporterLegacyPubkeyTags,
7474
Event_ExporterModuleELRewardsFinalizer,
7575
Event_ExporterModuleELPayloadExporter,
7676
Event_ExporterModuleELDepositsExporter,

backend/pkg/monitoring/services/base.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,18 @@ func NewStatusReport(id constants.Event, timeout time.Duration, check_interval t
109109
}()
110110
}
111111
}
112+
113+
func GetRequiredEvents() []constants.Event {
114+
// i would hope this simple of a function doesnt need caching
115+
requiredEvents := constants.RequiredEvents
116+
if utils.Config.DeploymentType == "production" {
117+
requiredEvents = append(requiredEvents, constants.ProductionRequiredEvents...)
118+
}
119+
if utils.Config.RocketpoolExporter.Enabled {
120+
requiredEvents = append(requiredEvents, constants.Event_ExporterLegacyRocketPool)
121+
}
122+
if utils.Config.Indexer.PubKeyTagsExporter.Enabled {
123+
requiredEvents = append(requiredEvents, constants.Event_ExporterLegacyPubkeyTags)
124+
}
125+
return requiredEvents
126+
}

0 commit comments

Comments
 (0)