|
| 1 | +package server |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + |
| 6 | + "github.com/VictoriaMetrics/metrics" |
| 7 | +) |
| 8 | + |
| 9 | +var winningBidValue = metrics.NewHistogram("mev_boost_winning_bid_value") |
| 10 | + |
| 11 | +const ( |
| 12 | + beaconNodeStatusLabel = `mev_boost_beacon_node_status_code_total{http_status_code="%s",endpoint="%s"}` |
| 13 | + bidValuesLabel = `mev_boost_bid_values{relay="%s"}` |
| 14 | + bidsBelowMinBidLabel = `mev_boost_bids_below_min_bid_total{relay="%s"}` |
| 15 | + relayLatencyLabel = `mev_boost_relay_latency{endpoint="%s",relay="%s"}` |
| 16 | + relayStatusCodeLabel = `mev_boost_relay_status_code_total{http_status_code="%s",endpoint="%s",relay="%s"}` |
| 17 | + relayLastSlotLabel = `mev_boost_relay_last_slot{relay="%s"}` |
| 18 | + msIntoSlotLabel = `mev_boost_millisec_into_slot{endpoint="%s"}` |
| 19 | +) |
| 20 | + |
| 21 | +func IncrementBeaconNodeStatus(status, endpoint string) { |
| 22 | + l := fmt.Sprintf(beaconNodeStatusLabel, status, endpoint) |
| 23 | + metrics.GetOrCreateCounter(l).Inc() |
| 24 | +} |
| 25 | + |
| 26 | +func RecordBidValue(relay string, value float64) { |
| 27 | + l := fmt.Sprintf(bidValuesLabel, relay) |
| 28 | + metrics.GetOrCreateHistogram(l).Update(value) |
| 29 | +} |
| 30 | + |
| 31 | +func IncrementBidBelowMinBid(relay string) { |
| 32 | + l := fmt.Sprintf(bidsBelowMinBidLabel, relay) |
| 33 | + metrics.GetOrCreateCounter(l).Inc() |
| 34 | +} |
| 35 | + |
| 36 | +func RecordWinningBidValue(value float64) { |
| 37 | + winningBidValue.Update(value) |
| 38 | +} |
| 39 | + |
| 40 | +func RecordRelayLatency(endpoint, relay string, latency float64) { |
| 41 | + l := fmt.Sprintf(relayLatencyLabel, endpoint, relay) |
| 42 | + metrics.GetOrCreateHistogram(l).Update(latency) |
| 43 | +} |
| 44 | + |
| 45 | +func RecordRelayStatusCode(httpStatus, endpoint, relay string) { |
| 46 | + l := fmt.Sprintf(relayStatusCodeLabel, httpStatus, endpoint, relay) |
| 47 | + metrics.GetOrCreateCounter(l).Inc() |
| 48 | +} |
| 49 | + |
| 50 | +func RecordRelayLastSlot(relay string, slot uint64) { |
| 51 | + l := fmt.Sprintf(relayLastSlotLabel, relay) |
| 52 | + metrics.GetOrCreateGauge(l, nil).Set(float64(slot)) |
| 53 | +} |
| 54 | + |
| 55 | +func RecordMsIntoSlot(endpoint string, ms float64) { |
| 56 | + l := fmt.Sprintf(msIntoSlotLabel, endpoint) |
| 57 | + metrics.GetOrCreateHistogram(l).Update(ms) |
| 58 | +} |
0 commit comments