@grafana/scenes 5.14.7 → 5.14.8--canary.858.10850008598.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. package/CHANGELOG.md +6 -6
  2. package/dist/esm/behaviors/SceneQueryController.js +60 -5
  3. package/dist/esm/behaviors/SceneQueryController.js.map +1 -1
  4. package/dist/esm/behaviors/SceneRenderProfiler.js +169 -0
  5. package/dist/esm/behaviors/SceneRenderProfiler.js.map +1 -0
  6. package/dist/esm/components/SceneRefreshPicker.js +4 -1
  7. package/dist/esm/components/SceneRefreshPicker.js.map +1 -1
  8. package/dist/esm/components/VizPanel/VizPanel.js +9 -6
  9. package/dist/esm/components/VizPanel/VizPanel.js.map +1 -1
  10. package/dist/esm/core/SceneTimeRange.js +3 -0
  11. package/dist/esm/core/SceneTimeRange.js.map +1 -1
  12. package/dist/esm/core/sceneGraph/getQueryController.js +19 -0
  13. package/dist/esm/core/sceneGraph/getQueryController.js.map +1 -0
  14. package/dist/esm/core/sceneGraph/index.js +3 -3
  15. package/dist/esm/core/sceneGraph/index.js.map +1 -1
  16. package/dist/esm/core/sceneGraph/sceneGraph.js +1 -26
  17. package/dist/esm/core/sceneGraph/sceneGraph.js.map +1 -1
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/querying/SceneQueryRunner.js +1 -3
  20. package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
  21. package/dist/esm/querying/registerQueryWithController.js +19 -2
  22. package/dist/esm/querying/registerQueryWithController.js.map +1 -1
  23. package/dist/esm/utils/getDataSource.js +17 -1
  24. package/dist/esm/utils/getDataSource.js.map +1 -1
  25. package/dist/esm/variables/adhoc/AdHocFilterRenderer.js +12 -8
  26. package/dist/esm/variables/adhoc/AdHocFilterRenderer.js.map +1 -1
  27. package/dist/esm/variables/adhoc/AdHocFiltersVariableUrlSyncHandler.js +1 -4
  28. package/dist/esm/variables/adhoc/AdHocFiltersVariableUrlSyncHandler.js.map +1 -1
  29. package/dist/esm/variables/components/VariableValueSelect.js +5 -0
  30. package/dist/esm/variables/components/VariableValueSelect.js.map +1 -1
  31. package/dist/esm/variables/utils.js.map +1 -1
  32. package/dist/esm/variables/variants/MultiValueVariable.js.map +1 -1
  33. package/dist/esm/variables/variants/TestVariable.js.map +1 -1
  34. package/dist/index.d.ts +44 -32
  35. package/dist/index.js +479 -230
  36. package/dist/index.js.map +1 -1
  37. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -85,7 +85,7 @@
85
85
 
86
86
  #### UrlSync: Support browser history steps, remove singleton ([#878](https://github.com/grafana/scenes/pull/878))
87
87
 
88
- getUrlSyncManager is no longer exported as UrlSyncManager is now no longer global singleton but local to the UrlSyncContextProvider.
88
+ getUrlSyncManager is no longer exported as UrlSyncManager is now no longer global singleton but local to the UrlSyncContextProvider.
89
89
  If you called getUrlSyncManager().getUrlState that util function is available via the exported object sceneUtils.
90
90
 
91
91
  ---
