Skip to content

Commit

Permalink
fix(metrics): version wasn't being properly reported (#1321)
Browse files Browse the repository at this point in the history
* bet

* bet

* bet

* bet
  • Loading branch information
itsdevbear committed Jun 5, 2024
1 parent bd33e2d commit 556e3c8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
3 changes: 2 additions & 1 deletion mod/execution/pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,9 @@ func (s *EngineClient[ExecutionPayloadT]) buildJWTHeader() (http.Header, error)
return header, nil
}

// Name returns the name of the engine client.
func (s *EngineClient[ExecutionPayloadT]) Name() string {
return "EngineClient"
return "engine-client"
}

// ================================ Info ================================
Expand Down
9 changes: 7 additions & 2 deletions mod/node-builder/pkg/services/version/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ func newVersionMetrics(

// reportVersion increments the versionReported counter.
func (vm *versionMetrics) reportVersion(version string) {
vm.logger.Info("this node is running", "version", version)
vm.logger.Info(
"this node is running beacon-kit software",
"version",
version,
)
vm.sink.IncrementCounter(
"beacon_kit.runtime.version.reported", "version", version)
"beacon_kit.runtime.version.reported", "version", version,
)
}
25 changes: 13 additions & 12 deletions mod/node-builder/pkg/services/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ type ReportingService struct {
logger log.Logger[any]
// version represents the current version of the running chain.
version string
// ticker is used to trigger periodic logging at specified intervals.
ticker *time.Ticker
// reportingInterval is the interval at which the version is reported.
reportingInterval time.Duration
// metrics contains the metrics for the version service.
metrics *versionMetrics
}
Expand All @@ -51,30 +51,31 @@ func NewReportingService(
version string,
) *ReportingService {
return &ReportingService{
logger: logger,
version: version,
ticker: time.NewTicker(
defaultReportingInterval,
),
metrics: newVersionMetrics(logger, telemetrySink),
logger: logger,
version: version,
reportingInterval: defaultReportingInterval,
metrics: newVersionMetrics(logger, telemetrySink),
}
}

// Name returns the name of the service.
func (*ReportingService) Name() string {
return "ReportingService"
return "reporting"
}

// Start begins the periodic logging of the chain version.
func (v *ReportingService) Start(ctx context.Context) error {
ticker := time.NewTicker(v.reportingInterval)
v.metrics.reportVersion(v.version)
go func() {
for {
select {
case <-ticker.C:
v.metrics.reportVersion(v.version)
continue
case <-ctx.Done():
v.ticker.Stop()
ticker.Stop()
return
case <-v.ticker.C:
v.metrics.reportVersion(v.version)
}
}
}()
Expand Down
2 changes: 1 addition & 1 deletion mod/storage/pkg/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func NewDBManager[
func (m *DBManager[
BeaconBlockT, BlockEventT, SubscriptionT,
]) Name() string {
return "DBManager"
return "db-manager"
}

// TODO: fr implementation
Expand Down

0 comments on commit 556e3c8

Please sign in to comment.