mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 13:46:00 +00:00
profiler charts
This commit is contained in:
@@ -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,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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',
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -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,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
Reference in New Issue
Block a user