Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
avalonche committed May 24, 2024
1 parent 0309079 commit e95e2fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 36 deletions.
4 changes: 0 additions & 4 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ var (
GetPayloadLatencyHistogram otelapi.Float64Histogram
PublishBlockLatencyHistogram otelapi.Float64Histogram

GetHeaderCount otelapi.Int64Counter
GetPayloadCount otelapi.Int64Counter

SubmitNewBlockLatencyHistogram otelapi.Float64Histogram
SubmitNewBlockReadLatencyHistogram otelapi.Float64Histogram
SubmitNewBlockDecodeLatencyHistogram otelapi.Float64Histogram
Expand All @@ -37,7 +34,6 @@ var (
SubmitNewBlockRedisTopBidLatencyHistogram otelapi.Float64Histogram
SubmitNewBlockRedisFloorLatencyHistogram otelapi.Float64Histogram

SubmitNewBlockCount otelapi.Int64Counter
BuilderDemotionCount otelapi.Int64Counter

// latencyBoundariesMs is the set of buckets of exponentially growing
Expand Down
47 changes: 15 additions & 32 deletions services/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1183,23 +1183,10 @@ func (api *RelayAPI) handleGetHeader(w http.ResponseWriter, req *http.Request) {

log.Debug("getHeader request received")
defer func() {
s, err := strconv.ParseInt(slotStr, 10, 64)
if err != nil {
log.WithError(err).Error("could not parse slot to int64")
return
}
metrics.GetHeaderLatencyHistogram.Record(
req.Context(),
float64(time.Since(requestTime).Milliseconds()),
)
metrics.GetHeaderCount.Add(
req.Context(),
1,
otelapi.WithAttributes(
attribute.Int64("slot", s),
attribute.Int64("floorSecIntoSlot", msIntoSlot/1000),
),
)
}()

if slices.Contains(apiNoHeaderUserAgents, ua) {
Expand Down Expand Up @@ -1299,10 +1286,6 @@ func (api *RelayAPI) handleGetPayload(w http.ResponseWriter, req *http.Request)
req.Context(),
float64(time.Since(receivedAt).Milliseconds()),
)
metrics.GetPayloadCount.Add(
req.Context(),
1,
)
}()

// Read the body first, so we can decode it later
Expand Down Expand Up @@ -1904,7 +1887,7 @@ func (api *RelayAPI) handleSubmitNewBlock(w http.ResponseWriter, req *http.Reque
}).Info("request finished")

// metrics
api.saveBlockSubmissionMetrics(pf)
api.saveBlockSubmissionMetrics(pf, receivedAt)
}()

// If cancellations are disabled but builder requested it, return error
Expand Down Expand Up @@ -2269,20 +2252,7 @@ func (api *RelayAPI) handleSubmitNewBlock(w http.ResponseWriter, req *http.Reque
w.WriteHeader(http.StatusOK)
}

func (api *RelayAPI) saveBlockSubmissionMetrics(pf common.Profile) {
metrics.SubmitNewBlockCount.Add(
context.Background(),
1,
otelapi.WithAttributes(
attribute.String("contentType", pf.ContentType),
attribute.Bool("isGzip", pf.IsGzip),
attribute.Bool("aboveFloorBid", pf.AboveFloorBid),
attribute.Bool("simulationSuccess", pf.SimulationSuccess),
attribute.Bool("wasBidSaved", pf.WasBidSaved),
attribute.Bool("optimistic", pf.Optimistic),
),
)

func (api *RelayAPI) saveBlockSubmissionMetrics(pf common.Profile, receivedTime time.Time) {
if pf.PayloadLoad > 0 {
metrics.SubmitNewBlockReadLatencyHistogram.Record(
context.Background(),
Expand Down Expand Up @@ -2341,6 +2311,19 @@ func (api *RelayAPI) saveBlockSubmissionMetrics(pf common.Profile) {
float64(pf.RedisUpdateFloor)/1000,
)
}

metrics.SubmitNewBlockLatencyHistogram.Record(
context.Background(),
float64(time.Since(receivedTime).Milliseconds()),
otelapi.WithAttributes(
attribute.String("contentType", pf.ContentType),
attribute.Bool("isGzip", pf.IsGzip),
attribute.Bool("aboveFloorBid", pf.AboveFloorBid),
attribute.Bool("simulationSuccess", pf.SimulationSuccess),
attribute.Bool("wasBidSaved", pf.WasBidSaved),
attribute.Bool("optimistic", pf.Optimistic),
),
)
}

// ---------------
Expand Down

0 comments on commit e95e2fe

Please sign in to comment.