Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: nolouch <[email protected]>
  • Loading branch information
nolouch committed Apr 8, 2024
1 parent af48caa commit c0f0895
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 170 deletions.
40 changes: 11 additions & 29 deletions pkg/mcs/resource_manager/server/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ func (m *Manager) backgroundMetricsFlush(ctx context.Context) {
// Clean up the metrics that have not been updated for a long time.
for name, lastTime := range m.consumptionRecord {
if time.Since(lastTime) > metricsCleanupTimeout {
<<<<<<< HEAD:pkg/mcs/resource_manager/server/manager.go
readRequestUnitCost.DeleteLabelValues(name)
writeRequestUnitCost.DeleteLabelValues(name)
sqlLayerRequestUnitCost.DeleteLabelValues(name)
Expand All @@ -432,22 +431,9 @@ func (m *Manager) backgroundMetricsFlush(ctx context.Context) {
requestCount.DeleteLabelValues(name, writeTypeLabel)
availableRUCounter.DeleteLabelValues(name)
delete(m.consumptionRecord, name)
=======
readRequestUnitCost.DeleteLabelValues(r.name, r.name, r.ruType)
writeRequestUnitCost.DeleteLabelValues(r.name, r.name, r.ruType)
sqlLayerRequestUnitCost.DeleteLabelValues(r.name, r.name, r.ruType)
readByteCost.DeleteLabelValues(r.name, r.name, r.ruType)
writeByteCost.DeleteLabelValues(r.name, r.name, r.ruType)
kvCPUCost.DeleteLabelValues(r.name, r.name, r.ruType)
sqlCPUCost.DeleteLabelValues(r.name, r.name, r.ruType)
requestCount.DeleteLabelValues(r.name, r.name, readTypeLabel)
requestCount.DeleteLabelValues(r.name, r.name, writeTypeLabel)
availableRUCounter.DeleteLabelValues(r.name, r.name, r.ruType)
delete(m.consumptionRecord, r)
delete(maxPerSecTrackers, r.name)
readRequestUnitMaxPerSecCost.DeleteLabelValues(r.name)
writeRequestUnitMaxPerSecCost.DeleteLabelValues(r.name)
>>>>>>> 52e876337 (resource_manager: record the max RU per second (#7936)):pkg/mcs/resourcemanager/server/manager.go
delete(maxPerSecTrackers, name)
readRequestUnitMaxPerSecCost.DeleteLabelValues(name)
writeRequestUnitMaxPerSecCost.DeleteLabelValues(name)
}
}
case <-availableRUTicker.C:
Expand All @@ -466,10 +452,7 @@ func (m *Manager) backgroundMetricsFlush(ctx context.Context) {
if ru < 0 {
ru = 0
}
<<<<<<< HEAD:pkg/mcs/resource_manager/server/manager.go
availableRUCounter.WithLabelValues(name).Set(ru)
=======
availableRUCounter.WithLabelValues(group.Name, group.Name).Set(ru)
availableRUCounter.WithLabelValues(group.Name).Set(ru)
}

case <-recordMaxTicker.C:
Expand All @@ -478,14 +461,13 @@ func (m *Manager) backgroundMetricsFlush(ctx context.Context) {
names := make([]string, 0, len(m.groups))
for name := range m.groups {
names = append(names, name)
>>>>>>> 52e876337 (resource_manager: record the max RU per second (#7936)):pkg/mcs/resourcemanager/server/manager.go
}
m.RUnlock()
for _, name := range names {
if t, ok := maxPerSecTrackers[name]; !ok {
maxPerSecTrackers[name] = newMaxPerSecCostTracker(name, defaultCollectIntervalSec)
} else {
t.FlushMetrics()
m.RUnlock()
for _, name := range names {
if t, ok := maxPerSecTrackers[name]; !ok {
maxPerSecTrackers[name] = newMaxPerSecCostTracker(name, defaultCollectIntervalSec)
} else {
t.FlushMetrics()
}
}
}
}
Expand Down
32 changes: 24 additions & 8 deletions pkg/mcs/resource_manager/server/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ import (
)

const (
namespace = "resource_manager"
serverSubsystem = "server"
ruSubsystem = "resource_unit"
resourceSubsystem = "resource"
resourceGroupNameLabel = "name"
typeLabel = "type"
readTypeLabel = "read"
writeTypeLabel = "write"
namespace = "resource_manager"
serverSubsystem = "server"
ruSubsystem = "resource_unit"
resourceSubsystem = "resource"
resourceGroupNameLabel = "name"
typeLabel = "type"
readTypeLabel = "read"
writeTypeLabel = "write"
newResourceGroupNameLabel = "resource_group"
)

var (
Expand Down Expand Up @@ -55,6 +56,21 @@ var (
Help: "Bucketed histogram of the write request unit cost for all resource groups.",
Buckets: prometheus.ExponentialBuckets(3, 10, 5), // 3 ~ 300000
}, []string{resourceGroupNameLabel})
readRequestUnitMaxPerSecCost = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: ruSubsystem,
Name: "read_request_unit_max_per_sec",
Help: "Gauge of the max read request unit per second for all resource groups.",
}, []string{newResourceGroupNameLabel})
writeRequestUnitMaxPerSecCost = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: ruSubsystem,
Name: "write_request_unit_max_per_sec",
Help: "Gauge of the max write request unit per second for all resource groups.",
}, []string{newResourceGroupNameLabel})

sqlLayerRequestUnitCost = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Expand Down
133 changes: 0 additions & 133 deletions pkg/mcs/resourcemanager/server/metrics.go

This file was deleted.

0 comments on commit c0f0895

Please sign in to comment.