Skip to content
Open
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
33 changes: 20 additions & 13 deletions internal/mysqlmetrics/mysqlmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ import (
)

const (
innoDBKey = "is_inno_db_default"
bufferPoolKey = "buffer_pool_size"
totalRAMKey = "total_ram"
currentRoleKey = "current_role"
replicationZonesKey = "replication_zones"
sourceRole = "source"
replicaRole = "replica"
replicationZonesQuery = "SELECT HOST FROM information_schema.PROCESSLIST AS p WHERE p.COMMAND = 'Binlog Dump'"
innoDBKey = "is_inno_db_default"
bufferPoolKey = "buffer_pool_size"
totalRAMKey = "total_ram"
currentRoleKey = "current_role"
replicationZonesKey = "replication_zones"
notProtectedByAutoFailoverKey = "not_protected_by_auto_failover"
sourceRole = "source"
replicaRole = "replica"
replicationZonesQuery = "SELECT HOST FROM information_schema.PROCESSLIST AS p WHERE p.COMMAND = 'Binlog Dump'"
)

type netInterface interface {
Expand Down Expand Up @@ -1134,21 +1135,27 @@ func (m *MySQLMetrics) CollectWlmMetricsOnce(ctx context.Context, dwActivated bo
}
currentRole := m.currentRole(ctx)
replicationZones := m.replicationZones(ctx, currentRole, &netImpl{})
notProtectedByAutoFailover, err := m.notProtectedByAutoFailover(ctx)
if err != nil {
log.CtxLogger(ctx).Warnf("Failed to get not protected by auto failover: %v", err)
}
log.CtxLogger(ctx).Debugw("Finished collecting MySQL metrics once. Next step is to send to WLM (DW).",
bufferPoolKey, bufferPoolSize,
totalRAMKey, totalRAM,
innoDBKey, isInnoDBDefault,
currentRoleKey, currentRole,
replicationZonesKey, strings.Join(replicationZones, ","),
notProtectedByAutoFailoverKey, notProtectedByAutoFailover,
)
metrics := workloadmanager.WorkloadMetrics{
WorkloadType: workloadmanager.MYSQL,
Metrics: map[string]string{
bufferPoolKey: strconv.FormatInt(bufferPoolSize, 10),
totalRAMKey: strconv.Itoa(totalRAM),
innoDBKey: strconv.FormatBool(isInnoDBDefault),
currentRoleKey: currentRole,
replicationZonesKey: strings.Join(replicationZones, ","),
bufferPoolKey: strconv.FormatInt(bufferPoolSize, 10),
totalRAMKey: strconv.Itoa(totalRAM),
innoDBKey: strconv.FormatBool(isInnoDBDefault),
currentRoleKey: currentRole,
replicationZonesKey: strings.Join(replicationZones, ","),
notProtectedByAutoFailoverKey: strconv.FormatBool(notProtectedByAutoFailover),
},
}
res, err := workloadmanager.SendDataInsight(ctx, workloadmanager.SendDataInsightParams{
Expand Down
22 changes: 12 additions & 10 deletions internal/mysqlmetrics/mysqlmetrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1237,11 +1237,12 @@ func TestCollectWlmMetricsOnce(t *testing.T) {
wantMetrics: &workloadmanager.WorkloadMetrics{
WorkloadType: workloadmanager.MYSQL,
Metrics: map[string]string{
bufferPoolKey: "134217728",
currentRoleKey: sourceRole,
totalRAMKey: strconv.Itoa(4025040 * 1024),
innoDBKey: "true",
replicationZonesKey: "",
bufferPoolKey: "134217728",
currentRoleKey: sourceRole,
totalRAMKey: strconv.Itoa(4025040 * 1024),
innoDBKey: "true",
replicationZonesKey: "",
notProtectedByAutoFailoverKey: "true",
},
},
wantErr: false,
Expand Down Expand Up @@ -1450,11 +1451,12 @@ func TestCollectWlmMetricsOnce(t *testing.T) {
wantMetrics: &workloadmanager.WorkloadMetrics{
WorkloadType: workloadmanager.MYSQL,
Metrics: map[string]string{
bufferPoolKey: "134217728",
currentRoleKey: sourceRole,
totalRAMKey: strconv.Itoa(4025040 * 1024),
innoDBKey: "true",
replicationZonesKey: "",
bufferPoolKey: "134217728",
currentRoleKey: sourceRole,
totalRAMKey: strconv.Itoa(4025040 * 1024),
innoDBKey: "true",
replicationZonesKey: "",
notProtectedByAutoFailoverKey: "true",
},
},
wantErr: false,
Expand Down
Loading