Skip to content

Conversation

faheelsattar
Copy link
Collaborator

@faheelsattar faheelsattar commented Sep 25, 2025

📝 Summary

Adds prometheus metrics related to

  • bids delivered by relays
  • latency by relay
  • status of the response received by relays
  • status code returned to beacon node
  • number of bids below the min bid
  • winning bid
  • ms into the slot
  • last slot for which relay delivered the header

⛱ Motivation and Context

📚 References


✅ I have run these commands

  • make lint
  • make test-race
  • go mod tidy

Comment on lines +194 to +200
metricsAddrFlag = &cli.StringFlag{
Name: "metrics-addr",
Sources: cli.EnvVars("METRICS_ADDR"),
Value: "localhost:18551",
Usage: "listening address for the metrics server",
Category: Metrics,
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit: it would be nice to separate it out to metrics-addr and metrics-port into separate flags.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually mirrors how we do it elsewhere. I'd like to keep it like this for consistency.

mev-boost/cli/flags.go

Lines 42 to 48 in 7e47dd2

addrFlag = &cli.StringFlag{
Name: "addr",
Sources: cli.EnvVars("BOOST_LISTEN_ADDR"),
Value: "localhost:18550",
Usage: "listen-address for mev-boost server",
Category: GeneralCategory,
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright sounds good

Comment on lines 100 to 102
if RelayLatency != nil {
RelayLatency.WithLabelValues(params.PathGetHeader, relay.String()).Observe(float64(time.Since(start).Milliseconds()))
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it in microseconds? We can always divide the metric by 1000 to get the value in millisecond. Lets have more precision.

@jtraglia
Copy link
Collaborator

We're missing the README updates from:

@metachris metachris requested a review from Copilot September 26, 2025 11:18
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive Prometheus metrics instrumentation to mev-boost, enabling monitoring of relay performance, bid tracking, and service health metrics.

  • Implements a metrics server with various histograms, counters, and gauges for monitoring relay operations
  • Adds latency tracking and status code recording for all relay interactions
  • Introduces command-line flags to enable and configure the metrics server

Reviewed Changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
server/metrics.go New file defining Prometheus metrics definitions and helper functions
server/service.go Adds metrics server startup, beacon node status tracking, and relay monitoring
server/register_validator.go Instruments validator registration with latency and status code metrics
server/get_header.go Adds bid value tracking, winning bid recording, and slot timing metrics
server/get_payload.go Instruments payload operations with latency tracking and slot timing
cli/main.go Integrates metrics server startup with command-line configuration
cli/flags.go Defines new CLI flags for enabling and configuring metrics
go.mod Adds Prometheus client library dependency
README.md Documents new metrics functionality and CLI flags

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@metachris metachris changed the title Faheel/prom metrics Prometheus Metrics Sep 30, 2025
-metrics
enables a metrics server (default: false)
-metrics-addr string
listening address for the metrics server (default: "localhost:18551")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are both flags necessary, or should we only use -metrics-addr and when set then enable, and by default empty string disable?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm this would require the user provide a URL/port. Not quite as simple as "enable with -metrics".

I think we did it this way because it mimics how clients do it, eg:

image

@metachris metachris merged commit eb41f10 into flashbots:develop Oct 1, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants