Skip to content

Commit

Permalink
OM-209 - review feedback
Browse files Browse the repository at this point in the history
removed unnecessary code, and fixed service hist stats
  • Loading branch information
mphanias committed Oct 24, 2024
1 parent 4ba93a1 commit bef843b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
21 changes: 12 additions & 9 deletions internal/pkg/statprocessors/sp_latency.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,24 @@ func (lw *LatencyStatsProcessor) getLatenciesCommands(rawMetrics map[string]stri
//
// Hashmap content format := namespace-<histogram-key> = <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)
}

Expand Down
16 changes: 4 additions & 12 deletions internal/pkg/statprocessors/sp_namespaces.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package statprocessors

import (
"fmt"
"regexp"
"strings"
"time"
Expand Down Expand Up @@ -233,27 +234,18 @@ 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
}
}

}
// 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
}
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/statprocessors/sp_node_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down

0 comments on commit bef843b

Please sign in to comment.