From bef843b3583487b680cc067097017a076323821a Mon Sep 17 00:00:00 2001 From: mphanias Date: Thu, 24 Oct 2024 15:00:42 +0530 Subject: [PATCH] OM-209 - review feedback removed unnecessary code, and fixed service hist stats --- internal/pkg/statprocessors/sp_latency.go | 21 +++++++++++--------- internal/pkg/statprocessors/sp_namespaces.go | 16 ++++----------- internal/pkg/statprocessors/sp_node_stats.go | 4 ++-- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/internal/pkg/statprocessors/sp_latency.go b/internal/pkg/statprocessors/sp_latency.go index b1388ea..b4e0e80 100644 --- a/internal/pkg/statprocessors/sp_latency.go +++ b/internal/pkg/statprocessors/sp_latency.go @@ -52,21 +52,24 @@ func (lw *LatencyStatsProcessor) getLatenciesCommands(rawMetrics map[string]stri // // Hashmap content format := namespace- = <0/1> for latencyHistName := range LatencyBenchmarks { - histTokens := strings.Split(latencyHistName, "~") + nsName := strings.Split(latencyHistName, "~")[0] + stat := LatencyBenchmarks[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] + "}-" + // service-enable-benchmarks-fabric or ns-enable-benchmarks-ops-sub or service-enable-hist-info or service-enable-hist-proxy + if nsName != "service" { + histCommand = histCommand + "{" + nsName + "}-" } - - if strings.Contains(latencyHistName, "enable-benchmarks-") { - histCommand = histCommand + strings.Join(histTokens[2:], "-") - } else { - histCommand = histCommand + strings.Join(histTokens[3:], "-") + if strings.Contains(stat, "enable-") { + stat = strings.ReplaceAll(stat, "enable-", "") + } + if strings.Contains(stat, "hist-") { + stat = strings.ReplaceAll(stat, "hist-", "") } + histCommand = histCommand + stat + commands = append(commands, histCommand) } diff --git a/internal/pkg/statprocessors/sp_namespaces.go b/internal/pkg/statprocessors/sp_namespaces.go index 53de7ae..25b402c 100644 --- a/internal/pkg/statprocessors/sp_namespaces.go +++ b/internal/pkg/statprocessors/sp_namespaces.go @@ -1,6 +1,7 @@ package statprocessors import ( + "fmt" "regexp" "strings" "time" @@ -233,19 +234,10 @@ func (nw *NamespaceStatsProcessor) refreshNamespaceStats(singleInfoKey string, i // 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, nsName+"-"+stat) - - if pv == 1 { - LatencyBenchmarks[nsName+"-"+stat] = stat - } - } - - // 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) + fmt.Println("\t ===> ", nsName, " === stat ", stat) + if pv == 1 { LatencyBenchmarks[nsName+"~"+stat] = stat } @@ -253,7 +245,7 @@ func (nw *NamespaceStatsProcessor) refreshNamespaceStats(singleInfoKey string, i } // 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" + LatencyBenchmarks[nsName+"~latency-hist-re-repl"] = "re-repl" return nsMetricsToSend } diff --git a/internal/pkg/statprocessors/sp_node_stats.go b/internal/pkg/statprocessors/sp_node_stats.go index 6282a91..bd925a5 100644 --- a/internal/pkg/statprocessors/sp_node_stats.go +++ b/internal/pkg/statprocessors/sp_node_stats.go @@ -88,10 +88,10 @@ func (sw *NodeStatsProcessor) handleRefresh(nodeRawMetrics string) []AerospikeSt 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) + delete(LatencyBenchmarks, "service~"+stat) if pv == 1 { - LatencyBenchmarks["service-"+stat] = stat + LatencyBenchmarks["service~"+stat] = stat } } }