#41993: add grafanaPerformanceMetrics dynamically

pull/42230/head
Artur Wierzbicki 3 years ago
parent 9843fd385c
commit 95b17fdf88
  1. 3
      public/app/app.ts
  2. 16
      public/app/features/runtime/init.ts

@ -73,7 +73,6 @@ import { createDataSourceVariableAdapter } from './features/variables/datasource
import { createIntervalVariableAdapter } from './features/variables/interval/adapter';
import { createAdHocVariableAdapter } from './features/variables/adhoc/adapter';
import { createSystemVariableAdapter } from './features/variables/system/adapter';
import { PerformanceMetrics } from './core/services/PerformanceMetrics';
// add move to lodash for backward compatabilty with plugins
// @ts-ignore
@ -85,8 +84,6 @@ const extensionsExports = extensionsIndex.keys().map((key: any) => {
return extensionsIndex(key);
});
window.grafanaPerformanceMetrics = PerformanceMetrics.instance();
if (process.env.NODE_ENV === 'development') {
initDevFeatures();
}

@ -3,6 +3,8 @@ import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv';
import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv';
import { PerformanceMetrics } from 'app/core/services/PerformanceMetrics';
const performanceMetrics = PerformanceMetrics.instance();
/**
* This will setup features that are accessible through the root window location
*
@ -44,11 +46,17 @@ export function initWindowRuntime() {
},
performanceMetrics: {
/** Gets stats collected by the LivePerformance service and stops further collection */
getStats: () => PerformanceMetrics.instance().stopAndGetStats(),
/** Gets stats collected by the PerformanceMetrics service and stops further collection */
getStats: () => {
window.grafanaPerformanceMetrics = undefined;
return performanceMetrics.stopAndGetStats();
},
/** Enables LivePerformance to collect stats */
start: () => PerformanceMetrics.instance().start(),
/** Enables collection of performance metrics */
start: () => {
window.grafanaPerformanceMetrics = performanceMetrics;
performanceMetrics.start();
},
},
};
}

Loading…
Cancel
Save