Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Om86 #101

Merged
merged 8 commits into from
Nov 30, 2023
Merged

Om86 #101

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
59 changes: 57 additions & 2 deletions watcher_latency.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"strings"

"github.com/prometheus/client_golang/prometheus"

log "github.com/sirupsen/logrus"
Expand All @@ -9,6 +11,8 @@ import (
type LatencyWatcher struct {
}

var LatencyBenchmarks = make(map[string]string)

func (lw *LatencyWatcher) describe(ch chan<- *prometheus.Desc) {}

func (lw *LatencyWatcher) passOneKeys() []string {
Expand All @@ -33,7 +37,7 @@ func (lw *LatencyWatcher) passTwoKeys(rawMetrics map[string]string) (latencyComm
}

if ok {
return []string{"latencies:"}
return lw.getLatenciesCommands(rawMetrics)
}

return []string{"latency:"}
Expand All @@ -56,10 +60,25 @@ func (lw *LatencyWatcher) refresh(o *Observer, infoKeys []string, rawMetrics map
}
}

// loop all the latency infokeys
for _, infoKey := range infoKeys {
err := parseSingleLatenciesKey(infoKey, rawMetrics, allowedLatenciesList, blockedLatenciessList, ch)
if err != nil {
return err
}
}

return nil
}

func parseSingleLatenciesKey(singleLatencyKey string, rawMetrics map[string]string,
allowedLatenciesList map[string]struct{},
blockedLatenciessList map[string]struct{}, ch chan<- prometheus.Metric) error {

var latencyStats map[string]StatsMap

if rawMetrics["latencies:"] != "" {
latencyStats = parseLatencyInfo(rawMetrics["latencies:"], int(config.Aerospike.LatencyBucketsCount))
latencyStats = parseLatencyInfo(rawMetrics[singleLatencyKey], int(config.Aerospike.LatencyBucketsCount))
} else {
latencyStats = parseLatencyInfoLegacy(rawMetrics["latency:"], int(config.Aerospike.LatencyBucketsCount))
}
Expand Down Expand Up @@ -99,3 +118,39 @@ func (lw *LatencyWatcher) refresh(o *Observer, infoKeys []string, rawMetrics map

return nil
}

// Utility methods
// checks if a stat can be considered for latency stat retrieval
func isStatLatencyHistRelated(stat string) bool {
// is not enable-benchmarks-storage and (enable-benchmarks-* or enable-hist-*)
return (!strings.Contains(stat, "enable-benchmarks-storage")) && (strings.Contains(stat, "enable-benchmarks-") ||
strings.Contains(stat, "enable-hist-")) // hist-proxy & hist-info - both at service level
}

func (lw *LatencyWatcher) getLatenciesCommands(rawMetrics map[string]string) []string {
var commands = []string{"latencies:"}

// Hashmap content format := namespace-<histogram-key> = <histogram-key>
for latencyHistName := range LatencyBenchmarks {
histTokens := strings.Split(latencyHistName, "-")

histCommand := "latencies:hist="

// service-enable-benchmarks-fabric or ns-enable-benchmarks-ops-sub or service-enable-hist-info
if histTokens[0] != "service" {
histCommand = histCommand + "{" + histTokens[0] + "}-"
}

if strings.Contains(latencyHistName, "enable-benchmarks-") {
histCommand = histCommand + strings.Join(histTokens[2:], "-")
} else {
histCommand = histCommand + strings.Join(histTokens[3:], "-")
}

commands = append(commands, histCommand)
}

log.Tracef("latency-passtwokeys:%s", commands)

return commands
}
16 changes: 14 additions & 2 deletions watcher_namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ func (nw *NamespaceWatcher) refreshNamespaceStats(singleInfoKey string, infoKeys
sindexType := stats[SINDEX_TYPE]
storageEngine := stats[STORAGE_ENGINE]

// fmt.Println(" storageEngine: ", storageEngine)

// if stat is index-type or sindex-type , append addl label
if strings.HasPrefix(deviceType, INDEX_TYPE) && len(indexType) > 0 {
labels = append(labels, METRIC_LABEL_INDEX)
Expand Down Expand Up @@ -210,7 +208,21 @@ func (nw *NamespaceWatcher) refreshNamespaceStats(singleInfoKey string, infoKeys
// push to prom-channel
pushToPrometheus(asMetric, pv, labels, labelValues, ch)
}

// below code section is to ensure ns+latencies combination is handled during LatencyWatcher
//
// check and if latency benchmarks stat - is it enabled (bool true==1 and false==0 after conversion)
if isStatLatencyHistRelated(stat) {
delete(LatencyBenchmarks, nsName+"-"+stat)

if pv == 1 {
LatencyBenchmarks[nsName+"-"+stat] = stat
}
}

}
// // append default re-repl, as this auto-enabled, but not coming as part of latencies, we need this as namespace is available only here
// LatencyBenchmarks[nsName+"-latency-hist-re-repl"] = "{" + nsName + "}-re-repl"

}

Expand Down
10 changes: 10 additions & 0 deletions watcher_node_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,15 @@ func (sw *StatsWatcher) handleRefresh(o *Observer, nodeRawMetrics string, cluste

pushToPrometheus(asMetric, pv, labels, labelsValues, ch)

// check and if latency benchmarks stat, is it enabled (bool true==1 and false==0 after conversion)
if isStatLatencyHistRelated(stat) {
// remove old value as microbenchmark may get enabled / disable on-the-fly at server so we cannot rely on value
delete(LatencyBenchmarks, "service-"+stat)

if pv == 1 {
LatencyBenchmarks["service-"+stat] = stat
}
}

}
}