metrics_patterns
Current Prometheus Metrics Setup
Structure
Central metrics files:
metrics/gateway.go- Gateway-level metrics (requests, duration, response size)metrics/server.go- Prometheus metrics server setupmetrics/prometheus_reporter.go- Metrics reporter interfacecmd/metrics.go- Metrics server initialization
Protocol-specific metrics:
metrics/protocol/shannon/metrics.go- Shannon protocol metrics
QoS-specific metrics:
metrics/qos/evm/metrics.go- EVM QoS metricsmetrics/qos/solana/metrics.go- Solana QoS metrics
Pattern Analysis
Common Constants
All metrics files use
pathProcess = "path"as the subsystem name.Each file defines specific metric name constants (e.g.,
requestsTotal,relaysTotalMetric).
Registration Pattern
Each metrics file has an
init()function that callsprometheus.MustRegister()for its metrics.Metrics are defined as package-level variables using
prometheus.NewCounterVec,prometheus.NewHistogramVec, etc.
Metric Definition Structure
var myMetric = prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: pathProcess, // Always "path"
Name: metricName, // Defined as constant
Help: "Description...",
},
[]string{"label1", "label2"}, // Labels
)Publishing Pattern
Each metrics file exposes a
PublishMetrics()function.Uses
prometheus.Labels{}to set label values.Calls
.With(labels).Inc()or.With(labels).Observe(value)on metrics.
Version Handling
Project uses git-based versioning via:
git describe --tags --always --dirtyNo existing version metric is present in the current setup.
Build process injects values via ldflags in
makefiles/release.mk.
Was this helpful?
