Skip to content

Commit

Permalink
add support for microsecond-histograms with 5.1 and over
Browse files Browse the repository at this point in the history
  • Loading branch information
realmgic committed Oct 25, 2020
1 parent 6d8dd02 commit 5f84c13
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 22 deletions.
3 changes: 3 additions & 0 deletions controllers/enterprise.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func transformLatency(latestLatency map[string]common.Stats) common.Stats {
for op, stats := range latestLatency {
buckets := stats["buckets"].([]string)
valBuckets := stats["valBuckets"].([]float64)
histUnit := stats["histUnit"]

totalOver1ms := 0.0
for _, v := range valBuckets {
Expand Down Expand Up @@ -149,6 +150,7 @@ func transformLatency(latestLatency map[string]common.Stats) common.Stats {
"timestamp": timestamp,
"timestamp_unix": stats["timestamp_unix"],
"ops/sec": tps,
"units": histUnit,
"data": data,
}
}
Expand Down Expand Up @@ -206,6 +208,7 @@ func getNodesLatencyHistory(c echo.Context) error {
res[node.Address()] = common.Stats{
"node_status": node.Status(),
"node_build": node.Build(),
"latency_units": node.LatencyUnits(),
"latency_history": latencyHistory,
"address": node.Address(),
}
Expand Down
11 changes: 10 additions & 1 deletion models/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,15 @@ func (n *Node) Build() string {
return n.InfoAttr("build")
}

func (n *Node) LatencyUnits() string {
res := n.latestConfig.TryString("microsecond-histograms", "")
if res == "true" {
return "usec"
} else {
return "msec"
}
}

func (n *Node) Disk() common.Stats {
return common.Stats{
"used": n.nsAggCalcStats.TryInt("used-bytes-disk", 0),
Expand Down Expand Up @@ -1131,7 +1140,7 @@ func (n *Node) parseLatenciesInfo(s string) (map[string]common.Stats, map[string
bucketNumber = 7 // <1ms to >64ms
valBucketsFloat = valBucketsFloat[:bucketNumber]
} else {
bucketNumber = len(valBucketsFloat)
bucketNumber = 15
}

buckets := make([]string, bucketNumber)
Expand Down
65 changes: 44 additions & 21 deletions static/js/models/latency/nodemodel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
*Copyright 2008-2014 by Aerospike, Inc. All rights reserved.
*Copyright 2008-2020 by Aerospike, Inc. All rights reserved.
*THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE. THE COPYRIGHT NOTICE
*ABOVE DOES NOT EVIDENCE ANY ACTUAL OR INTENDED PUBLICATION.
******************************************************************************/
Expand All @@ -11,7 +11,8 @@ define(["underscore", "backbone", "poller", "config/app-config", "views/latency/
this.modelID = this.get("model_id");
this.address = this.get("address");
this.clusterID = window.AMCGLOBALS.persistent.clusterID;//this.get("cluster_id");
this.colorScale = ["#5ACC44", "#E2BE00", "#ff7f0e", "#d62728", "#1f75fe", "#b5674d", "#926eae", "#ffaacc", "#199ebd", "#fdd9b5", "#1dacd6", "#cd4a4a", "#000000"];
this.colorScale = ["#5ACC44", "#E2BE00", "#ff7f0e", "#d62728", "#1f75fe", "#b5674d", "#926eae", "#ffaacc", "#199ebd",
"#fdd9b5", "#1dacd6", "#cd4a4a", "#566d54", "#f39385", "#e6e6fa", "#b49270", "#000000"];
this.polling = true;
this.latencyData = null;
this.legend;
Expand All @@ -37,7 +38,8 @@ define(["underscore", "backbone", "poller", "config/app-config", "views/latency/

initLatencyHistory: function (history) {
this.attributes.node_status = history.node_status || "off";
this.attributes.node_build = history.node_build || "5.0.0.0"
this.attributes.node_build = history.node_build || "5.0.0.0";
this.attributes.latency_units = history.latency_units || "msec";

if (history.latency_history != null && history.latency_history.length > 0) {

Expand Down Expand Up @@ -382,23 +384,23 @@ define(["underscore", "backbone", "poller", "config/app-config", "views/latency/
if (latency[attr].data[i][bucket].pct !== null)
pct = latency[attr].data[i][bucket].pct.toFixed(2) + "%";

if (that.latencyData[attr][0].data[i].data.length == 0 ||
if (that.latencyData[attr][0].data[i].data.length == 0 ||
that.latencyData[attr][0].data[i].data.slice(-1)[0].x != timestampUnix) {
that.latencyData[attr][0].data[i].data.push({ x: timestampUnix, y: value, secondary: pct });
that.legend.push({ color: that.colorScale[i], title: bucket });
console.debug("Latency item:" + attr + ":" + i + ":" + timestampUnix + ":" + value + ":" + pct)
console.debug("Latency item:" + attr + ":" + i + ":" + timestampUnix + ":" + value + ":" + pct);
} else {
console.log("First item or Latency item already exists: " + timestampUnix)
console.debug("First item or Latency item already exists: " + timestampUnix);
}

}
if (that.latencyData[attr][1].data.length == 0 ||
that.latencyData[attr][1].data.slice(-1)[0].x != timestampUnix) {
that.latencyData[attr][1].data.push({ x: timestampUnix, y: latency[attr]["ops/sec"], secondary: "100.00%" });
that.legend.push({ color: "#333", title: "Ops/Sec" });
console.debug("Latency ops :" + attr + ":" + " :" + timestampUnix + ":" + latency[attr]["ops/sec"])
console.debug("Latency ops :" + attr + ":" + " :" + timestampUnix + ":" + latency[attr]["ops/sec"]);
} else {
console.log("First item or Latency total already exists: " + timestampUnix)
console.debug("First item or Latency total already exists: " + timestampUnix);
}
}
},
Expand All @@ -416,7 +418,7 @@ define(["underscore", "backbone", "poller", "config/app-config", "views/latency/
}

currentLatencyTimestampUnix = currentLatencyTimestampUnix || latency[attr].timestamp_unix * 1000;
if (lastTimestampUnix == null ) {
if (lastTimestampUnix == null) {
lastTimestampUnix = model.latencyData[attr][0].data[0].data[model.latencyData[attr][0].data[0].data.length - 1].x;
}

Expand Down Expand Up @@ -507,18 +509,39 @@ define(["underscore", "backbone", "poller", "config/app-config", "views/latency/
{ '>64ms': { 'pct': null, 'value': null } }]
};
} else {
var nullData = {
'ops/sec': null, data: [
{ '&#x2264;1ms': { 'pct': null, 'value': null } },
{ '>1ms to &#x2264;2ms': { 'pct': null, 'value': null } },
{ '>2ms to &#x2264;4ms': { 'pct': null, 'value': null } },
{ '>4ms to &#x2264;8ms': { 'pct': null, 'value': null } },
{ '>8ms to &#x2264;16ms': { 'pct': null, 'value': null } },
{ '>16ms to &#x2264;32ms': { 'pct': null, 'value': null } },
{ '>32ms to &#x2264;64ms': { 'pct': null, 'value': null } },
{ '>64ms': { 'pct': null, 'value': null } }]
};

if (that.attributes.latency_units == "usec") {
var nullData = {
'ops/sec': null, data: [
{ '&#x2264;1us': { 'pct': null, 'value': null } },
{ '>1us to &#x2264;2us': { 'pct': null, 'value': null } },
{ '>2us to &#x2264;4us': { 'pct': null, 'value': null } },
{ '>4us to &#x2264;8us': { 'pct': null, 'value': null } },
{ '>8us to &#x2264;16us': { 'pct': null, 'value': null } },
{ '>16us to &#x2264;32us': { 'pct': null, 'value': null } },
{ '>32us to &#x2264;64us': { 'pct': null, 'value': null } },
{ '>64us to &#x2264;128us': { 'pct': null, 'value': null } },
{ '>128us to &#x2264;256us': { 'pct': null, 'value': null } },
{ '>256us to &#x2264;512us': { 'pct': null, 'value': null } },
{ '>512us to &#x2264;1024us': { 'pct': null, 'value': null } },
{ '>1024us to &#x2264;2048us': { 'pct': null, 'value': null } },
{ '>2048us to &#x2264;4096us': { 'pct': null, 'value': null } },
{ '>4096us to &#x2264;8192us': { 'pct': null, 'value': null } },
{ '>8192us to &#x2264;16384us': { 'pct': null, 'value': null } },
{ '>16384us': { 'pct': null, 'value': null } }]
};
} else {
var nullData = {
'ops/sec': null, data: [
{ '&#x2264;1ms': { 'pct': null, 'value': null } },
{ '>1ms to &#x2264;2ms': { 'pct': null, 'value': null } },
{ '>2ms to &#x2264;4ms': { 'pct': null, 'value': null } },
{ '>4ms to &#x2264;8ms': { 'pct': null, 'value': null } },
{ '>8ms to &#x2264;16ms': { 'pct': null, 'value': null } },
{ '>16ms to &#x2264;32ms': { 'pct': null, 'value': null } },
{ '>32ms to &#x2264;64ms': { 'pct': null, 'value': null } },
{ '>64ms': { 'pct': null, 'value': null } }]
};
}
}

nullData.timestamp = (timestamp.getHours() < 10 ? ("0" + timestamp.getHours()) : ("" + timestamp.getHours())) + ":";
Expand Down

0 comments on commit 5f84c13

Please sign in to comment.