Skip to content

Commit 66ebc15

Browse files
authored
metrics split by request size (#43)
## πŸ“ Summary Split reported metrics by request size ## β›± Motivation and Context When metrics are not split p99 is heavily skewed towards blob bundles ## πŸ“š References --- ## βœ… I have run these commands * [x] `make lint` * [x] `make test` * [x] `go mod tidy`
1 parent c547683 commit 66ebc15

File tree

5 files changed

+30
-11
lines changed

5 files changed

+30
-11
lines changed

β€Žgo.modβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/VictoriaMetrics/metrics v1.35.1
99
github.com/cenkalti/backoff v2.2.1+incompatible
1010
github.com/ethereum/go-ethereum v1.15.5
11-
github.com/flashbots/go-utils v0.13.0
11+
github.com/flashbots/go-utils v0.13.2
1212
github.com/google/uuid v1.6.0
1313
github.com/hashicorp/golang-lru/v2 v2.0.7
1414
github.com/stretchr/testify v1.10.0

β€Žgo.sumβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ github.com/ethereum/go-ethereum v1.15.5 h1:Fo2TbBWC61lWVkFw9tsMoHCNX1ndpuaQBRJ8H
3232
github.com/ethereum/go-ethereum v1.15.5/go.mod h1:1LG2LnMOx2yPRHR/S+xuipXH29vPr6BIH6GElD8N/fo=
3333
github.com/ethereum/go-verkle v0.2.2 h1:I2W0WjnrFUIzzVPwm8ykY+7pL2d4VhlsePn4j7cnFk8=
3434
github.com/ethereum/go-verkle v0.2.2/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk=
35-
github.com/flashbots/go-utils v0.13.0 h1:rGR/4e8Xh2Y4JUjX+gZ7T82AT3d//m5RawVy+h95PeA=
36-
github.com/flashbots/go-utils v0.13.0/go.mod h1:i4xxEB6sHDFfNWEIfh+rP6nx3LxynEn8AOZa05EYgwA=
35+
github.com/flashbots/go-utils v0.13.2 h1:9fdnLKpQP/9i48NDad7u5NOK945DmL3Z61eCA9JGiwQ=
36+
github.com/flashbots/go-utils v0.13.2/go.mod h1:i4xxEB6sHDFfNWEIfh+rP6nx3LxynEn8AOZa05EYgwA=
3737
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
3838
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
3939
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=

β€Žproxy/metrics.goβ€Ž

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ const (
2828

2929
shareQueuePeerStallingErrorsLabel = `orderflow_proxy_share_queue_peer_stalling_errors{peer="%s"}`
3030
shareQueuePeerRPCErrorsLabel = `orderflow_proxy_share_queue_peer_rpc_errors{peer="%s"}`
31-
shareQueuePeerRPCDurationLabel = `orderflow_proxy_share_queue_peer_rpc_duration_milliseconds{peer="%s"}`
32-
shareQueuePeerE2EDurationLabel = `orderflow_proxy_share_queue_peer_e2e_duration_milliseconds{peer="%s",method="%s",system_endpoint="%t"}`
31+
shareQueuePeerRPCDurationLabel = `orderflow_proxy_share_queue_peer_rpc_duration_milliseconds{peer="%s",is_big="%t"}`
32+
shareQueuePeerE2EDurationLabel = `orderflow_proxy_share_queue_peer_e2e_duration_milliseconds{peer="%s",method="%s",system_endpoint="%t",is_big="%t"}`
33+
shareQueuePeerQueueDurationLabel = `orderflow_proxy_share_queue_peer_queue_duration_milliseconds{peer="%s",method="%s",system_endpoint="%t",is_big="%t"}`
3334

3435
requestDurationLabel = `orderflow_proxy_api_request_processing_duration_milliseconds{method="%s",server_name="%s",step="%s"}`
3536
)
@@ -58,14 +59,20 @@ func incShareQueuePeerRPCErrors(peer string) {
5859
metrics.GetOrCreateCounter(l).Inc()
5960
}
6061

61-
func timeShareQueuePeerRPCDuration(peer string, duration int64) {
62-
l := fmt.Sprintf(shareQueuePeerRPCDurationLabel, peer)
62+
func timeShareQueuePeerRPCDuration(peer string, duration int64, bigRequest bool) {
63+
l := fmt.Sprintf(shareQueuePeerRPCDurationLabel, peer, bigRequest)
6364
metrics.GetOrCreateSummary(l).Update(float64(duration))
6465
}
6566

66-
func timeShareQueuePeerE2EDuration(peer string, duration time.Duration, method string, systemEndpoint bool) {
67+
func timeShareQueuePeerE2EDuration(peer string, duration time.Duration, method string, systemEndpoint, bigRequest bool) {
6768
millis := float64(duration.Microseconds()) / 1000.0
68-
l := fmt.Sprintf(shareQueuePeerE2EDurationLabel, peer, method, systemEndpoint)
69+
l := fmt.Sprintf(shareQueuePeerE2EDurationLabel, peer, method, systemEndpoint, bigRequest)
70+
metrics.GetOrCreateSummary(l).Update(float64(millis))
71+
}
72+
73+
func timeShareQueuePeerQueueDuration(peer string, duration time.Duration, method string, systemEndpoint, bigRequest bool) {
74+
millis := float64(duration.Microseconds()) / 1000.0
75+
l := fmt.Sprintf(shareQueuePeerQueueDurationLabel, peer, method, systemEndpoint, bigRequest)
6976
metrics.GetOrCreateSummary(l).Update(float64(millis))
7077
}
7178

β€Žproxy/receiver_api.goβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ func (prx *ReceiverProxy) EthSendBundle(ctx context.Context, ethSendBundle rpcty
125125
systemEndpoint: systemEndpoint,
126126
ethSendBundle: &ethSendBundle,
127127
method: EthSendBundleMethod,
128+
size: rpcserver.GetRequestSize(ctx),
128129
}
129130

130131
err := prx.ValidateSigner(ctx, &parsedRequest, systemEndpoint)
@@ -192,6 +193,7 @@ func (prx *ReceiverProxy) MevSendBundle(ctx context.Context, mevSendBundle rpcty
192193
systemEndpoint: systemEndpoint,
193194
mevSendBundle: &mevSendBundle,
194195
method: MevSendBundleMethod,
196+
size: rpcserver.GetRequestSize(ctx),
195197
}
196198

197199
err := prx.ValidateSigner(ctx, &parsedRequest, systemEndpoint)
@@ -259,6 +261,7 @@ func (prx *ReceiverProxy) EthCancelBundle(ctx context.Context, ethCancelBundle r
259261
systemEndpoint: systemEndpoint,
260262
ethCancelBundle: &ethCancelBundle,
261263
method: EthCancelBundleMethod,
264+
size: rpcserver.GetRequestSize(ctx),
262265
}
263266

264267
err := prx.ValidateSigner(ctx, &parsedRequest, systemEndpoint)
@@ -290,6 +293,7 @@ func (prx *ReceiverProxy) EthSendRawTransaction(ctx context.Context, ethSendRawT
290293
systemEndpoint: systemEndpoint,
291294
ethSendRawTransaction: &ethSendRawTransaction,
292295
method: EthSendRawTransactionMethod,
296+
size: rpcserver.GetRequestSize(ctx),
293297
}
294298
err := prx.ValidateSigner(ctx, &parsedRequest, systemEndpoint)
295299
if err != nil {
@@ -319,6 +323,7 @@ func (prx *ReceiverProxy) BidSubsidiseBlock(ctx context.Context, bidSubsidiseBlo
319323
systemEndpoint: systemEndpoint,
320324
bidSubsidiseBlock: &bidSubsidiseBlock,
321325
method: BidSubsidiseBlockMethod,
326+
size: rpcserver.GetRequestSize(ctx),
322327
}
323328

324329
err := prx.ValidateSigner(ctx, &parsedRequest, systemEndpoint)
@@ -349,6 +354,7 @@ type ParsedRequest struct {
349354
signer common.Address
350355
method string
351356
peerName string
357+
size int
352358
receivedAt time.Time
353359
requestArgUniqueKey *uuid.UUID
354360
ethSendBundle *rpctypes.EthSendBundleArgs

β€Žproxy/sharing.goβ€Ž

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ var (
1414
requestTimeout = time.Second * 10
1515
)
1616

17+
const (
18+
bigRequestSize = 50_000
19+
)
20+
1721
type ShareQueue struct {
1822
name string
1923
log *slog.Logger
@@ -162,6 +166,7 @@ func (sq *ShareQueue) proxyRequests(peer *shareQueuePeer, worker int) {
162166
method string
163167
data any
164168
)
169+
isBig := req.size > bigRequestSize
165170
if req.ethSendBundle != nil {
166171
method = EthSendBundleMethod
167172
data = req.ethSendBundle
@@ -182,12 +187,13 @@ func (sq *ShareQueue) proxyRequests(peer *shareQueuePeer, worker int) {
182187
shareQueueInternalErrors.Inc()
183188
continue
184189
}
190+
timeShareQueuePeerQueueDuration(peer.name, time.Since(req.receivedAt), method, req.systemEndpoint, isBig)
185191
start := time.Now()
186192
ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
187193
resp, err := peer.client.Call(ctx, method, data)
188194
cancel()
189-
timeShareQueuePeerRPCDuration(peer.name, time.Since(start).Milliseconds())
190-
timeShareQueuePeerE2EDuration(peer.name, time.Since(req.receivedAt), method, req.systemEndpoint)
195+
timeShareQueuePeerRPCDuration(peer.name, time.Since(start).Milliseconds(), isBig)
196+
timeShareQueuePeerE2EDuration(peer.name, time.Since(req.receivedAt), method, req.systemEndpoint, isBig)
191197
logSendErrorLevel := slog.LevelDebug
192198
if peer.name == "local-builder" {
193199
logSendErrorLevel = slog.LevelWarn

0 commit comments

Comments
Β (0)