datasource: query performance logging
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import config from 'grafana/app/core/config';
|
||||||
import * as dateMath from 'grafana/app/core/utils/datemath';
|
import * as dateMath from 'grafana/app/core/utils/datemath';
|
||||||
import * as utils from './utils';
|
import * as utils from './utils';
|
||||||
import * as migrations from './migrations';
|
import * as migrations from './migrations';
|
||||||
@@ -18,6 +19,8 @@ export class ZabbixDatasource {
|
|||||||
this.templateSrv = templateSrv;
|
this.templateSrv = templateSrv;
|
||||||
this.zabbixAlertingSrv = zabbixAlertingSrv;
|
this.zabbixAlertingSrv = zabbixAlertingSrv;
|
||||||
|
|
||||||
|
this.enableDebugLog = config.buildInfo.env === 'development';
|
||||||
|
|
||||||
// Use custom format for template variables
|
// Use custom format for template variables
|
||||||
this.replaceTemplateVars = _.partial(replaceTemplateVars, this.templateSrv);
|
this.replaceTemplateVars = _.partial(replaceTemplateVars, this.templateSrv);
|
||||||
|
|
||||||
@@ -165,11 +168,21 @@ export class ZabbixDatasource {
|
|||||||
* Query target data for Metrics mode
|
* Query target data for Metrics mode
|
||||||
*/
|
*/
|
||||||
queryNumericData(target, timeRange, useTrends, options) {
|
queryNumericData(target, timeRange, useTrends, options) {
|
||||||
|
let queryStart, queryEnd;
|
||||||
let getItemOptions = {
|
let getItemOptions = {
|
||||||
itemtype: 'num'
|
itemtype: 'num'
|
||||||
};
|
};
|
||||||
return this.zabbix.getItemsFromTarget(target, getItemOptions)
|
return this.zabbix.getItemsFromTarget(target, getItemOptions)
|
||||||
.then(items => this.queryNumericDataForItems(items, target, timeRange, useTrends, options));
|
.then(items => {
|
||||||
|
queryStart = new Date().getTime();
|
||||||
|
return this.queryNumericDataForItems(items, target, timeRange, useTrends, options);
|
||||||
|
}).then(result => {
|
||||||
|
queryEnd = new Date().getTime();
|
||||||
|
if (this.enableDebugLog) {
|
||||||
|
console.log(`Datasource::Performance Query Time (${this.name}): ${queryEnd - queryStart}`);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user