@@ -15,7 +15,7 @@ type redisMetric struct {
15
15
value float64
16
16
}
17
17
18
- func generateUniqueMetrics (instanceName string ) []redisMetric {
18
+ func generateUniqueMetrics (redisInfoOutput string ) []redisMetric {
19
19
var metrics []redisMetric
20
20
// ensure that the map is always iterated in the same order
21
21
metricNames := make ([]string , 0 , len (uniqueMetricMap ))
@@ -28,7 +28,7 @@ func generateUniqueMetrics(instanceName string) []redisMetric {
28
28
29
29
for _ , metricName := range metricNames {
30
30
submNam := uniqueMetricMap [metricName ]
31
- val , err := fetchMetricValue (instanceName , metricName )
31
+ val , err := fetchMetricValue (redisInfoOutput , metricName )
32
32
33
33
if err == nil {
34
34
metrics = append (metrics , redisMetric {
@@ -43,8 +43,8 @@ func generateUniqueMetrics(instanceName string) []redisMetric {
43
43
return metrics
44
44
}
45
45
46
- func fetchMetricValue (instanceName string , metricName string ) (float64 , error ) {
47
- scanner := bufio .NewScanner (strings .NewReader (instanceName ))
46
+ func fetchMetricValue (redisInfoOutput string , metricName string ) (float64 , error ) {
47
+ scanner := bufio .NewScanner (strings .NewReader (redisInfoOutput ))
48
48
49
49
for scanner .Scan () {
50
50
line := scanner .Text ()
@@ -59,11 +59,11 @@ func fetchMetricValue(instanceName string, metricName string) (float64, error) {
59
59
return 0 , fmt .Errorf ("metric %s not found" , metricName )
60
60
}
61
61
62
- func generateRecordsMetrics (instanceName string ) []redisMetric {
62
+ func generateRecordsMetrics (redisInfoOutput string ) []redisMetric {
63
63
var metrics []redisMetric
64
64
// group 1 is the db ID; group 2 is the number of keys (records)
65
65
re := regexp .MustCompile (`^db(\d+):keys=(\d+)` )
66
- scanner := bufio .NewScanner (strings .NewReader (instanceName ))
66
+ scanner := bufio .NewScanner (strings .NewReader (redisInfoOutput ))
67
67
68
68
for scanner .Scan () {
69
69
line := scanner .Text ()
0 commit comments