datasource: query performance logging
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import _ from 'lodash';
|
||||
import config from 'grafana/app/core/config';
|
||||
import * as dateMath from 'grafana/app/core/utils/datemath';
|
||||
import * as utils from './utils';
|
||||
import * as migrations from './migrations';
|
||||
@@ -18,6 +19,8 @@ export class ZabbixDatasource {
|
||||
this.templateSrv = templateSrv;
|
||||
this.zabbixAlertingSrv = zabbixAlertingSrv;
|
||||
|
||||
this.enableDebugLog = config.buildInfo.env === 'development';
|
||||
|
||||
// Use custom format for template variables
|
||||
this.replaceTemplateVars = _.partial(replaceTemplateVars, this.templateSrv);
|
||||
|
||||
@@ -165,11 +168,21 @@ export class ZabbixDatasource {
|
||||
* Query target data for Metrics mode
|
||||
*/
|
||||
queryNumericData(target, timeRange, useTrends, options) {
|
||||
let queryStart, queryEnd;
|
||||
let getItemOptions = {
|
||||
itemtype: 'num'
|
||||
};
|
||||
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