Skip to content

Commit

Permalink
chore: expose gc related metrics [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
muety committed Sep 20, 2023
1 parent 435560b commit 7db470c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions routes/api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const (

DescMemAllocTotal = "Total number of bytes allocated for heap"
DescMemSysTotal = "Total number of bytes obtained from the OS"
DescPausedTotal = "Total nanoseconds stop-the-world pause time due to GC"
DescNumGCTotal = "Total number of GC cycles"
DescGoroutines = "Total number of running goroutines"
DescDatabaseSize = "Total database size in bytes"
)
Expand Down Expand Up @@ -245,6 +247,20 @@ func (h *MetricsHandler) getUserMetrics(user *models.User) (*mm.Metrics, error)
Labels: []mm.Label{},
})

metrics = append(metrics, &mm.CounterMetric{
Name: MetricsPrefix + "_paused_total",
Desc: DescPausedTotal,
Value: int64(memStats.PauseTotalNs),
Labels: []mm.Label{},
})

metrics = append(metrics, &mm.CounterMetric{
Name: MetricsPrefix + "_num_gc_total",
Desc: DescNumGCTotal,
Value: int64(memStats.NumGC),
Labels: []mm.Label{},
})

// Database metrics
dbSize, err := h.metricsRepo.GetDatabaseSize()
if err != nil {
Expand Down

0 comments on commit 7db470c

Please sign in to comment.