From e95e2fe6e390bf5ee35bbdd0c3ce63a169e384d5 Mon Sep 17 00:00:00 2001 From: avalonche Date: Sat, 25 May 2024 02:10:51 +1000 Subject: [PATCH] comments --- metrics/metrics.go | 4 ---- services/api/service.go | 47 +++++++++++++---------------------------- 2 files changed, 15 insertions(+), 36 deletions(-) diff --git a/metrics/metrics.go b/metrics/metrics.go index 502369c9..da7113dd 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -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 @@ -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 diff --git a/services/api/service.go b/services/api/service.go index aa0b28a8..51684efd 100644 --- a/services/api/service.go +++ b/services/api/service.go @@ -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) { @@ -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 @@ -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 @@ -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(), @@ -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), + ), + ) } // ---------------