Skip to content

Commit

Permalink
Fix metrics system typo (#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
sollhui authored Oct 8, 2024
1 parent c92ee3a commit bcaf9a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Release Notes.

## 0.8.0

### Chores

- Fix metrics system typo.

## 0.7.0

### File System Changes
Expand Down
28 changes: 14 additions & 14 deletions banyand/observability/metrics_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ var (
// RootScope is the root scope for all metrics.
RootScope = meter.NewHierarchicalScope("banyandb", "_")
// SystemScope is the system scope for all metrics.
SystemScope = RootScope.SubScope("system")
cpuStateGauge meter.Gauge
cpuNumGauge meter.Gauge
memorySateGauge meter.Gauge
netStateGauge meter.Gauge
upTimeGauge meter.Gauge
diskStateGauge meter.Gauge
diskMap = sync.Map{}
SystemScope = RootScope.SubScope("system")
cpuStateGauge meter.Gauge
cpuNumGauge meter.Gauge
memoryStateGauge meter.Gauge
netStateGauge meter.Gauge
upTimeGauge meter.Gauge
diskStateGauge meter.Gauge
diskMap = sync.Map{}
)

// UpdatePath updates a path to monitoring its disk usage.
Expand Down Expand Up @@ -82,7 +82,7 @@ func (p *metricService) initMetrics() {
factory := p.With(SystemScope)
cpuStateGauge = factory.NewGauge("cpu_state", "kind")
cpuNumGauge = factory.NewGauge("cpu_num")
memorySateGauge = factory.NewGauge("memory_state", "kind")
memoryStateGauge = factory.NewGauge("memory_state", "kind")
netStateGauge = factory.NewGauge("net_state", "kind", "name")
upTimeGauge = factory.NewGauge("up_time")
diskStateGauge = factory.NewGauge("disk", "path", "kind")
Expand Down Expand Up @@ -118,16 +118,16 @@ func collectCPU() {
}

func collectMemory() {
if memorySateGauge == nil {
log.Error().Msg("memorySateGauge is not registered")
if memoryStateGauge == nil {
log.Error().Msg("memoryStateGauge is not registered")
}
m, err := mem.VirtualMemory()
if err != nil {
log.Error().Err(err).Msg("cannot get memory stat")
}
memorySateGauge.Set(m.UsedPercent/100, "used_percent")
memorySateGauge.Set(float64(m.Used), "used")
memorySateGauge.Set(float64(m.Total), "total")
memoryStateGauge.Set(m.UsedPercent/100, "used_percent")
memoryStateGauge.Set(float64(m.Used), "used")
memoryStateGauge.Set(float64(m.Total), "total")
}

func collectNet() {
Expand Down

0 comments on commit bcaf9a8

Please sign in to comment.