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

Add builder demotion metrics #624

Merged
merged 1 commit into from
May 22, 2024
Merged
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
15 changes: 15 additions & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var (
GetPayloadLatencyHistogram otelapi.Float64Histogram
PublishBlockLatencyHistogram otelapi.Float64Histogram

BuilderDemotionCount otelapi.Int64Counter

latencyBoundaries = otelapi.WithExplicitBucketBoundaries(func() []float64 {
base := math.Exp(math.Log(12.0) / 15.0)
res := make([]float64, 0, 31)
Expand All @@ -37,6 +39,7 @@ func Setup(ctx context.Context) error {
setupMeter, // must come first
setupGetPayloadLatency,
setupPublishBlockLatency,
setupBuilderDemotionCount,
} {
if err := setup(ctx); err != nil {
return err
Expand Down Expand Up @@ -98,3 +101,15 @@ func setupPublishBlockLatency(ctx context.Context) error {
}
return nil
}

func setupBuilderDemotionCount(ctx context.Context) error {
counter, err := meter.Int64Counter(
"builder_demotion_count",
otelapi.WithDescription("number of times a builder has been demoted"),
)
BuilderDemotionCount = counter
if err != nil {
return err
}
return nil
}
8 changes: 8 additions & 0 deletions services/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@ func (api *RelayAPI) StartServer() (err error) {

// start block-builder API specific things
if api.opts.BlockBuilderAPI {
// Initialize metrics
metrics.BuilderDemotionCount.Add(context.Background(), 0)

// Get current proposer duties blocking before starting, to have them ready
api.updateProposerDuties(syncStatus.HeadSlot)

Expand Down Expand Up @@ -600,6 +603,11 @@ func (api *RelayAPI) simulateBlock(ctx context.Context, opts blockSimOptions) (r
}

func (api *RelayAPI) demoteBuilder(pubkey string, req *common.VersionedSubmitBlockRequest, simError error) {
metrics.BuilderDemotionCount.Add(
context.Background(),
1,
)

builderEntry, ok := api.blockBuildersCache[pubkey]
if !ok {
api.log.Warnf("builder %v not in the builder cache", pubkey)
Expand Down
Loading