Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use gauges for time metrics #3009

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cache/metercacher/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ var (

type metrics struct {
getCount *prometheus.CounterVec
getTime *prometheus.CounterVec
getTime *prometheus.GaugeVec

putCount prometheus.Counter
putTime prometheus.Counter
putTime prometheus.Gauge

len prometheus.Gauge
portionFilled prometheus.Gauge
Expand All @@ -49,8 +49,8 @@ func newMetrics(
},
resultLabels,
),
getTime: prometheus.NewCounterVec(
prometheus.CounterOpts{
getTime: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "get_time",
Help: "time spent (ns) in get calls",
Expand All @@ -62,7 +62,7 @@ func newMetrics(
Name: "put_count",
Help: "number of put calls",
}),
putTime: prometheus.NewCounter(prometheus.CounterOpts{
putTime: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "put_time",
Help: "time spent (ns) in put calls",
Expand Down
10 changes: 5 additions & 5 deletions database/leveldb/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type metrics struct {
writesDelayedCount prometheus.Counter
// total amount of time (in ns) that writes that have been delayed due to
// compaction
writesDelayedDuration prometheus.Counter
writesDelayedDuration prometheus.Gauge
// set to 1 if there is currently at least one write that is being delayed
// due to compaction
writeIsDelayed prometheus.Gauge
Expand All @@ -44,7 +44,7 @@ type metrics struct {
// size of each level
levelSize *prometheus.GaugeVec
// amount of time spent compacting each level
levelDuration *prometheus.CounterVec
levelDuration *prometheus.GaugeVec
// amount of bytes read while compacting each level
levelReads *prometheus.CounterVec
// amount of bytes written while compacting each level
Expand All @@ -69,7 +69,7 @@ func newMetrics(namespace string, reg prometheus.Registerer) (metrics, error) {
Name: "writes_delayed",
Help: "number of cumulative writes that have been delayed due to compaction",
}),
writesDelayedDuration: prometheus.NewCounter(prometheus.CounterOpts{
writesDelayedDuration: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "writes_delayed_duration",
Help: "amount of time (in ns) that writes have been delayed due to compaction",
Expand Down Expand Up @@ -129,8 +129,8 @@ func newMetrics(namespace string, reg prometheus.Registerer) (metrics, error) {
},
levelLabels,
),
levelDuration: prometheus.NewCounterVec(
prometheus.CounterOpts{
levelDuration: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "duration",
Help: "amount of time (in ns) spent in compaction by level",
Expand Down
6 changes: 3 additions & 3 deletions database/meterdb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type Database struct {
db database.Database

calls *prometheus.CounterVec
duration *prometheus.CounterVec
duration *prometheus.GaugeVec
size *prometheus.CounterVec
}

Expand All @@ -112,8 +112,8 @@ func New(
},
methodLabels,
),
duration: prometheus.NewCounterVec(
prometheus.CounterOpts{
duration: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "duration",
Help: "time spent in database calls (ns)",
Expand Down
6 changes: 3 additions & 3 deletions message/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ type msgBuilder struct {

zstdCompressor compression.Compressor
count *prometheus.CounterVec // type + op + direction
duration *prometheus.CounterVec // type + op + direction
duration *prometheus.GaugeVec // type + op + direction

maxMessageTimeout time.Duration
}
Expand Down Expand Up @@ -170,8 +170,8 @@ func newMsgBuilder(
},
metricLabels,
),
duration: prometheus.NewCounterVec(
prometheus.CounterOpts{
duration: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "compressed_duration",
Help: "time spent handling compressed messages",
Expand Down
4 changes: 2 additions & 2 deletions network/p2p/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func NewNetwork(
namespace string,
) (*Network, error) {
metrics := metrics{
msgTime: prometheus.NewCounterVec(
prometheus.CounterOpts{
msgTime: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "msg_time",
Help: "message handling time (ns)",
Expand Down
2 changes: 1 addition & 1 deletion network/p2p/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type meteredHandler struct {
}

type metrics struct {
msgTime *prometheus.CounterVec
msgTime *prometheus.GaugeVec
msgCount *prometheus.CounterVec
}

Expand Down
10 changes: 5 additions & 5 deletions snow/networking/handler/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
type metrics struct {
expired *prometheus.CounterVec // op
messages *prometheus.CounterVec // op
lockingTime prometheus.Counter
messageHandlingTime *prometheus.CounterVec // op
lockingTime prometheus.Gauge
messageHandlingTime *prometheus.GaugeVec // op
}

func newMetrics(namespace string, reg prometheus.Registerer) (*metrics, error) {
Expand All @@ -34,15 +34,15 @@ func newMetrics(namespace string, reg prometheus.Registerer) (*metrics, error) {
},
opLabels,
),
messageHandlingTime: prometheus.NewCounterVec(
prometheus.CounterOpts{
messageHandlingTime: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "message_handling_time",
Help: "time spent handling messages",
},
opLabels,
),
lockingTime: prometheus.NewCounter(prometheus.CounterOpts{
lockingTime: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "locking_time",
Help: "time spent acquiring the context lock",
Expand Down
6 changes: 3 additions & 3 deletions snow/networking/timeout/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (m *metrics) Observe(chainID ids.ID, op message.Op, latency time.Duration)
// chainMetrics contains message response time metrics for a chain
type chainMetrics struct {
messages *prometheus.CounterVec // op
messageLatencies *prometheus.CounterVec // op
messageLatencies *prometheus.GaugeVec // op
}

func newChainMetrics(reg prometheus.Registerer) (*chainMetrics, error) {
Expand All @@ -75,8 +75,8 @@ func newChainMetrics(reg prometheus.Registerer) (*chainMetrics, error) {
},
opLabels,
),
messageLatencies: prometheus.NewCounterVec(
prometheus.CounterOpts{
messageLatencies: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: responseNamespace,
Name: "message_latencies",
Help: "message latencies (ns)",
Expand Down
Loading