@@ -301,7 +301,7 @@ Brings a fix for [variables interpolation bug](https://github.com/grafana/scenes
301
301
 
302
302
  #### 🚀 Enhancement
303
303
 
304
- - Allow setting _skipOnLayoutChange in SceneGridLayout [#849](https://github.com/grafana/scenes/pull/849) ([@kaydelaney](https://github.com/kaydelaney))
304
+ - Allow setting \_skipOnLayoutChange in SceneGridLayout [#849](https://github.com/grafana/scenes/pull/849) ([@kaydelaney](https://github.com/kaydelaney))
305
305
 
306
306
  #### Authors: 1
307
307
 
@@ -337,7 +337,7 @@ Brings a fix for [variables interpolation bug](https://github.com/grafana/scenes
337
337
 
338
338
  #### 🚀 Enhancement
339
339
 
340
- - Wrap __sceneObject scoped var in an serialisable wrapper [#828](https://github.com/grafana/scenes/pull/828) ([@dprokop](https://github.com/dprokop))
340
+ - Wrap \_\_sceneObject scoped var in an serialisable wrapper [#828](https://github.com/grafana/scenes/pull/828) ([@dprokop](https://github.com/dprokop))
341
341
 
342
342
  #### Authors: 1
343
343
 
@@ -665,7 +665,7 @@ Brings a fix for [variables interpolation bug](https://github.com/grafana/scenes
665
665
 
666
666
  #### 🚀 Enhancement
667
667
 
668
- - Variables: Add support to read only variables and expose missing types for custom variables in core grafana [#781](https://github.com/grafana/scenes/pull/781) ([@axelavargas](https://github.com/axelavargas))
668
+ - Variables: Add support to read only variables and expose missing types for custom variables in core grafana [#781](https://github.com/grafana/scenes/pull/781) ([@axelavargas](https://github.com/axelavargas))
669
669
 
670
670
  #### Authors: 1
671
671
 
@@ -1186,7 +1186,7 @@ Brings a fix for [variables interpolation bug](https://github.com/grafana/scenes
1186
1186
 
1187
1187
  #### 🚀 Enhancement
1188
1188
 
1189
- - Fix ${__all_variables} not updating their value in panels [#698](https://github.com/grafana/scenes/pull/698) ([@axelavargas](https://github.com/axelavargas))
1189
+ - Fix ${\_\_all_variables} not updating their value in panels [#698](https://github.com/grafana/scenes/pull/698) ([@axelavargas](https://github.com/axelavargas))
1190
1190
 
1191
1191
  #### Authors: 1
1192
1192
 
@@ -1294,7 +1294,7 @@ Brings a fix for [variables interpolation bug](https://github.com/grafana/scenes
1294
1294
 
1295
1295
  #### 🐛 Bug Fix
1296
1296
 
1297
- - Clone SceneQueryRunner together with _results [#681](https://github.com/grafana/scenes/pull/681) ([@mdvictor](https://github.com/mdvictor))
1297
+ - Clone SceneQueryRunner together with \_results [#681](https://github.com/grafana/scenes/pull/681) ([@mdvictor](https://github.com/mdvictor))
1298
1298
 
1299
1299
  #### Authors: 1
1300
1300
 
@@ -1,5 +1,26 @@
1
1
  import { SceneObjectBase } from '../core/SceneObjectBase.js';
2
+ import { writeSceneLog } from '../utils/writeSceneLog.js';
3
+ import { SceneRenderProfiler } from './SceneRenderProfiler.js';
2
4
 
5
+ var __defProp = Object.defineProperty;
6
+ var __defProps = Object.defineProperties;
7
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
3
24
  var __accessCheck = (obj, member, msg) => {
4
25
  if (!member.has(obj))
5
26
  throw TypeError("Cannot " + msg);
@@ -13,22 +34,38 @@ var __privateAdd = (obj, member, value) => {
13
34
  throw TypeError("Cannot add the same private member more than once");
14
35
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
15
36
  };
16
- var _running;
37
+ var __privateSet = (obj, member, value, setter) => {
38
+ __accessCheck(obj, member, "write to private field");
39
+ setter ? setter.call(obj, value) : member.set(obj, value);
40
+ return value;
41
+ };
42
+ var _running, _tryCompleteProfileFrameId;
17
43
  function isQueryController(s) {
18
44
  return "isQueryController" in s;
19
45
  }
20
46
  class SceneQueryController extends SceneObjectBase {
21
- constructor() {
22
- super({ isRunning: false });
47
+ constructor(state = {}) {
48
+ super(__spreadProps(__spreadValues({}, state), { isRunning: false }));
23
49
  this.isQueryController = true;
50
+ this.profiler = new SceneRenderProfiler(this);
24
51
  __privateAdd(this, _running, /* @__PURE__ */ new Set());
52
+ __privateAdd(this, _tryCompleteProfileFrameId, null);
53
+ this.runningQueriesCount = () => {
54
+ return __privateGet(this, _running).size;
55
+ };
25
56
  this.addActivationHandler(() => {
26
57
  return () => __privateGet(this, _running).clear();
27
58
  });
28
59
  }
60
+ startProfile(source) {
61
+ if (!this.state.enableProfiling) {
62
+ return;
63
+ }
64
+ this.profiler.startProfile(source.constructor.name);
65
+ }
29
66
  queryStarted(entry) {
30
67
  __privateGet(this, _running).add(entry);
31
- this.changeRunningQueryCount(1);
68
+ this.changeRunningQueryCount(1, entry);
32
69
  if (!this.state.isRunning) {
33
70
  this.setState({ isRunning: true });
34
71
  }
@@ -43,9 +80,26 @@ class SceneQueryController extends SceneObjectBase {
43
80
  this.setState({ isRunning: false });
44
81
  }
45
82
  }
46
- changeRunningQueryCount(dir) {
83
+ changeRunningQueryCount(dir, entry) {
47
84
  var _a;
48
85
  window.__grafanaRunningQueryCount = ((_a = window.__grafanaRunningQueryCount) != null ? _a : 0) + dir;
86
+ if (dir === 1 && this.state.enableProfiling) {
87
+ if (entry) {
88
+ this.profiler.addCrumb(`${entry.origin.constructor.name}/${entry.type}`);
89
+ }
90
+ if (this.profiler.isTailRecording()) {
91
+ writeSceneLog(this.constructor.name, "New query started, cancelling tail recording");
92
+ this.profiler.cancelTailRecording();
93
+ }
94
+ }
95
+ if (this.state.enableProfiling) {
96
+ if (__privateGet(this, _tryCompleteProfileFrameId)) {
97
+ cancelAnimationFrame(__privateGet(this, _tryCompleteProfileFrameId));
98
+ }
99
+ __privateSet(this, _tryCompleteProfileFrameId, requestAnimationFrame(() => {
100
+ this.profiler.tryCompletingProfile();
101
+ }));
102
+ }
49
103
  }
50
104
  cancelAll() {
51
105
  var _a;
@@ -55,6 +109,7 @@ class SceneQueryController extends SceneObjectBase {
55
109
  }
56
110
  }
57
111
  _running = new WeakMap();
112
+ _tryCompleteProfileFrameId = new WeakMap();
58
113
 
59
114
  export { SceneQueryController, isQueryController };
60
115
  //# sourceMappingURL=SceneQueryController.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SceneQueryController.js","sources":["../../../src/behaviors/SceneQueryController.ts"],"sourcesContent":["import { SceneObjectBase } from '../core/SceneObjectBase';\nimport { SceneObject, SceneObjectState, SceneStatelessBehavior } from '../core/types';\nimport { DataQueryRequest } from '@grafana/data';\nimport { LoadingState } from '@grafana/schema';\n\nexport interface SceneQueryStateControllerState extends SceneObjectState {\n isRunning: boolean;\n}\n\nexport interface SceneQueryControllerLike extends SceneObject<SceneQueryStateControllerState> {\n isQueryController: true;\n cancelAll(): void;\n\n queryStarted(entry: SceneQueryControllerEntry): void;\n queryCompleted(entry: SceneQueryControllerEntry): void;\n}\n\nexport function isQueryController(s: SceneObject | SceneStatelessBehavior): s is SceneQueryControllerLike {\n return 'isQueryController' in s;\n}\n\nexport interface QueryResultWithState {\n state: LoadingState;\n}\n\nexport interface SceneQueryControllerEntry {\n request?: DataQueryRequest;\n type: SceneQueryControllerEntryType;\n origin: SceneObject;\n cancel?: () => void;\n}\n\nexport type SceneQueryControllerEntryType = 'data' | 'annotations' | 'variable' | 'alerts';\n\nexport class SceneQueryController\n extends SceneObjectBase<SceneQueryStateControllerState>\n implements SceneQueryControllerLike\n{\n public isQueryController: true = true;\n\n #running = new Set<SceneQueryControllerEntry>();\n\n public constructor() {\n super({ isRunning: false });\n\n // Clear running state on deactivate\n this.addActivationHandler(() => {\n return () => this.#running.clear();\n });\n }\n\n public queryStarted(entry: SceneQueryControllerEntry) {\n this.#running.add(entry);\n\n this.changeRunningQueryCount(1);\n\n if (!this.state.isRunning) {\n this.setState({ isRunning: true });\n }\n }\n\n public queryCompleted(entry: SceneQueryControllerEntry) {\n if (!this.#running.has(entry)) {\n return;\n }\n\n this.#running.delete(entry);\n\n this.changeRunningQueryCount(-1);\n\n if (this.#running.size === 0) {\n this.setState({ isRunning: false });\n }\n }\n\n private changeRunningQueryCount(dir: 1 | -1) {\n /**\n * Used by grafana-image-renderer to know when all queries are completed.\n */\n (window as any).__grafanaRunningQueryCount = ((window as any).__grafanaRunningQueryCount ?? 0) + dir;\n }\n\n public cancelAll() {\n for (const entry of this.#running.values()) {\n entry.cancel?.();\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,IAAA,QAAA,CAAA;AAiBO,SAAS,kBAAkB,CAAwE,EAAA;AACxG,EAAA,OAAO,mBAAuB,IAAA,CAAA,CAAA;AAChC,CAAA;AAeO,MAAM,6BACH,eAEV,CAAA;AAAA,E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AA,CAAA;AA+EI,IAAC,MAAe,CAAA,0BAAA,GAAA,CAAA,CAA+B,EAAe,GAAA,MAAA,CAAA,0BAAA,KAAf,YAA6C,CAAK,IAAA,GAAA,CAAA;AAAA,GACnG;AAAA,EAEO,SAAY,GAAA;AAlFrB,IAAA,IAAA,EAAA,CAAA;AAmFI,IAAA,KAAA,MAAW,KAAS,IAAA,YAAA,CAAA,IAAA,EAAK,QAAS,CAAA,CAAA,MAAA,EAAU,EAAA;AAC1C,MAAA,CAAA,EAAA,GAAA,KAAA,CAAM,MAAN,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,CAAA,KAAA,CAAA,CAAA;AAAA,KACF;AAAA,GACF;AACF,CAAA;AA/CE,QAAA,GAAA,IAAA,OAAA,EAAA;;;;"}
1
+ {"version":3,"file":"SceneQueryController.js","sources":["../../../src/behaviors/SceneQueryController.ts"],"sourcesContent":["import { SceneObjectBase } from '../core/SceneObjectBase';\nimport { SceneObject, SceneStatelessBehavior } from '../core/types';\nimport { writeSceneLog } from '../utils/writeSceneLog';\nimport { SceneRenderProfiler } from './SceneRenderProfiler';\nimport { SceneQueryControllerEntry, SceneQueryControllerLike, SceneQueryStateControllerState } from './types';\n\nexport function isQueryController(s: SceneObject | SceneStatelessBehavior): s is SceneQueryControllerLike {\n return 'isQueryController' in s;\n}\n\nexport class SceneQueryController\n extends SceneObjectBase<SceneQueryStateControllerState>\n implements SceneQueryControllerLike\n{\n public isQueryController: true = true;\n private profiler = new SceneRenderProfiler(this);\n\n #running = new Set<SceneQueryControllerEntry>();\n\n #tryCompleteProfileFrameId: number | null = null;\n\n // lastFrameTime: number = 0;\n\n public constructor(state: Partial<SceneQueryStateControllerState> = {}) {\n super({ ...state, isRunning: false });\n\n // Clear running state on deactivate\n this.addActivationHandler(() => {\n return () => this.#running.clear();\n });\n }\n\n public runningQueriesCount = () => {\n return this.#running.size;\n };\n public startProfile(source: SceneObject) {\n if (!this.state.enableProfiling) {\n return;\n }\n this.profiler.startProfile(source.constructor.name);\n }\n\n public queryStarted(entry: SceneQueryControllerEntry) {\n this.#running.add(entry);\n this.changeRunningQueryCount(1, entry);\n\n if (!this.state.isRunning) {\n this.setState({ isRunning: true });\n }\n }\n\n public queryCompleted(entry: SceneQueryControllerEntry) {\n if (!this.#running.has(entry)) {\n return;\n }\n\n this.#running.delete(entry);\n\n this.changeRunningQueryCount(-1);\n\n if (this.#running.size === 0) {\n this.setState({ isRunning: false });\n }\n }\n\n private changeRunningQueryCount(dir: 1 | -1, entry?: SceneQueryControllerEntry) {\n /**\n * Used by grafana-image-renderer to know when all queries are completed.\n */\n (window as any).__grafanaRunningQueryCount = ((window as any).__grafanaRunningQueryCount ?? 0) + dir;\n\n // console.log('\\tRunning queries:', (window as any).__grafanaRunningQueryCount);\n if (dir === 1 && this.state.enableProfiling) {\n if (entry) {\n // Collect profile crumbs, variables, annotations, queries and plugins\n this.profiler.addCrumb(`${entry.origin.constructor.name}/${entry.type}`);\n }\n if (this.profiler.isTailRecording()) {\n writeSceneLog(this.constructor.name, 'New query started, cancelling tail recording');\n this.profiler.cancelTailRecording();\n }\n }\n\n if (this.state.enableProfiling) {\n // Delegate to next frame to check if all queries are completed\n // This is to account for scenarios when there's \"yet another\" query that's started\n if (this.#tryCompleteProfileFrameId) {\n cancelAnimationFrame(this.#tryCompleteProfileFrameId);\n }\n\n this.#tryCompleteProfileFrameId = requestAnimationFrame(() => {\n this.profiler.tryCompletingProfile();\n });\n }\n }\n\n public cancelAll() {\n for (const entry of this.#running.values()) {\n entry.cancel?.();\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,QAAA,EAAA,0BAAA,CAAA;AAMO,SAAS,kBAAkB,CAAwE,EAAA;AACxG,EAAA,OAAO,mBAAuB,IAAA,CAAA,CAAA;AAChC,CAAA;AAEO,MAAM,6BACH,eAEV,CAAA;AAAA,EAUS,WAAA,CAAY,KAA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MAAA,IAAI,mBAAK,0BAA4B,CAAA,EAAA;AACnC,QAAA,oBAAA,CAAqB,mBAAK,0BAA0B,CAAA,CAAA,CAAA;AAAA,OACtD;AAEA,MAAK,YAAA,CAAA,IAAA,EAAA,0BAAA,EAA6B,sBAAsB,MAAM;AAC5D,QAAA,IAAA,CAAK,SAAS,oBAAqB,EAAA,CAAA;AAAA,OACpC,CAAA,CAAA,CAAA;AAAA,KACH;AAAA,GACF;AAAA,EAEO,SAAY,GAAA;AAhGrB,IAAA,IAAA,EAAA,CAAA;AAiGI,IAAA,KAAA,MAAW,KAAS,IAAA,YAAA,CAAA,IAAA,EAAK,QAAS,CAAA,CAAA,MAAA,EAAU,EAAA;AAC1C,MAAA,CAAA,EAAA,GAAA,KAAA,CAAM,MAAN,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,CAAA,KAAA,CAAA,CAAA;AAAA,KACF;AAAA,GACF;AACF,CAAA;AApFE,QAAA,GAAA,IAAA,OAAA,EAAA,CAAA;AAEA,0BAAA,GAAA,IAAA,OAAA,EAAA;;;;"}
@@ -0,0 +1,169 @@
1
+ import { writeSceneLog } from '../utils/writeSceneLog.js';
2
+
3
+ var __accessCheck = (obj, member, msg) => {
4
+ if (!member.has(obj))
5
+ throw TypeError("Cannot " + msg);
6
+ };
7
+ var __privateGet = (obj, member, getter) => {
8
+ __accessCheck(obj, member, "read from private field");
9
+ return getter ? getter.call(obj) : member.get(obj);
10
+ };
11
+ var __privateAdd = (obj, member, value) => {
12
+ if (member.has(obj))
13
+ throw TypeError("Cannot add the same private member more than once");
14
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
15
+ };
16
+ var __privateSet = (obj, member, value, setter) => {
17
+ __accessCheck(obj, member, "write to private field");
18
+ setter ? setter.call(obj, value) : member.set(obj, value);
19
+ return value;
20
+ };
21
+ var _profileInProgress, _profileStartTs, _trailAnimationFrameId, _recordedTrailingSpans;
22
+ const POST_STORM_WINDOW = 2e3;
23
+ const SPAN_THRESHOLD = 30;
24
+ class SceneRenderProfiler {
25
+ constructor(queryController) {
26
+ this.queryController = queryController;
27
+ __privateAdd(this, _profileInProgress, null);
28
+ __privateAdd(this, _profileStartTs, null);
29
+ __privateAdd(this, _trailAnimationFrameId, null);
30
+ __privateAdd(this, _recordedTrailingSpans, []);
31
+ this.lastFrameTime = 0;
32
+ this.measureTrailingFrames = (measurementStartTs, lastFrameTime, profileStartTs) => {
33
+ const currentFrameTime = performance.now();
34
+ const frameLength = currentFrameTime - lastFrameTime;
35
+ __privateGet(this, _recordedTrailingSpans).push(frameLength);
36
+ if (currentFrameTime - measurementStartTs < POST_STORM_WINDOW) {
37
+ __privateSet(this, _trailAnimationFrameId, requestAnimationFrame(
38
+ () => this.measureTrailingFrames(measurementStartTs, currentFrameTime, profileStartTs)
39
+ ));
40
+ } else {
41
+ const slowFrames = processRecordedSpans(__privateGet(this, _recordedTrailingSpans));
42
+ const slowFramesTime = slowFrames.reduce((acc, val) => acc + val, 0);
43
+ writeSceneLog(
44
+ this.constructor.name,
45
+ "Profile tail recorded, slow frames duration:",
46
+ slowFramesTime,
47
+ slowFrames,
48
+ __privateGet(this, _profileInProgress)
49
+ );
50
+ __privateSet(this, _recordedTrailingSpans, []);
51
+ const profileDuration = measurementStartTs - profileStartTs;
52
+ writeSceneLog(
53
+ this.constructor.name,
54
+ "Stoped recording, total measured time (network included):",
55
+ profileDuration + slowFramesTime
56
+ );
57
+ __privateSet(this, _trailAnimationFrameId, null);
58
+ const profileEndTs = profileStartTs + profileDuration + slowFramesTime;
59
+ performance.measure("DashboardInteraction", {
60
+ start: profileStartTs,
61
+ end: profileEndTs
62
+ });
63
+ const networkDuration = captureNetwork(profileStartTs, profileEndTs);
64
+ if (this.queryController.state.onProfileComplete) {
65
+ this.queryController.state.onProfileComplete({
66
+ origin: __privateGet(this, _profileInProgress).origin,
67
+ crumbs: __privateGet(this, _profileInProgress).crumbs,
68
+ duration: profileDuration + slowFramesTime,
69
+ networkDuration,
70
+ jsHeapSizeLimit: performance.memory ? performance.memory.jsHeapSizeLimit : 0,
71
+ usedJSHeapSize: performance.memory ? performance.memory.usedJSHeapSize : 0,
72
+ totalJSHeapSize: performance.memory ? performance.memory.totalJSHeapSize : 0
73
+ });
74
+ }
75
+ if (window.__runs) {
76
+ window.__runs += `${Date.now()}, ${profileDuration + slowFramesTime}
77
+ `;
78
+ } else {
79
+ window.__runs = `${Date.now()}, ${profileDuration + slowFramesTime}
80
+ `;
81
+ }
82
+ }
83
+ };
84
+ }
85
+ startProfile(name) {
86
+ if (__privateGet(this, _trailAnimationFrameId)) {
87
+ cancelAnimationFrame(__privateGet(this, _trailAnimationFrameId));
88
+ __privateSet(this, _trailAnimationFrameId, null);
89
+ writeSceneLog(this.constructor.name, "New profile: Stopped recording frames");
90
+ }
91
+ __privateSet(this, _profileInProgress, { origin: name, crumbs: [] });
92
+ __privateSet(this, _profileStartTs, performance.now());
93
+ writeSceneLog(this.constructor.name, "Profile started:", __privateGet(this, _profileInProgress), __privateGet(this, _profileStartTs));
94
+ }
95
+ recordProfileTail(measurementStartTime, profileStartTs) {
96
+ __privateSet(this, _trailAnimationFrameId, requestAnimationFrame(
97
+ () => this.measureTrailingFrames(measurementStartTime, measurementStartTime, profileStartTs)
98
+ ));
99
+ }
100
+ tryCompletingProfile() {
101
+ writeSceneLog(this.constructor.name, "Trying to complete profile", __privateGet(this, _profileInProgress));
102
+ if (this.queryController.runningQueriesCount() === 0 && __privateGet(this, _profileInProgress)) {
103
+ writeSceneLog(this.constructor.name, "All queries completed, stopping profile");
104
+ this.recordProfileTail(performance.now(), __privateGet(this, _profileStartTs));
105
+ }
106
+ }
107
+ isTailRecording() {
108
+ return Boolean(__privateGet(this, _trailAnimationFrameId));
109
+ }
110
+ cancelTailRecording() {
111
+ if (__privateGet(this, _trailAnimationFrameId)) {
112
+ cancelAnimationFrame(__privateGet(this, _trailAnimationFrameId));
113
+ __privateSet(this, _trailAnimationFrameId, null);
114
+ writeSceneLog(this.constructor.name, "Cancelled recording frames, new profile started");
115
+ }
116
+ }
117
+ addCrumb(crumb) {
118
+ if (__privateGet(this, _profileInProgress)) {
119
+ __privateGet(this, _profileInProgress).crumbs.push(crumb);
120
+ }
121
+ }
122
+ }
123
+ _profileInProgress = new WeakMap();
124
+ _profileStartTs = new WeakMap();
125
+ _trailAnimationFrameId = new WeakMap();
126
+ _recordedTrailingSpans = new WeakMap();
127
+ function processRecordedSpans(spans) {
128
+ for (let i = spans.length - 1; i >= 0; i--) {
129
+ if (spans[i] > SPAN_THRESHOLD) {
130
+ return spans.slice(0, i + 1);
131
+ }
132
+ }
133
+ return [spans[0]];
134
+ }
135
+ function captureNetwork(startTs, endTs) {
136
+ const entries = performance.getEntriesByType("resource");
137
+ performance.clearResourceTimings();
138
+ const networkEntries = entries.filter((entry) => entry.startTime >= startTs && entry.startTime <= endTs);
139
+ for (const entry of networkEntries) {
140
+ performance.measure("Network entry " + entry.name, {
141
+ start: entry.startTime,
142
+ end: entry.responseEnd
143
+ });
144
+ }
145
+ return calculateNetworkTime(networkEntries);
146
+ }
147
+ function calculateNetworkTime(requests) {
148
+ if (requests.length === 0) {
149
+ return 0;
150
+ }
151
+ requests.sort((a, b) => a.startTime - b.startTime);
152
+ let totalNetworkTime = 0;
153
+ let currentStart = requests[0].startTime;
154
+ let currentEnd = requests[0].responseEnd;
155
+ for (let i = 1; i < requests.length; i++) {
156
+ if (requests[i].startTime <= currentEnd) {
157
+ currentEnd = Math.max(currentEnd, requests[i].responseEnd);
158
+ } else {
159
+ totalNetworkTime += currentEnd - currentStart;
160
+ currentStart = requests[i].startTime;
161
+ currentEnd = requests[i].responseEnd;
162
+ }
163
+ }
164
+ totalNetworkTime += currentEnd - currentStart;
165
+ return totalNetworkTime;
166
+ }
167
+
168
+ export { SceneRenderProfiler };
169
+ //# sourceMappingURL=SceneRenderProfiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SceneRenderProfiler.js","sources":["../../../src/behaviors/SceneRenderProfiler.ts"],"sourcesContent":["import { writeSceneLog } from '../utils/writeSceneLog';\nimport { SceneQueryControllerLike } from './types';\n\nconst POST_STORM_WINDOW = 2000; // Time after last query to observe slow frames\nconst SPAN_THRESHOLD = 30; // Frames longer than this will be considered slow\n\nexport class SceneRenderProfiler {\n #profileInProgress: {\n // Profile origin, i.e. scene refresh picker\n origin: string;\n crumbs: string[];\n } | null = null;\n\n #profileStartTs: number | null = null;\n #trailAnimationFrameId: number | null = null;\n\n // Will keep measured lengths trailing frames\n #recordedTrailingSpans: number[] = [];\n\n lastFrameTime: number = 0;\n\n public constructor(private queryController: SceneQueryControllerLike) {}\n\n public startProfile(name: string) {\n if (this.#trailAnimationFrameId) {\n cancelAnimationFrame(this.#trailAnimationFrameId);\n this.#trailAnimationFrameId = null;\n\n writeSceneLog(this.constructor.name, 'New profile: Stopped recording frames');\n }\n\n this.#profileInProgress = { origin: name, crumbs: [] };\n this.#profileStartTs = performance.now();\n writeSceneLog(this.constructor.name, 'Profile started:', this.#profileInProgress, this.#profileStartTs);\n }\n\n private recordProfileTail(measurementStartTime: number, profileStartTs: number) {\n this.#trailAnimationFrameId = requestAnimationFrame(() =>\n this.measureTrailingFrames(measurementStartTime, measurementStartTime, profileStartTs)\n );\n }\n\n private measureTrailingFrames = (measurementStartTs: number, lastFrameTime: number, profileStartTs: number) => {\n const currentFrameTime = performance.now();\n const frameLength = currentFrameTime - lastFrameTime;\n this.#recordedTrailingSpans.push(frameLength);\n\n if (currentFrameTime - measurementStartTs! < POST_STORM_WINDOW) {\n this.#trailAnimationFrameId = requestAnimationFrame(() =>\n this.measureTrailingFrames(measurementStartTs, currentFrameTime, profileStartTs)\n );\n } else {\n const slowFrames = processRecordedSpans(this.#recordedTrailingSpans);\n const slowFramesTime = slowFrames.reduce((acc, val) => acc + val, 0);\n\n writeSceneLog(\n this.constructor.name,\n 'Profile tail recorded, slow frames duration:',\n slowFramesTime,\n slowFrames,\n this.#profileInProgress\n );\n\n this.#recordedTrailingSpans = [];\n\n const profileDuration = measurementStartTs - profileStartTs;\n\n writeSceneLog(\n this.constructor.name,\n 'Stoped recording, total measured time (network included):',\n profileDuration + slowFramesTime\n );\n this.#trailAnimationFrameId = null;\n\n // performance.measure('DashboardInteraction tail', {\n // start: measurementStartTs,\n // end: measurementStartTs + n,\n // });\n\n const profileEndTs = profileStartTs + profileDuration + slowFramesTime;\n\n performance.measure('DashboardInteraction', {\n start: profileStartTs,\n end: profileEndTs,\n });\n\n const networkDuration = captureNetwork(profileStartTs, profileEndTs);\n\n if (this.queryController.state.onProfileComplete) {\n this.queryController.state.onProfileComplete({\n origin: this.#profileInProgress!.origin,\n crumbs: this.#profileInProgress!.crumbs,\n duration: profileDuration + slowFramesTime,\n networkDuration,\n // @ts-ignore\n jsHeapSizeLimit: performance.memory ? performance.memory.jsHeapSizeLimit : 0,\n // @ts-ignore\n usedJSHeapSize: performance.memory ? performance.memory.usedJSHeapSize : 0,\n // @ts-ignore\n totalJSHeapSize: performance.memory ? performance.memory.totalJSHeapSize : 0,\n });\n }\n // @ts-ignore\n if (window.__runs) {\n // @ts-ignore\n window.__runs += `${Date.now()}, ${profileDuration + slowFramesTime}\\n`;\n } else {\n // @ts-ignore\n window.__runs = `${Date.now()}, ${profileDuration + slowFramesTime}\\n`;\n }\n }\n };\n\n public tryCompletingProfile() {\n writeSceneLog(this.constructor.name, 'Trying to complete profile', this.#profileInProgress);\n\n if (this.queryController.runningQueriesCount() === 0 && this.#profileInProgress) {\n writeSceneLog(this.constructor.name, 'All queries completed, stopping profile');\n this.recordProfileTail(performance.now(), this.#profileStartTs!);\n }\n }\n\n public isTailRecording() {\n return Boolean(this.#trailAnimationFrameId);\n }\n public cancelTailRecording() {\n if (this.#trailAnimationFrameId) {\n cancelAnimationFrame(this.#trailAnimationFrameId);\n this.#trailAnimationFrameId = null;\n writeSceneLog(this.constructor.name, 'Cancelled recording frames, new profile started');\n }\n }\n\n public addCrumb(crumb: string) {\n if (this.#profileInProgress) {\n this.#profileInProgress.crumbs.push(crumb);\n }\n }\n}\n\nfunction processRecordedSpans(spans: number[]) {\n // identifie last span in spans that's bigger than 50\n for (let i = spans.length - 1; i >= 0; i--) {\n if (spans[i] > SPAN_THRESHOLD) {\n return spans.slice(0, i + 1);\n }\n }\n return [spans[0]];\n}\n\nfunction captureNetwork(startTs: number, endTs: number) {\n const entries = performance.getEntriesByType('resource');\n performance.clearResourceTimings();\n const networkEntries = entries.filter((entry) => entry.startTime >= startTs && entry.startTime <= endTs);\n for (const entry of networkEntries) {\n performance.measure('Network entry ' + entry.name, {\n start: entry.startTime,\n end: entry.responseEnd,\n });\n }\n\n return calculateNetworkTime(networkEntries);\n}\n\n// Will calculate total time spent on Network\nfunction calculateNetworkTime(requests: PerformanceResourceTiming[]): number {\n if (requests.length === 0) {\n return 0;\n }\n\n // Step 1: Sort the requests by startTs\n requests.sort((a, b) => a.startTime - b.startTime);\n\n // Step 2: Initialize variables\n let totalNetworkTime = 0;\n let currentStart = requests[0].startTime;\n let currentEnd = requests[0].responseEnd;\n\n // Step 3: Iterate through the sorted list and merge overlapping intervals\n for (let i = 1; i < requests.length; i++) {\n if (requests[i].startTime <= currentEnd) {\n // Overlapping intervals, merge them\n currentEnd = Math.max(currentEnd, requests[i].responseEnd);\n } else {\n // Non-overlapping interval, add the duration to total time\n totalNetworkTime += currentEnd - currentStart;\n\n // Update current interval\n currentStart = requests[i].startTime;\n currentEnd = requests[i].responseEnd;\n }\n }\n\n // Step 4: Add the last interval\n totalNetworkTime += currentEnd - currentStart;\n\n return totalNetworkTime;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,IAAA,kBAAA,EAAA,eAAA,EAAA,sBAAA,EAAA,sBAAA,CAAA;AAGA,MAAM,iBAAoB,GAAA,GAAA,CAAA;AAC1B,MAAM,cAAiB,GAAA,EAAA,CAAA;AAEhB,MAAM,mBAAoB,CAAA;AAAA,EAexB,YAAoB,eAA2C,EAAA;AAA3C,IAAA,IAAA,CAA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AC/B,EAAI,IAAA,UAAA,GAAa,SAAS,CAAG,CAAA,CAAA,WAAA,CAAA;AAG7B,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,QAAA,CAAS,QAAQ,CAAK,EAAA,EAAA;AACxC,IAAI,IAAA,QAAA,CAAS,CAAG,CAAA,CAAA,SAAA,IAAa,UAAY,EAAA;AAEvC,MAAA,UAAA,GAAa,IAAK,CAAA,GAAA,CAAI,UAAY,EAAA,QAAA,CAAS,GAAG,WAAW,CAAA,CAAA;AAAA,KACpD,MAAA;AAEL,MAAA,gBAAA,IAAoB,UAAa,GAAA,YAAA,CAAA;AAGjC,MAAA,YAAA,GAAe,SAAS,CAAG,CAAA,CAAA,SAAA,CAAA;AAC3B,MAAA,UAAA,GAAa,SAAS,CAAG,CAAA,CAAA,WAAA,CAAA;AAAA,KAC3B;AAAA,GACF;AAGA,EAAA,gBAAA,IAAoB,UAAa,GAAA,YAAA,CAAA;AAEjC,EAAO,OAAA,gBAAA,CAAA;AACT;;;;"}
@@ -46,6 +46,7 @@ class SceneRefreshPicker extends SceneObjectBase {
46
46
  this._autoRefreshBlocked = false;
47
47
  this.onRefresh = () => {
48
48
  const queryController = sceneGraph.getQueryController(this);
49
+ queryController == null ? void 0 : queryController.startProfile(this);
49
50
  if (queryController == null ? void 0 : queryController.state.isRunning) {
50
51
  queryController.cancelAll();
51
52
  return;
@@ -174,7 +175,9 @@ function SceneRefreshPickerRenderer({ model }) {
174
175
  tooltip,
175
176
  width,
176
177
  text,
177
- onRefresh: model.onRefresh,
178
+ onRefresh: () => {
179
+ model.onRefresh();
180
+ },
178
181
  primary,
179
182
  onIntervalChanged: model.onIntervalChanged,
180
183
  isLoading: isRunning,
@@ -1 +1 @@
1
- {"version":3,"file":"SceneRefreshPicker.js","sources":["../../../src/components/SceneRefreshPicker.tsx"],"sourcesContent":["import React from 'react';\nimport { Unsubscribable } from 'rxjs';\nimport { rangeUtil } from '@grafana/data';\nimport { config } from '@grafana/runtime';\nimport { RefreshPicker } from '@grafana/ui';\n\nimport { SceneObjectBase } from '../core/SceneObjectBase';\nimport { sceneGraph } from '../core/sceneGraph';\nimport { SceneComponentProps, SceneObject, SceneObjectState, SceneObjectUrlValues } from '../core/types';\nimport { SceneObjectUrlSyncConfig } from '../services/SceneObjectUrlSyncConfig';\n\nexport const DEFAULT_INTERVALS = ['5s', '10s', '30s', '1m', '5m', '15m', '30m', '1h', '2h', '1d'];\n\nexport interface SceneRefreshPickerState extends SceneObjectState {\n /**\n * Refresh interval, e.g. 5s, 1m, 2h\n */\n refresh: string;\n autoEnabled?: boolean;\n autoMinInterval?: string;\n autoValue?: string;\n /**\n * List of allowed refresh intervals, e.g. ['5s', '1m']\n */\n intervals?: string[];\n isOnCanvas?: boolean;\n primary?: boolean;\n withText?: boolean;\n /**\n * Overrides the default minRefreshInterval from the grafana config. Can be set to \"0s\" to remove the minimum refresh interval.\n */\n minRefreshInterval?: string;\n}\n\nexport class SceneRefreshPicker extends SceneObjectBase<SceneRefreshPickerState> {\n public static Component = SceneRefreshPickerRenderer;\n protected _urlSync = new SceneObjectUrlSyncConfig(this, { keys: ['refresh'] });\n private _intervalTimer: ReturnType<typeof setInterval> | undefined;\n private _autoTimeRangeListener: Unsubscribable | undefined;\n private _autoRefreshBlocked: boolean = false;\n\n public constructor(state: Partial<SceneRefreshPickerState>) {\n const filterDissalowedIntervals = (i: string) => {\n const minInterval = state.minRefreshInterval ?? config.minRefreshInterval;\n return minInterval ? rangeUtil.intervalToMs(i) >= rangeUtil.intervalToMs(minInterval) : true;\n };\n\n super({\n refresh: '',\n ...state,\n autoValue: undefined,\n autoEnabled: state.autoEnabled ?? true,\n autoMinInterval: state.autoMinInterval ?? config.minRefreshInterval,\n intervals: (state.intervals ?? DEFAULT_INTERVALS).filter(filterDissalowedIntervals),\n });\n\n this.addActivationHandler(() => {\n this.setupIntervalTimer();\n\n const onVisibilityChange = () => {\n if (this._autoRefreshBlocked && document.visibilityState === 'visible') {\n this._autoRefreshBlocked = false;\n this.onRefresh();\n }\n }\n\n document.addEventListener('visibilitychange', onVisibilityChange);\n\n return () => {\n if (this._intervalTimer) {\n clearInterval(this._intervalTimer);\n }\n\n document.removeEventListener('visibilitychange', onVisibilityChange);\n this._autoTimeRangeListener?.unsubscribe();\n };\n });\n }\n\n public onRefresh = () => {\n const queryController = sceneGraph.getQueryController(this);\n if (queryController?.state.isRunning) {\n queryController.cancelAll();\n return;\n }\n\n const timeRange = sceneGraph.getTimeRange(this);\n\n if (this._intervalTimer) {\n clearInterval(this._intervalTimer);\n }\n\n timeRange.onRefresh();\n this.setupIntervalTimer();\n };\n\n public onIntervalChanged = (interval: string) => {\n this.setState({ refresh: interval });\n this.setupIntervalTimer();\n };\n\n public getUrlState() {\n return {\n refresh: this.state.refresh,\n };\n }\n\n public updateFromUrl(values: SceneObjectUrlValues) {\n const { intervals } = this.state;\n const refresh = values.refresh;\n\n if (refresh && typeof refresh === 'string') {\n if (intervals?.includes(refresh)) {\n this.setState({\n refresh,\n });\n } else {\n this.setState({\n // Default to the first refresh interval if the interval from the URL is not allowed, just like in the old architecture.\n refresh: intervals ? intervals[0] : undefined,\n });\n }\n }\n }\n\n private setupAutoTimeRangeListener = () => {\n // If the time range has changed, we need to recalculate the auto interval but prevent unnecessary processing\n return sceneGraph.getTimeRange(this).subscribeToState((newState, prevState) => {\n if (newState.from !== prevState.from || newState.to !== prevState.to) {\n this.setupIntervalTimer();\n }\n });\n };\n\n private calculateAutoRefreshInterval = () => {\n const timeRange = sceneGraph.getTimeRange(this);\n const resolution = window?.innerWidth ?? 2000;\n return rangeUtil.calculateInterval(timeRange.state.value, resolution, this.state.autoMinInterval);\n };\n\n private isTabVisible() {\n return document.visibilityState === undefined || document.visibilityState === 'visible';\n }\n\n private setupIntervalTimer = () => {\n const timeRange = sceneGraph.getTimeRange(this);\n const { refresh, intervals } = this.state;\n\n if (this._intervalTimer || refresh === '') {\n clearInterval(this._intervalTimer);\n }\n\n if (refresh === '') {\n return;\n }\n\n // If the provided interval is not allowed\n if (refresh !== RefreshPicker.autoOption.value && intervals && !intervals.includes(refresh)) {\n return;\n }\n\n let intervalMs: number;\n\n // Unsubscribe from previous listener no matter what\n this._autoTimeRangeListener?.unsubscribe();\n\n if (refresh === RefreshPicker.autoOption.value) {\n const autoRefreshInterval = this.calculateAutoRefreshInterval();\n\n intervalMs = autoRefreshInterval.intervalMs;\n\n this._autoTimeRangeListener = this.setupAutoTimeRangeListener();\n\n if (autoRefreshInterval.interval !== this.state.autoValue) {\n this.setState({ autoValue: autoRefreshInterval.interval });\n }\n } else {\n intervalMs = rangeUtil.intervalToMs(refresh);\n }\n\n this._intervalTimer = setInterval(() => {\n if (this.isTabVisible()) {\n timeRange.onRefresh();\n } else {\n this._autoRefreshBlocked = true;\n }\n }, intervalMs);\n };\n}\n\nexport function SceneRefreshPickerRenderer({ model }: SceneComponentProps<SceneRefreshPicker>) {\n const { refresh, intervals, autoEnabled, autoValue, isOnCanvas, primary, withText } = model.useState();\n const isRunning = useQueryControllerState(model);\n\n let text = refresh === RefreshPicker.autoOption?.value ? autoValue : withText ? 'Refresh' : undefined;\n let tooltip: string | undefined;\n let width: string | undefined;\n\n if (isRunning) {\n tooltip = 'Cancel all queries';\n\n if (withText) {\n text = 'Cancel';\n }\n }\n\n if (withText) {\n width = '96px';\n }\n\n return (\n <RefreshPicker\n showAutoInterval={autoEnabled}\n value={refresh}\n intervals={intervals}\n tooltip={tooltip}\n width={width}\n text={text}\n onRefresh={model.onRefresh}\n primary={primary}\n onIntervalChanged={model.onIntervalChanged}\n isLoading={isRunning}\n isOnCanvas={isOnCanvas ?? true}\n />\n );\n}\n\nfunction useQueryControllerState(model: SceneObject): boolean {\n const queryController = sceneGraph.getQueryController(model);\n if (!queryController) {\n return false;\n }\n\n return queryController.useState().isRunning;\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAWa,MAAA,iBAAA,GAAoB,CAAC,IAAA,EAAM,KA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port { Unsubscribable } from 'rxjs';\nimport { rangeUtil } from '@grafana/data';\nimport { config } from '@grafana/runtime';\nimport { RefreshPicker } from '@grafana/ui';\n\nimport { SceneObjectBase } from '../core/SceneObjectBase';\nimport { sceneGraph } from '../core/sceneGraph';\nimport { SceneComponentProps, SceneObject, SceneObjectState, SceneObjectUrlValues } from '../core/types';\nimport { SceneObjectUrlSyncConfig } from '../services/SceneObjectUrlSyncConfig';\n\nexport const DEFAULT_INTERVALS = ['5s', '10s', '30s', '1m', '5m', '15m', '30m', '1h', '2h', '1d'];\n\nexport interface SceneRefreshPickerState extends SceneObjectState {\n /**\n * Refresh interval, e.g. 5s, 1m, 2h\n */\n refresh: string;\n autoEnabled?: boolean;\n autoMinInterval?: string;\n autoValue?: string;\n /**\n * List of allowed refresh intervals, e.g. ['5s', '1m']\n */\n intervals?: string[];\n isOnCanvas?: boolean;\n primary?: boolean;\n withText?: boolean;\n /**\n * Overrides the default minRefreshInterval from the grafana config. Can be set to \"0s\" to remove the minimum refresh interval.\n */\n minRefreshInterval?: string;\n}\n\nexport class SceneRefreshPicker extends SceneObjectBase<SceneRefreshPickerState> {\n public static Component = SceneRefreshPickerRenderer;\n protected _urlSync = new SceneObjectUrlSyncConfig(this, { keys: ['refresh'] });\n private _intervalTimer: ReturnType<typeof setInterval> | undefined;\n private _autoTimeRangeListener: Unsubscribable | undefined;\n private _autoRefreshBlocked: boolean = false;\n\n public constructor(state: Partial<SceneRefreshPickerState>) {\n const filterDissalowedIntervals = (i: string) => {\n const minInterval = state.minRefreshInterval ?? config.minRefreshInterval;\n return minInterval ? rangeUtil.intervalToMs(i) >= rangeUtil.intervalToMs(minInterval) : true;\n };\n\n super({\n refresh: '',\n ...state,\n autoValue: undefined,\n autoEnabled: state.autoEnabled ?? true,\n autoMinInterval: state.autoMinInterval ?? config.minRefreshInterval,\n intervals: (state.intervals ?? DEFAULT_INTERVALS).filter(filterDissalowedIntervals),\n });\n\n this.addActivationHandler(() => {\n this.setupIntervalTimer();\n\n const onVisibilityChange = () => {\n if (this._autoRefreshBlocked && document.visibilityState === 'visible') {\n this._autoRefreshBlocked = false;\n this.onRefresh();\n }\n };\n\n document.addEventListener('visibilitychange', onVisibilityChange);\n\n return () => {\n if (this._intervalTimer) {\n clearInterval(this._intervalTimer);\n }\n\n document.removeEventListener('visibilitychange', onVisibilityChange);\n this._autoTimeRangeListener?.unsubscribe();\n };\n });\n }\n\n public onRefresh = () => {\n const queryController = sceneGraph.getQueryController(this);\n\n queryController?.startProfile(this);\n\n if (queryController?.state.isRunning) {\n queryController.cancelAll();\n return;\n }\n\n const timeRange = sceneGraph.getTimeRange(this);\n\n if (this._intervalTimer) {\n clearInterval(this._intervalTimer);\n }\n\n timeRange.onRefresh();\n this.setupIntervalTimer();\n };\n\n public onIntervalChanged = (interval: string) => {\n this.setState({ refresh: interval });\n this.setupIntervalTimer();\n };\n\n public getUrlState() {\n return {\n refresh: this.state.refresh,\n };\n }\n\n public updateFromUrl(values: SceneObjectUrlValues) {\n const { intervals } = this.state;\n const refresh = values.refresh;\n\n if (refresh && typeof refresh === 'string') {\n if (intervals?.includes(refresh)) {\n this.setState({\n refresh,\n });\n } else {\n this.setState({\n // Default to the first refresh interval if the interval from the URL is not allowed, just like in the old architecture.\n refresh: intervals ? intervals[0] : undefined,\n });\n }\n }\n }\n\n private setupAutoTimeRangeListener = () => {\n // If the time range has changed, we need to recalculate the auto interval but prevent unnecessary processing\n return sceneGraph.getTimeRange(this).subscribeToState((newState, prevState) => {\n if (newState.from !== prevState.from || newState.to !== prevState.to) {\n this.setupIntervalTimer();\n }\n });\n };\n\n private calculateAutoRefreshInterval = () => {\n const timeRange = sceneGraph.getTimeRange(this);\n const resolution = window?.innerWidth ?? 2000;\n return rangeUtil.calculateInterval(timeRange.state.value, resolution, this.state.autoMinInterval);\n };\n\n private isTabVisible() {\n return document.visibilityState === undefined || document.visibilityState === 'visible';\n }\n\n private setupIntervalTimer = () => {\n const timeRange = sceneGraph.getTimeRange(this);\n const { refresh, intervals } = this.state;\n\n if (this._intervalTimer || refresh === '') {\n clearInterval(this._intervalTimer);\n }\n\n if (refresh === '') {\n return;\n }\n\n // If the provided interval is not allowed\n if (refresh !== RefreshPicker.autoOption.value && intervals && !intervals.includes(refresh)) {\n return;\n }\n\n let intervalMs: number;\n\n // Unsubscribe from previous listener no matter what\n this._autoTimeRangeListener?.unsubscribe();\n\n if (refresh === RefreshPicker.autoOption.value) {\n const autoRefreshInterval = this.calculateAutoRefreshInterval();\n\n intervalMs = autoRefreshInterval.intervalMs;\n\n this._autoTimeRangeListener = this.setupAutoTimeRangeListener();\n\n if (autoRefreshInterval.interval !== this.state.autoValue) {\n this.setState({ autoValue: autoRefreshInterval.interval });\n }\n } else {\n intervalMs = rangeUtil.intervalToMs(refresh);\n }\n\n this._intervalTimer = setInterval(() => {\n if (this.isTabVisible()) {\n timeRange.onRefresh();\n } else {\n this._autoRefreshBlocked = true;\n }\n }, intervalMs);\n };\n}\n\nexport function SceneRefreshPickerRenderer({ model }: SceneComponentProps<SceneRefreshPicker>) {\n const { refresh, intervals, autoEnabled, autoValue, isOnCanvas, primary, withText } = model.useState();\n const isRunning = useQueryControllerState(model);\n\n let text = refresh === RefreshPicker.autoOption?.value ? autoValue : withText ? 'Refresh' : undefined;\n let tooltip: string | undefined;\n let width: string | undefined;\n\n if (isRunning) {\n tooltip = 'Cancel all queries';\n\n if (withText) {\n text = 'Cancel';\n }\n }\n\n if (withText) {\n width = '96px';\n }\n\n return (\n <RefreshPicker\n showAutoInterval={autoEnabled}\n value={refresh}\n intervals={intervals}\n tooltip={tooltip}\n width={width}\n text={text}\n onRefresh={() => {\n model.onRefresh();\n }}\n primary={primary}\n onIntervalChanged={model.onIntervalChanged}\n isLoading={isRunning}\n isOnCanvas={isOnCanvas ?? true}\n />\n );\n}\n\nfunction useQueryControllerState(model: SceneObject): boolean {\n const queryController = sceneGraph.getQueryController(model);\n if (!queryController) {\n return false;\n }\n\n return queryController.useState().isRunning;\n}\n"],"names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,EAAA,IAAI,CAAC,eAAiB,EAAA;AACpB,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AAEA,EAAO,OAAA,eAAA,CAAgB,UAAW,CAAA,SAAA,CAAA;AACpC;;;;"}
@@ -13,6 +13,7 @@ import { mergeWith, cloneDeep, isArray, merge, isEmpty } from 'lodash';
13
13
  import { UserActionEvent } from '../../core/events.js';
14
14
  import { evaluateTimeRange } from '../../utils/evaluateTimeRange.js';
15
15
  import { LiveNowTimer } from '../../behaviors/LiveNowTimer.js';
16
+ import { wrapPromiseInStateObservable, registerQueryWithController } from '../../querying/registerQueryWithController.js';
16
17
 
17
18
  var __defProp = Object.defineProperty;
18
19
  var __defProps = Object.defineProperties;
@@ -202,7 +203,13 @@ class VizPanel extends SceneObjectBase {
202
203
  } else {
203
204
  const { importPanelPlugin } = getPluginImportUtils();
204
205
  try {
205
- const result = await importPanelPlugin(pluginId);
206
+ const panelPromise = importPanelPlugin(pluginId);
207
+ const queryControler = sceneGraph.getQueryController(this);
208
+ if (queryControler && queryControler.state.enableProfiling) {
209
+ wrapPromiseInStateObservable(panelPromise).pipe(registerQueryWithController({ type: "plugin", origin: this })).subscribe(() => {
210
+ });
211
+ }
212
+ const result = await panelPromise;
206
213
  this._pluginLoaded(result, overwriteOptions, overwriteFieldConfig, isAfterPluginChange);
207
214
  } catch (err) {
208
215
  this._pluginLoaded(getPanelPluginNotFound(pluginId));
@@ -271,11 +278,7 @@ class VizPanel extends SceneObjectBase {
271
278
  }
272
279
  async changePluginType(pluginId, newOptions, newFieldConfig) {
273
280
  var _a, _b;
274
- const {
275
- options: prevOptions,
276
- fieldConfig: prevFieldConfig,
277
- pluginId: prevPluginId
278
- } = this.state;
281
+ const { options: prevOptions, fieldConfig: prevFieldConfig, pluginId: prevPluginId } = this.state;
279
282
  this._dataWithFieldConfig = void 0;
280
283
  await this._loadPlugin(pluginId, newOptions != null ? newOptions : {}, newFieldConfig, true);
281
284
  const panel = {