Skip to content

Commit

Permalink
feat(h5-test): add ckv report
Browse files Browse the repository at this point in the history
  • Loading branch information
huangyoukun committed Jul 9, 2018
1 parent 2096405 commit b22f8e0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bin/tsw/api/tnm2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


const serverInfo = require('serverInfo.js');
const mapping = require('./mapping.json');
const mapping = require('api/tnm2/mapping.json');
const url = require('url');
const Deferred = require('util/Deferred');
const cluster = require('cluster');
Expand Down
5 changes: 3 additions & 2 deletions bin/tsw/api/tnm2/mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
"SUM_TSW_WEBSOCKET_ERROR" : 1253122,
"SUM_TSW_WEBSOCKET_CLOSE" : 1253126,

"AVG_TSW_CKV_QUEUE_COST" : 1253127,
"AVG_TSW_CKV_COST" : 1253129,
"SUM_TSW_CKV_CMD" : 1253127,
"AVG_TSW_CKV_QUEUE_COST" : 1253128,
"AVG_TSW_CKV_CMD_COST" : 1253129,

"AVG_TSW_CPU_LOAD_1" : 1280713,
"AVG_TSW_CPU_LOAD_5" : 1280714,
Expand Down
9 changes: 9 additions & 0 deletions bin/tsw/pool/cmem.l5.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
const logger = require('logger');
const Queue = require('util/Queue');
const dcapi = require('api/libdcapi/dcapi.js');
const tnm2 = require('api/tnm2');
const L5 = require('api/L5/L5.api.js');
const { isWin32Like } = require('util/isWindows.js');
let cache = global[__filename];
Expand Down Expand Up @@ -83,7 +84,13 @@ function queueWrap(memcached) {
const servers = memcached.servers && memcached.servers[0];
const start = Date.now();

tnm2.Attr_API('SUM_TSW_CKV_CMD', 1);

queue.queue(function() {
const startQueue = Date.now();
const costQueue = startQueue - start;

tnm2.Attr_API_Set('AVG_TSW_CKV_QUEUE_COST', costQueue);

const fn = (function(queryCompiler) {
return function() {
Expand Down Expand Up @@ -119,6 +126,8 @@ function queueWrap(memcached) {
}
}

tnm2.Attr_API_Set('AVG_TSW_CKV_CMD_COST', Date.now() - startQueue);

dcapi.report({
key: 'EVENT_TSW_MEMCACHED',
toIp: toIp,
Expand Down

0 comments on commit b22f8e0

Please sign in to comment.