profiler charts

This commit is contained in:
Jan Prochazka
2022-12-18 13:48:24 +01:00
parent 9a2631dc09
commit 2e37788471
9 changed files with 110 additions and 45 deletions

View File

@@ -1,12 +1,16 @@
const driver = require('./driver');
const formatProfilerEntry = require('../frontend/formatProfilerEntry');
const formatProfilerChartEntry = require('../frontend/formatProfilerChartEntry');
const {
formatProfilerEntry,
extractProfileTimestamp,
aggregateProfileChartEntry,
} = require('../frontend/profilerFunctions');
module.exports = {
packageName: 'dbgate-plugin-mongo',
drivers: [driver],
functions: {
formatProfilerEntry,
formatProfilerChartEntry,
extractProfileTimestamp,
aggregateProfileChartEntry,
},
};

View File

@@ -35,10 +35,15 @@ const driver = {
supportsServerSummary: true,
supportsDatabaseProfiler: true,
profilerFormatterFunction: 'formatProfilerEntry@dbgate-plugin-mongo',
profilerChartFormatterFunction: 'formatProfilerChartEntry@dbgate-plugin-mongo',
profilerTimestampFunction: 'extractProfileTimestamp@dbgate-plugin-mongo',
profilerChartAggregateFunction: 'aggregateProfileChartEntry@dbgate-plugin-mongo',
profilerChartMeasures: [
{ label: 'Req count', field: 'count' },
{ label: 'Duration', field: 'millis' },
{ label: 'Req count/s', field: 'countPerSec' },
{ label: 'Avg duration', field: 'avgDuration' },
// { label: 'Req count/s', field: 'countPerSec', perSecond: true },
// { field: 'countAll', hidden: true },
// { label: 'Avg duration', field: 'millis', perField: 'countAll' },
],
databaseUrlPlaceholder: 'e.g. mongodb://username:password@mongodb.mydomain.net/dbname',

View File

@@ -1,14 +0,0 @@
const _ = require('lodash');
const formatProfilerEntry = require('./formatProfilerEntry');
function formatProfilerChartEntry(obj) {
const fmt = formatProfilerEntry(obj);
return {
ts: fmt.ts,
millis: fmt.stats.millis,
count: 1,
};
}
module.exports = formatProfilerChartEntry;

View File

@@ -1,12 +1,12 @@
import driver from './driver';
import formatProfilerEntry from './formatProfilerEntry';
import formatProfilerChartEntry from './formatProfilerChartEntry';
import { formatProfilerEntry, extractProfileTimestamp, aggregateProfileChartEntry } from './profilerFunctions';
export default {
packageName: 'dbgate-plugin-mongo',
drivers: [driver],
functions: {
formatProfilerEntry,
formatProfilerChartEntry,
extractProfileTimestamp,
aggregateProfileChartEntry,
},
};

View File

@@ -69,4 +69,33 @@ function formatProfilerEntry(obj) {
};
}
module.exports = formatProfilerEntry;
function extractProfileTimestamp(obj) {
return obj.ts;
}
function aggregateProfileChartEntry(aggr, obj, stepDuration) {
// const fmt = formatProfilerEntry(obj);
const countAll = (aggr.countAll || 0) + 1;
const sumMillis = (aggr.sumMillis || 0) + obj.millis;
return {
countAll,
sumMillis,
countPerSec: (countAll / stepDuration) * 1000,
avgDuration: sumMillis / countAll,
};
// return {
// ts: fmt.ts,
// millis: fmt.stats.millis,
// countAll: 1,
// countPerSec: 1,
// };
}
module.exports = {
formatProfilerEntry,
extractProfileTimestamp,
aggregateProfileChartEntry,
};