Skip to content

Commit

Permalink
Add a metric for DB writing throughput (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
jianoaix authored Jul 18, 2024
1 parent 4590592 commit 796b35a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions node/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ type Metrics struct {
EigenMetrics eigenmetrics.Metrics
// Reachability gauge to monitoring the reachability of the node's retrieval/dispersal sockets
ReachabilityGauge *prometheus.GaugeVec
// The throughput (bytes per second) at which the data is written to database.
DBWriteThroughput prometheus.Gauge

registry *prometheus.Registry
// socketAddr is the address at which the metrics server will be listening.
Expand Down Expand Up @@ -139,6 +141,14 @@ func NewMetrics(eigenMetrics eigenmetrics.Metrics, reg *prometheus.Registry, log
},
[]string{"service"},
),
DBWriteThroughput: promauto.With(reg).NewGauge(
prometheus.GaugeOpts{
Namespace: Namespace,
Name: "db_write_throughput_bytes_per_second",
Help: "the throughput (bytes per second) at which the data is written to database",
},
),

EigenMetrics: eigenMetrics,
logger: logger.With("component", "NodeMetrics"),
registry: reg,
Expand Down
4 changes: 3 additions & 1 deletion node/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ func (s *Store) StoreBatch(ctx context.Context, header *core.BatchHeader, blobs
log.Error("Failed to write the batch into local database:", "err", err)
return nil, err
}
log.Debug("StoreBatch succeeded", "chunk serialization duration", serializationDuration, "bytes encoding duration", encodingDuration, "write batch duration", time.Since(start), "total store batch duration", time.Since(storeBatchStart), "total bytes", size)
throughput := float64(size) / time.Since(start).Seconds()
s.metrics.DBWriteThroughput.Set(throughput)
log.Debug("StoreBatch succeeded", "chunk serialization duration", serializationDuration, "bytes encoding duration", encodingDuration, "num blobs", len(blobs), "num of key-value pair entries", len(keys), "write batch duration", time.Since(start), "write throughput (MB/s)", throughput/1000_000, "total store batch duration", time.Since(storeBatchStart), "total bytes", size)

return &keys, nil
}
Expand Down

0 comments on commit 796b35a

Please sign in to comment.