@grafana/scenes 5.14.6 → 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 (39) hide show
  1. package/CHANGELOG.md +19 -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/AdHocFiltersVariable.js +11 -7
  28. package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
  29. package/dist/esm/variables/adhoc/AdHocFiltersVariableUrlSyncHandler.js +1 -4
  30. package/dist/esm/variables/adhoc/AdHocFiltersVariableUrlSyncHandler.js.map +1 -1
  31. package/dist/esm/variables/components/VariableValueSelect.js +5 -0
  32. package/dist/esm/variables/components/VariableValueSelect.js.map +1 -1
  33. package/dist/esm/variables/utils.js.map +1 -1
  34. package/dist/esm/variables/variants/MultiValueVariable.js.map +1 -1
  35. package/dist/esm/variables/variants/TestVariable.js.map +1 -1
  36. package/dist/index.d.ts +44 -32
  37. package/dist/index.js +490 -237
  38. package/dist/index.js.map +1 -1
  39. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -41,19 +41,19 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
41
41
  var uFuzzy__default = /*#__PURE__*/_interopDefaultLegacy(uFuzzy);
42
42
  var ReactGridLayout__default = /*#__PURE__*/_interopDefaultLegacy(ReactGridLayout);
43
43
 
44
- var __defProp$O = Object.defineProperty;
45
- var __getOwnPropSymbols$O = Object.getOwnPropertySymbols;
46
- var __hasOwnProp$O = Object.prototype.hasOwnProperty;
47
- var __propIsEnum$O = Object.prototype.propertyIsEnumerable;
48
- var __defNormalProp$O = (obj, key, value) => key in obj ? __defProp$O(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
49
- var __spreadValues$O = (a, b) => {
44
+ var __defProp$P = Object.defineProperty;
45
+ var __getOwnPropSymbols$P = Object.getOwnPropertySymbols;
46
+ var __hasOwnProp$P = Object.prototype.hasOwnProperty;
47
+ var __propIsEnum$P = Object.prototype.propertyIsEnumerable;
48
+ var __defNormalProp$P = (obj, key, value) => key in obj ? __defProp$P(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
49
+ var __spreadValues$P = (a, b) => {
50
50
  for (var prop in b || (b = {}))
51
- if (__hasOwnProp$O.call(b, prop))
52
- __defNormalProp$O(a, prop, b[prop]);
53
- if (__getOwnPropSymbols$O)
54
- for (var prop of __getOwnPropSymbols$O(b)) {
55
- if (__propIsEnum$O.call(b, prop))
56
- __defNormalProp$O(a, prop, b[prop]);
51
+ if (__hasOwnProp$P.call(b, prop))
52
+ __defNormalProp$P(a, prop, b[prop]);
53
+ if (__getOwnPropSymbols$P)
54
+ for (var prop of __getOwnPropSymbols$P(b)) {
55
+ if (__propIsEnum$P.call(b, prop))
56
+ __defNormalProp$P(a, prop, b[prop]);
57
57
  }
58
58
  return a;
59
59
  };
@@ -62,7 +62,7 @@ function useAppQueryParams() {
62
62
  return runtime.locationSearchToObject(location.search || "");
63
63
  }
64
64
  function getUrlWithAppState(path, preserveParams) {
65
- const paramsCopy = __spreadValues$O({}, runtime.locationService.getSearchObject());
65
+ const paramsCopy = __spreadValues$P({}, runtime.locationService.getSearchObject());
66
66
  if (preserveParams) {
67
67
  for (const key of Object.keys(paramsCopy)) {
68
68
  if (!preserveParams.includes(key)) {
@@ -76,31 +76,31 @@ function renderSceneComponentWithRouteProps(sceneObject, routeProps) {
76
76
  return React__default["default"].createElement(sceneObject.Component, { model: sceneObject, routeProps });
77
77
  }
78
78
 
79
- var __defProp$N = Object.defineProperty;
80
- var __defProps$u = Object.defineProperties;
81
- var __getOwnPropDescs$u = Object.getOwnPropertyDescriptors;
82
- var __getOwnPropSymbols$N = Object.getOwnPropertySymbols;
83
- var __hasOwnProp$N = Object.prototype.hasOwnProperty;
84
- var __propIsEnum$N = Object.prototype.propertyIsEnumerable;
85
- var __defNormalProp$N = (obj, key, value) => key in obj ? __defProp$N(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
86
- var __spreadValues$N = (a, b) => {
79
+ var __defProp$O = Object.defineProperty;
80
+ var __defProps$v = Object.defineProperties;
81
+ var __getOwnPropDescs$v = Object.getOwnPropertyDescriptors;
82
+ var __getOwnPropSymbols$O = Object.getOwnPropertySymbols;
83
+ var __hasOwnProp$O = Object.prototype.hasOwnProperty;
84
+ var __propIsEnum$O = Object.prototype.propertyIsEnumerable;
85
+ var __defNormalProp$O = (obj, key, value) => key in obj ? __defProp$O(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
86
+ var __spreadValues$O = (a, b) => {
87
87
  for (var prop in b || (b = {}))
88
- if (__hasOwnProp$N.call(b, prop))
89
- __defNormalProp$N(a, prop, b[prop]);
90
- if (__getOwnPropSymbols$N)
91
- for (var prop of __getOwnPropSymbols$N(b)) {
92
- if (__propIsEnum$N.call(b, prop))
93
- __defNormalProp$N(a, prop, b[prop]);
88
+ if (__hasOwnProp$O.call(b, prop))
89
+ __defNormalProp$O(a, prop, b[prop]);
90
+ if (__getOwnPropSymbols$O)
91
+ for (var prop of __getOwnPropSymbols$O(b)) {
92
+ if (__propIsEnum$O.call(b, prop))
93
+ __defNormalProp$O(a, prop, b[prop]);
94
94
  }
95
95
  return a;
96
96
  };
97
- var __spreadProps$u = (a, b) => __defProps$u(a, __getOwnPropDescs$u(b));
97
+ var __spreadProps$v = (a, b) => __defProps$v(a, __getOwnPropDescs$v(b));
98
98
  const runtimePanelPlugins = /* @__PURE__ */ new Map();
99
99
  function registerRuntimePanelPlugin({ pluginId, plugin }) {
100
100
  if (runtimePanelPlugins.has(pluginId)) {
101
101
  throw new Error(`A runtime panel plugin with id ${pluginId} has already been registered`);
102
102
  }
103
- plugin.meta = __spreadProps$u(__spreadValues$N({}, plugin.meta), {
103
+ plugin.meta = __spreadProps$v(__spreadValues$O({}, plugin.meta), {
104
104
  id: pluginId,
105
105
  name: pluginId,
106
106
  module: "runtime plugin",
@@ -128,33 +128,33 @@ function loadPanelPluginSync(pluginId) {
128
128
  return (_a = getPanelPluginFromCache(pluginId)) != null ? _a : runtimePanelPlugins.get(pluginId);
129
129
  }
130
130
 
131
- var __defProp$M = Object.defineProperty;
132
- var __defProps$t = Object.defineProperties;
133
- var __getOwnPropDescs$t = Object.getOwnPropertyDescriptors;
134
- var __getOwnPropSymbols$M = Object.getOwnPropertySymbols;
135
- var __hasOwnProp$M = Object.prototype.hasOwnProperty;
136
- var __propIsEnum$M = Object.prototype.propertyIsEnumerable;
137
- var __defNormalProp$M = (obj, key, value) => key in obj ? __defProp$M(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
138
- var __spreadValues$M = (a, b) => {
131
+ var __defProp$N = Object.defineProperty;
132
+ var __defProps$u = Object.defineProperties;
133
+ var __getOwnPropDescs$u = Object.getOwnPropertyDescriptors;
134
+ var __getOwnPropSymbols$N = Object.getOwnPropertySymbols;
135
+ var __hasOwnProp$N = Object.prototype.hasOwnProperty;
136
+ var __propIsEnum$N = Object.prototype.propertyIsEnumerable;
137
+ var __defNormalProp$N = (obj, key, value) => key in obj ? __defProp$N(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
138
+ var __spreadValues$N = (a, b) => {
139
139
  for (var prop in b || (b = {}))
140
- if (__hasOwnProp$M.call(b, prop))
141
- __defNormalProp$M(a, prop, b[prop]);
142
- if (__getOwnPropSymbols$M)
143
- for (var prop of __getOwnPropSymbols$M(b)) {
144
- if (__propIsEnum$M.call(b, prop))
145
- __defNormalProp$M(a, prop, b[prop]);
140
+ if (__hasOwnProp$N.call(b, prop))
141
+ __defNormalProp$N(a, prop, b[prop]);
142
+ if (__getOwnPropSymbols$N)
143
+ for (var prop of __getOwnPropSymbols$N(b)) {
144
+ if (__propIsEnum$N.call(b, prop))
145
+ __defNormalProp$N(a, prop, b[prop]);
146
146
  }
147
147
  return a;
148
148
  };
149
- var __spreadProps$t = (a, b) => __defProps$t(a, __getOwnPropDescs$t(b));
149
+ var __spreadProps$u = (a, b) => __defProps$u(a, __getOwnPropDescs$u(b));
150
150
  var __objRest$5 = (source, exclude) => {
151
151
  var target = {};
152
152
  for (var prop in source)
153
- if (__hasOwnProp$M.call(source, prop) && exclude.indexOf(prop) < 0)
153
+ if (__hasOwnProp$N.call(source, prop) && exclude.indexOf(prop) < 0)
154
154
  target[prop] = source[prop];
155
- if (source != null && __getOwnPropSymbols$M)
156
- for (var prop of __getOwnPropSymbols$M(source)) {
157
- if (exclude.indexOf(prop) < 0 && __propIsEnum$M.call(source, prop))
155
+ if (source != null && __getOwnPropSymbols$N)
156
+ for (var prop of __getOwnPropSymbols$N(source)) {
157
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$N.call(source, prop))
158
158
  target[prop] = source[prop];
159
159
  }
160
160
  return target;
@@ -172,7 +172,7 @@ function SceneComponentWrapperWithoutMemo(_a) {
172
172
  if (!model.isActive) {
173
173
  return null;
174
174
  }
175
- return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$t(__spreadValues$M({}, otherProps), {
175
+ return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$u(__spreadValues$N({}, otherProps), {
176
176
  model
177
177
  }));
178
178
  }
@@ -188,49 +188,49 @@ class UserActionEvent extends data.BusEventWithPayload {
188
188
  }
189
189
  UserActionEvent.type = "scene-object-user-action";
190
190
 
191
- var __accessCheck$3 = (obj, member, msg) => {
191
+ var __accessCheck$4 = (obj, member, msg) => {
192
192
  if (!member.has(obj))
193
193
  throw TypeError("Cannot " + msg);
194
194
  };
195
- var __privateGet$3 = (obj, member, getter) => {
196
- __accessCheck$3(obj, member, "read from private field");
195
+ var __privateGet$4 = (obj, member, getter) => {
196
+ __accessCheck$4(obj, member, "read from private field");
197
197
  return getter ? getter.call(obj) : member.get(obj);
198
198
  };
199
- var __privateAdd$3 = (obj, member, value) => {
199
+ var __privateAdd$4 = (obj, member, value) => {
200
200
  if (member.has(obj))
201
201
  throw TypeError("Cannot add the same private member more than once");
202
202
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
203
203
  };
204
- var __privateSet$2 = (obj, member, value, setter) => {
205
- __accessCheck$3(obj, member, "write to private field");
204
+ var __privateSet$4 = (obj, member, value, setter) => {
205
+ __accessCheck$4(obj, member, "write to private field");
206
206
  setter ? setter.call(obj, value) : member.set(obj, value);
207
207
  return value;
208
208
  };
209
209
  var _ref;
210
210
  class SceneObjectRef {
211
211
  constructor(ref) {
212
- __privateAdd$3(this, _ref, void 0);
213
- __privateSet$2(this, _ref, ref);
212
+ __privateAdd$4(this, _ref, void 0);
213
+ __privateSet$4(this, _ref, ref);
214
214
  }
215
215
  resolve() {
216
- return __privateGet$3(this, _ref);
216
+ return __privateGet$4(this, _ref);
217
217
  }
218
218
  }
219
219
  _ref = new WeakMap();
220
220
 
221
- var __defProp$L = Object.defineProperty;
222
- var __getOwnPropSymbols$L = Object.getOwnPropertySymbols;
223
- var __hasOwnProp$L = Object.prototype.hasOwnProperty;
224
- var __propIsEnum$L = Object.prototype.propertyIsEnumerable;
225
- var __defNormalProp$L = (obj, key, value) => key in obj ? __defProp$L(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
226
- var __spreadValues$L = (a, b) => {
221
+ var __defProp$M = Object.defineProperty;
222
+ var __getOwnPropSymbols$M = Object.getOwnPropertySymbols;
223
+ var __hasOwnProp$M = Object.prototype.hasOwnProperty;
224
+ var __propIsEnum$M = Object.prototype.propertyIsEnumerable;
225
+ var __defNormalProp$M = (obj, key, value) => key in obj ? __defProp$M(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
226
+ var __spreadValues$M = (a, b) => {
227
227
  for (var prop in b || (b = {}))
228
- if (__hasOwnProp$L.call(b, prop))
229
- __defNormalProp$L(a, prop, b[prop]);
230
- if (__getOwnPropSymbols$L)
231
- for (var prop of __getOwnPropSymbols$L(b)) {
232
- if (__propIsEnum$L.call(b, prop))
233
- __defNormalProp$L(a, prop, b[prop]);
228
+ if (__hasOwnProp$M.call(b, prop))
229
+ __defNormalProp$M(a, prop, b[prop]);
230
+ if (__getOwnPropSymbols$M)
231
+ for (var prop of __getOwnPropSymbols$M(b)) {
232
+ if (__propIsEnum$M.call(b, prop))
233
+ __defNormalProp$M(a, prop, b[prop]);
234
234
  }
235
235
  return a;
236
236
  };
@@ -293,7 +293,7 @@ class SceneObjectBase {
293
293
  }
294
294
  setState(update) {
295
295
  const prevState = this._state;
296
- const newState = __spreadValues$L(__spreadValues$L({}, this._state), update);
296
+ const newState = __spreadValues$M(__spreadValues$M({}, this._state), update);
297
297
  this._state = Object.freeze(newState);
298
298
  this._setParent(update);
299
299
  this._handleActivationOfChangedStateProps(prevState, newState);
@@ -489,19 +489,19 @@ function forEachChild(state, callback) {
489
489
  }
490
490
  }
491
491
 
492
- var __defProp$K = Object.defineProperty;
493
- var __getOwnPropSymbols$K = Object.getOwnPropertySymbols;
494
- var __hasOwnProp$K = Object.prototype.hasOwnProperty;
495
- var __propIsEnum$K = Object.prototype.propertyIsEnumerable;
496
- var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
497
- var __spreadValues$K = (a, b) => {
492
+ var __defProp$L = Object.defineProperty;
493
+ var __getOwnPropSymbols$L = Object.getOwnPropertySymbols;
494
+ var __hasOwnProp$L = Object.prototype.hasOwnProperty;
495
+ var __propIsEnum$L = Object.prototype.propertyIsEnumerable;
496
+ var __defNormalProp$L = (obj, key, value) => key in obj ? __defProp$L(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
497
+ var __spreadValues$L = (a, b) => {
498
498
  for (var prop in b || (b = {}))
499
- if (__hasOwnProp$K.call(b, prop))
500
- __defNormalProp$K(a, prop, b[prop]);
501
- if (__getOwnPropSymbols$K)
502
- for (var prop of __getOwnPropSymbols$K(b)) {
503
- if (__propIsEnum$K.call(b, prop))
504
- __defNormalProp$K(a, prop, b[prop]);
499
+ if (__hasOwnProp$L.call(b, prop))
500
+ __defNormalProp$L(a, prop, b[prop]);
501
+ if (__getOwnPropSymbols$L)
502
+ for (var prop of __getOwnPropSymbols$L(b)) {
503
+ if (__propIsEnum$L.call(b, prop))
504
+ __defNormalProp$L(a, prop, b[prop]);
505
505
  }
506
506
  return a;
507
507
  };
@@ -510,7 +510,7 @@ function cloneSceneObject(sceneObject, withState) {
510
510
  return new sceneObject.constructor(clonedState);
511
511
  }
512
512
  function cloneSceneObjectState(sceneState, withState) {
513
- const clonedState = __spreadValues$K({}, sceneState);
513
+ const clonedState = __spreadValues$L({}, sceneState);
514
514
  for (const key in clonedState) {
515
515
  const propValue = clonedState[key];
516
516
  if (propValue instanceof SceneObjectBase) {
@@ -607,6 +607,305 @@ function lookupVariable(name, sceneObject) {
607
607
  return null;
608
608
  }
609
609
 
610
+ function writeSceneLog(logger, message, ...rest) {
611
+ let loggingEnabled = false;
612
+ if (typeof window !== "undefined") {
613
+ loggingEnabled = localStorage.getItem("grafana.debug.scenes") === "true";
614
+ }
615
+ if (loggingEnabled) {
616
+ console.log(`${logger}: `, message, ...rest);
617
+ }
618
+ }
619
+
620
+ var __accessCheck$3 = (obj, member, msg) => {
621
+ if (!member.has(obj))
622
+ throw TypeError("Cannot " + msg);
623
+ };
624
+ var __privateGet$3 = (obj, member, getter) => {
625
+ __accessCheck$3(obj, member, "read from private field");
626
+ return getter ? getter.call(obj) : member.get(obj);
627
+ };
628
+ var __privateAdd$3 = (obj, member, value) => {
629
+ if (member.has(obj))
630
+ throw TypeError("Cannot add the same private member more than once");
631
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
632
+ };
633
+ var __privateSet$3 = (obj, member, value, setter) => {
634
+ __accessCheck$3(obj, member, "write to private field");
635
+ setter ? setter.call(obj, value) : member.set(obj, value);
636
+ return value;
637
+ };
638
+ var _profileInProgress, _profileStartTs, _trailAnimationFrameId, _recordedTrailingSpans;
639
+ const POST_STORM_WINDOW = 2e3;
640
+ const SPAN_THRESHOLD = 30;
641
+ class SceneRenderProfiler {
642
+ constructor(queryController) {
643
+ this.queryController = queryController;
644
+ __privateAdd$3(this, _profileInProgress, null);
645
+ __privateAdd$3(this, _profileStartTs, null);
646
+ __privateAdd$3(this, _trailAnimationFrameId, null);
647
+ __privateAdd$3(this, _recordedTrailingSpans, []);
648
+ this.lastFrameTime = 0;
649
+ this.measureTrailingFrames = (measurementStartTs, lastFrameTime, profileStartTs) => {
650
+ const currentFrameTime = performance.now();
651
+ const frameLength = currentFrameTime - lastFrameTime;
652
+ __privateGet$3(this, _recordedTrailingSpans).push(frameLength);
653
+ if (currentFrameTime - measurementStartTs < POST_STORM_WINDOW) {
654
+ __privateSet$3(this, _trailAnimationFrameId, requestAnimationFrame(
655
+ () => this.measureTrailingFrames(measurementStartTs, currentFrameTime, profileStartTs)
656
+ ));
657
+ } else {
658
+ const slowFrames = processRecordedSpans(__privateGet$3(this, _recordedTrailingSpans));
659
+ const slowFramesTime = slowFrames.reduce((acc, val) => acc + val, 0);
660
+ writeSceneLog(
661
+ this.constructor.name,
662
+ "Profile tail recorded, slow frames duration:",
663
+ slowFramesTime,
664
+ slowFrames,
665
+ __privateGet$3(this, _profileInProgress)
666
+ );
667
+ __privateSet$3(this, _recordedTrailingSpans, []);
668
+ const profileDuration = measurementStartTs - profileStartTs;
669
+ writeSceneLog(
670
+ this.constructor.name,
671
+ "Stoped recording, total measured time (network included):",
672
+ profileDuration + slowFramesTime
673
+ );
674
+ __privateSet$3(this, _trailAnimationFrameId, null);
675
+ const profileEndTs = profileStartTs + profileDuration + slowFramesTime;
676
+ performance.measure("DashboardInteraction", {
677
+ start: profileStartTs,
678
+ end: profileEndTs
679
+ });
680
+ const networkDuration = captureNetwork(profileStartTs, profileEndTs);
681
+ if (this.queryController.state.onProfileComplete) {
682
+ this.queryController.state.onProfileComplete({
683
+ origin: __privateGet$3(this, _profileInProgress).origin,
684
+ crumbs: __privateGet$3(this, _profileInProgress).crumbs,
685
+ duration: profileDuration + slowFramesTime,
686
+ networkDuration,
687
+ jsHeapSizeLimit: performance.memory ? performance.memory.jsHeapSizeLimit : 0,
688
+ usedJSHeapSize: performance.memory ? performance.memory.usedJSHeapSize : 0,
689
+ totalJSHeapSize: performance.memory ? performance.memory.totalJSHeapSize : 0
690
+ });
691
+ }
692
+ if (window.__runs) {
693
+ window.__runs += `${Date.now()}, ${profileDuration + slowFramesTime}
694
+ `;
695
+ } else {
696
+ window.__runs = `${Date.now()}, ${profileDuration + slowFramesTime}
697
+ `;
698
+ }
699
+ }
700
+ };
701
+ }
702
+ startProfile(name) {
703
+ if (__privateGet$3(this, _trailAnimationFrameId)) {
704
+ cancelAnimationFrame(__privateGet$3(this, _trailAnimationFrameId));
705
+ __privateSet$3(this, _trailAnimationFrameId, null);
706
+ writeSceneLog(this.constructor.name, "New profile: Stopped recording frames");
707
+ }
708
+ __privateSet$3(this, _profileInProgress, { origin: name, crumbs: [] });
709
+ __privateSet$3(this, _profileStartTs, performance.now());
710
+ writeSceneLog(this.constructor.name, "Profile started:", __privateGet$3(this, _profileInProgress), __privateGet$3(this, _profileStartTs));
711
+ }
712
+ recordProfileTail(measurementStartTime, profileStartTs) {
713
+ __privateSet$3(this, _trailAnimationFrameId, requestAnimationFrame(
714
+ () => this.measureTrailingFrames(measurementStartTime, measurementStartTime, profileStartTs)
715
+ ));
716
+ }
717
+ tryCompletingProfile() {
718
+ writeSceneLog(this.constructor.name, "Trying to complete profile", __privateGet$3(this, _profileInProgress));
719
+ if (this.queryController.runningQueriesCount() === 0 && __privateGet$3(this, _profileInProgress)) {
720
+ writeSceneLog(this.constructor.name, "All queries completed, stopping profile");
721
+ this.recordProfileTail(performance.now(), __privateGet$3(this, _profileStartTs));
722
+ }
723
+ }
724
+ isTailRecording() {
725
+ return Boolean(__privateGet$3(this, _trailAnimationFrameId));
726
+ }
727
+ cancelTailRecording() {
728
+ if (__privateGet$3(this, _trailAnimationFrameId)) {
729
+ cancelAnimationFrame(__privateGet$3(this, _trailAnimationFrameId));
730
+ __privateSet$3(this, _trailAnimationFrameId, null);
731
+ writeSceneLog(this.constructor.name, "Cancelled recording frames, new profile started");
732
+ }
733
+ }
734
+ addCrumb(crumb) {
735
+ if (__privateGet$3(this, _profileInProgress)) {
736
+ __privateGet$3(this, _profileInProgress).crumbs.push(crumb);
737
+ }
738
+ }
739
+ }
740
+ _profileInProgress = new WeakMap();
741
+ _profileStartTs = new WeakMap();
742
+ _trailAnimationFrameId = new WeakMap();
743
+ _recordedTrailingSpans = new WeakMap();
744
+ function processRecordedSpans(spans) {
745
+ for (let i = spans.length - 1; i >= 0; i--) {
746
+ if (spans[i] > SPAN_THRESHOLD) {
747
+ return spans.slice(0, i + 1);
748
+ }
749
+ }
750
+ return [spans[0]];
751
+ }
752
+ function captureNetwork(startTs, endTs) {
753
+ const entries = performance.getEntriesByType("resource");
754
+ performance.clearResourceTimings();
755
+ const networkEntries = entries.filter((entry) => entry.startTime >= startTs && entry.startTime <= endTs);
756
+ for (const entry of networkEntries) {
757
+ performance.measure("Network entry " + entry.name, {
758
+ start: entry.startTime,
759
+ end: entry.responseEnd
760
+ });
761
+ }
762
+ return calculateNetworkTime(networkEntries);
763
+ }
764
+ function calculateNetworkTime(requests) {
765
+ if (requests.length === 0) {
766
+ return 0;
767
+ }
768
+ requests.sort((a, b) => a.startTime - b.startTime);
769
+ let totalNetworkTime = 0;
770
+ let currentStart = requests[0].startTime;
771
+ let currentEnd = requests[0].responseEnd;
772
+ for (let i = 1; i < requests.length; i++) {
773
+ if (requests[i].startTime <= currentEnd) {
774
+ currentEnd = Math.max(currentEnd, requests[i].responseEnd);
775
+ } else {
776
+ totalNetworkTime += currentEnd - currentStart;
777
+ currentStart = requests[i].startTime;
778
+ currentEnd = requests[i].responseEnd;
779
+ }
780
+ }
781
+ totalNetworkTime += currentEnd - currentStart;
782
+ return totalNetworkTime;
783
+ }
784
+
785
+ var __defProp$K = Object.defineProperty;
786
+ var __defProps$t = Object.defineProperties;
787
+ var __getOwnPropDescs$t = Object.getOwnPropertyDescriptors;
788
+ var __getOwnPropSymbols$K = Object.getOwnPropertySymbols;
789
+ var __hasOwnProp$K = Object.prototype.hasOwnProperty;
790
+ var __propIsEnum$K = Object.prototype.propertyIsEnumerable;
791
+ var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
792
+ var __spreadValues$K = (a, b) => {
793
+ for (var prop in b || (b = {}))
794
+ if (__hasOwnProp$K.call(b, prop))
795
+ __defNormalProp$K(a, prop, b[prop]);
796
+ if (__getOwnPropSymbols$K)
797
+ for (var prop of __getOwnPropSymbols$K(b)) {
798
+ if (__propIsEnum$K.call(b, prop))
799
+ __defNormalProp$K(a, prop, b[prop]);
800
+ }
801
+ return a;
802
+ };
803
+ var __spreadProps$t = (a, b) => __defProps$t(a, __getOwnPropDescs$t(b));
804
+ var __accessCheck$2 = (obj, member, msg) => {
805
+ if (!member.has(obj))
806
+ throw TypeError("Cannot " + msg);
807
+ };
808
+ var __privateGet$2 = (obj, member, getter) => {
809
+ __accessCheck$2(obj, member, "read from private field");
810
+ return getter ? getter.call(obj) : member.get(obj);
811
+ };
812
+ var __privateAdd$2 = (obj, member, value) => {
813
+ if (member.has(obj))
814
+ throw TypeError("Cannot add the same private member more than once");
815
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
816
+ };
817
+ var __privateSet$2 = (obj, member, value, setter) => {
818
+ __accessCheck$2(obj, member, "write to private field");
819
+ setter ? setter.call(obj, value) : member.set(obj, value);
820
+ return value;
821
+ };
822
+ var _running, _tryCompleteProfileFrameId;
823
+ function isQueryController(s) {
824
+ return "isQueryController" in s;
825
+ }
826
+ class SceneQueryController extends SceneObjectBase {
827
+ constructor(state = {}) {
828
+ super(__spreadProps$t(__spreadValues$K({}, state), { isRunning: false }));
829
+ this.isQueryController = true;
830
+ this.profiler = new SceneRenderProfiler(this);
831
+ __privateAdd$2(this, _running, /* @__PURE__ */ new Set());
832
+ __privateAdd$2(this, _tryCompleteProfileFrameId, null);
833
+ this.runningQueriesCount = () => {
834
+ return __privateGet$2(this, _running).size;
835
+ };
836
+ this.addActivationHandler(() => {
837
+ return () => __privateGet$2(this, _running).clear();
838
+ });
839
+ }
840
+ startProfile(source) {
841
+ if (!this.state.enableProfiling) {
842
+ return;
843
+ }
844
+ this.profiler.startProfile(source.constructor.name);
845
+ }
846
+ queryStarted(entry) {
847
+ __privateGet$2(this, _running).add(entry);
848
+ this.changeRunningQueryCount(1, entry);
849
+ if (!this.state.isRunning) {
850
+ this.setState({ isRunning: true });
851
+ }
852
+ }
853
+ queryCompleted(entry) {
854
+ if (!__privateGet$2(this, _running).has(entry)) {
855
+ return;
856
+ }
857
+ __privateGet$2(this, _running).delete(entry);
858
+ this.changeRunningQueryCount(-1);
859
+ if (__privateGet$2(this, _running).size === 0) {
860
+ this.setState({ isRunning: false });
861
+ }
862
+ }
863
+ changeRunningQueryCount(dir, entry) {
864
+ var _a;
865
+ window.__grafanaRunningQueryCount = ((_a = window.__grafanaRunningQueryCount) != null ? _a : 0) + dir;
866
+ if (dir === 1 && this.state.enableProfiling) {
867
+ if (entry) {
868
+ this.profiler.addCrumb(`${entry.origin.constructor.name}/${entry.type}`);
869
+ }
870
+ if (this.profiler.isTailRecording()) {
871
+ writeSceneLog(this.constructor.name, "New query started, cancelling tail recording");
872
+ this.profiler.cancelTailRecording();
873
+ }
874
+ }
875
+ if (this.state.enableProfiling) {
876
+ if (__privateGet$2(this, _tryCompleteProfileFrameId)) {
877
+ cancelAnimationFrame(__privateGet$2(this, _tryCompleteProfileFrameId));
878
+ }
879
+ __privateSet$2(this, _tryCompleteProfileFrameId, requestAnimationFrame(() => {
880
+ this.profiler.tryCompletingProfile();
881
+ }));
882
+ }
883
+ }
884
+ cancelAll() {
885
+ var _a;
886
+ for (const entry of __privateGet$2(this, _running).values()) {
887
+ (_a = entry.cancel) == null ? void 0 : _a.call(entry);
888
+ }
889
+ }
890
+ }
891
+ _running = new WeakMap();
892
+ _tryCompleteProfileFrameId = new WeakMap();
893
+
894
+ function getQueryController(sceneObject) {
895
+ let parent = sceneObject;
896
+ while (parent) {
897
+ if (parent.state.$behaviors) {
898
+ for (const behavior of parent.state.$behaviors) {
899
+ if (isQueryController(behavior)) {
900
+ return behavior;
901
+ }
902
+ }
903
+ }
904
+ parent = parent.parent;
905
+ }
906
+ return void 0;
907
+ }
908
+
610
909
  var __defProp$J = Object.defineProperty;
611
910
  var __getOwnPropSymbols$J = Object.getOwnPropertySymbols;
612
911
  var __hasOwnProp$J = Object.prototype.hasOwnProperty;
@@ -772,6 +1071,8 @@ class SceneTimeRange extends SceneObjectBase {
772
1071
  this.state.UNSAFE_nowDelay
773
1072
  );
774
1073
  if (update.from !== this.state.from || update.to !== this.state.to) {
1074
+ const queryController = getQueryController(this);
1075
+ queryController == null ? void 0 : queryController.startProfile(this);
775
1076
  this._urlSync.performBrowserHistoryAction(() => {
776
1077
  this.setState(update);
777
1078
  });
@@ -1823,70 +2124,56 @@ function isDataLayer(obj) {
1823
2124
  return "isDataLayer" in obj;
1824
2125
  }
1825
2126
 
1826
- var __accessCheck$2 = (obj, member, msg) => {
1827
- if (!member.has(obj))
1828
- throw TypeError("Cannot " + msg);
1829
- };
1830
- var __privateGet$2 = (obj, member, getter) => {
1831
- __accessCheck$2(obj, member, "read from private field");
1832
- return getter ? getter.call(obj) : member.get(obj);
1833
- };
1834
- var __privateAdd$2 = (obj, member, value) => {
1835
- if (member.has(obj))
1836
- throw TypeError("Cannot add the same private member more than once");
1837
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1838
- };
1839
- var _running;
1840
- function isQueryController(s) {
1841
- return "isQueryController" in s;
1842
- }
1843
- class SceneQueryController extends SceneObjectBase {
1844
- constructor() {
1845
- super({ isRunning: false });
1846
- this.isQueryController = true;
1847
- __privateAdd$2(this, _running, /* @__PURE__ */ new Set());
1848
- this.addActivationHandler(() => {
1849
- return () => __privateGet$2(this, _running).clear();
1850
- });
1851
- }
1852
- queryStarted(entry) {
1853
- __privateGet$2(this, _running).add(entry);
1854
- this.changeRunningQueryCount(1);
1855
- if (!this.state.isRunning) {
1856
- this.setState({ isRunning: true });
1857
- }
1858
- }
1859
- queryCompleted(entry) {
1860
- if (!__privateGet$2(this, _running).has(entry)) {
1861
- return;
1862
- }
1863
- __privateGet$2(this, _running).delete(entry);
1864
- this.changeRunningQueryCount(-1);
1865
- if (__privateGet$2(this, _running).size === 0) {
1866
- this.setState({ isRunning: false });
1867
- }
1868
- }
1869
- changeRunningQueryCount(dir) {
1870
- var _a;
1871
- window.__grafanaRunningQueryCount = ((_a = window.__grafanaRunningQueryCount) != null ? _a : 0) + dir;
1872
- }
1873
- cancelAll() {
1874
- var _a;
1875
- for (const entry of __privateGet$2(this, _running).values()) {
1876
- (_a = entry.cancel) == null ? void 0 : _a.call(entry);
2127
+ function registerQueryWithController(entry) {
2128
+ return (queryStream) => {
2129
+ const queryControler = sceneGraph.getQueryController(entry.origin);
2130
+ if (!queryControler) {
2131
+ return queryStream;
1877
2132
  }
1878
- }
2133
+ return new rxjs.Observable((observer) => {
2134
+ if (!entry.cancel) {
2135
+ entry.cancel = () => observer.complete();
2136
+ }
2137
+ queryControler.queryStarted(entry);
2138
+ let markedAsCompleted = false;
2139
+ const sub = queryStream.subscribe({
2140
+ next: (v) => {
2141
+ if (!markedAsCompleted && v.state !== schema.LoadingState.Loading) {
2142
+ markedAsCompleted = true;
2143
+ queryControler.queryCompleted(entry);
2144
+ }
2145
+ observer.next(v);
2146
+ },
2147
+ error: (e) => observer.error(e),
2148
+ complete: () => {
2149
+ observer.complete();
2150
+ }
2151
+ });
2152
+ return () => {
2153
+ sub.unsubscribe();
2154
+ if (!markedAsCompleted) {
2155
+ queryControler.queryCompleted(entry);
2156
+ }
2157
+ };
2158
+ });
2159
+ };
1879
2160
  }
1880
- _running = new WeakMap();
1881
-
1882
- function writeSceneLog(logger, message, ...rest) {
1883
- let loggingEnabled = false;
1884
- if (typeof window !== "undefined") {
1885
- loggingEnabled = localStorage.getItem("grafana.debug.scenes") === "true";
1886
- }
1887
- if (loggingEnabled) {
1888
- console.log(`${logger}: `, message, ...rest);
1889
- }
2161
+ function wrapPromiseInStateObservable(promise) {
2162
+ console.log("wrapPromiseInStateObservable", promise);
2163
+ return new rxjs.Observable((observer) => {
2164
+ observer.next({ state: schema.LoadingState.Loading });
2165
+ const promiseObservable = rxjs.from(promise);
2166
+ promiseObservable.pipe(
2167
+ rxjs.map(() => ({ state: schema.LoadingState.Done })),
2168
+ rxjs.catchError(() => {
2169
+ observer.next({ state: schema.LoadingState.Error });
2170
+ return [];
2171
+ })
2172
+ ).subscribe({
2173
+ next: (result) => observer.next(result),
2174
+ complete: () => observer.complete()
2175
+ });
2176
+ });
1890
2177
  }
1891
2178
 
1892
2179
  async function getDataSource(datasource, scopedVars) {
@@ -1899,7 +2186,21 @@ async function getDataSource(datasource, scopedVars) {
1899
2186
  if (datasource && datasource.query) {
1900
2187
  return datasource;
1901
2188
  }
1902
- return await runtime.getDataSourceSrv().get(datasource, scopedVars);
2189
+ const dsPromise = runtime.getDataSourceSrv().get(datasource, scopedVars);
2190
+ if (scopedVars.__sceneObject && scopedVars.__sceneObject.value.valueOf()) {
2191
+ const queryControler = sceneGraph.getQueryController(scopedVars.__sceneObject.value.valueOf());
2192
+ if (queryControler && queryControler.state.enableProfiling) {
2193
+ wrapPromiseInStateObservable(dsPromise).pipe(
2194
+ registerQueryWithController({
2195
+ type: "plugin",
2196
+ origin: scopedVars.__sceneObject.value.valueOf()
2197
+ })
2198
+ ).subscribe(() => {
2199
+ });
2200
+ }
2201
+ }
2202
+ const result = await dsPromise;
2203
+ return result;
1903
2204
  }
1904
2205
 
1905
2206
  class VariableValueRecorder {
@@ -2147,41 +2448,6 @@ function findActiveAdHocFilterVariableByUid(dsUid) {
2147
2448
  return void 0;
2148
2449
  }
2149
2450
 
2150
- function registerQueryWithController(entry) {
2151
- return (queryStream) => {
2152
- const queryControler = sceneGraph.getQueryController(entry.origin);
2153
- if (!queryControler) {
2154
- return queryStream;
2155
- }
2156
- return new rxjs.Observable((observer) => {
2157
- if (!entry.cancel) {
2158
- entry.cancel = () => observer.complete();
2159
- }
2160
- queryControler.queryStarted(entry);
2161
- let markedAsCompleted = false;
2162
- const sub = queryStream.subscribe({
2163
- next: (v) => {
2164
- if (!markedAsCompleted && v.state !== schema.LoadingState.Loading) {
2165
- markedAsCompleted = true;
2166
- queryControler.queryCompleted(entry);
2167
- }
2168
- observer.next(v);
2169
- },
2170
- error: (e) => observer.error(e),
2171
- complete: () => {
2172
- observer.complete();
2173
- }
2174
- });
2175
- return () => {
2176
- sub.unsubscribe();
2177
- if (!markedAsCompleted) {
2178
- queryControler.queryCompleted(entry);
2179
- }
2180
- };
2181
- });
2182
- };
2183
- }
2184
-
2185
2451
  const allActiveGroupByVariables = /* @__PURE__ */ new Set();
2186
2452
  function findActiveGroupByVariablesByUid(dsUid) {
2187
2453
  var _a;
@@ -2571,6 +2837,7 @@ function VariableValueSelect({ model }) {
2571
2837
  const [inputValue, setInputValue] = React.useState("");
2572
2838
  const [hasCustomValue, setHasCustomValue] = React.useState(false);
2573
2839
  const selectValue = toSelectableValue$2(value, String(text));
2840
+ const queryController = sceneGraph.getQueryController(model);
2574
2841
  const optionSearcher = React.useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);
2575
2842
  const onInputChange = (value2, { action }) => {
2576
2843
  if (action === "input-change") {
@@ -2610,6 +2877,7 @@ function VariableValueSelect({ model }) {
2610
2877
  "data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${value}`),
2611
2878
  onChange: (newValue) => {
2612
2879
  model.changeValueTo(newValue.value, newValue.label);
2880
+ queryController == null ? void 0 : queryController.startProfile(model);
2613
2881
  if (hasCustomValue !== newValue.__isNew__) {
2614
2882
  setHasCustomValue(newValue.__isNew__);
2615
2883
  }
@@ -2621,6 +2889,7 @@ function VariableValueSelectMulti({ model }) {
2621
2889
  const arrayValue = React.useMemo(() => lodash.isArray(value) ? value : [value], [value]);
2622
2890
  const [uncommittedValue, setUncommittedValue] = React.useState(arrayValue);
2623
2891
  const [inputValue, setInputValue] = React.useState("");
2892
+ const queryController = sceneGraph.getQueryController(model);
2624
2893
  const optionSearcher = React.useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);
2625
2894
  React.useEffect(() => {
2626
2895
  setUncommittedValue(arrayValue);
@@ -2666,6 +2935,7 @@ function VariableValueSelectMulti({ model }) {
2666
2935
  onInputChange,
2667
2936
  onBlur: () => {
2668
2937
  model.changeValueTo(uncommittedValue);
2938
+ queryController == null ? void 0 : queryController.startProfile(model);
2669
2939
  },
2670
2940
  filterOption: filterNoOp$2,
2671
2941
  "data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${uncommittedValue}`),
@@ -3273,10 +3543,12 @@ function AdHocFilterRenderer({ filter, model }) {
3273
3543
  const [isOperatorOpen, setIsOperatorOpen] = React.useState(false);
3274
3544
  const [valueInputValue, setValueInputValue] = React.useState("");
3275
3545
  const [valueHasCustomValue, setValueHasCustomValue] = React.useState(false);
3276
- const [uncommittedValue, setUncommittedValue] = React.useState(filter.values ? filter.values.map((value, index) => {
3277
- var _a2;
3278
- return keyLabelToOption(value, (_a2 = filter.valueLabels) == null ? void 0 : _a2[index]);
3279
- }) : []);
3546
+ const [uncommittedValue, setUncommittedValue] = React.useState(
3547
+ filter.values ? filter.values.map((value, index) => {
3548
+ var _a2;
3549
+ return keyLabelToOption(value, (_a2 = filter.valueLabels) == null ? void 0 : _a2[index]);
3550
+ }) : []
3551
+ );
3280
3552
  const isMultiValue = isMultiValueOperator(filter.operator);
3281
3553
  const keyValue = keyLabelToOption(filter.key, filter.keyLabel);
3282
3554
  const valueValue = keyLabelToOption(filter.value, (_a = filter.valueLabels) == null ? void 0 : _a[0]);
@@ -3299,10 +3571,12 @@ function AdHocFilterRenderer({ filter, model }) {
3299
3571
  setUncommittedValue([]);
3300
3572
  } else if (!isMultiValueOperator(existingOperator) && isMultiValueOperator(newOperator) && filter.value) {
3301
3573
  update.values = [filter.value];
3302
- setUncommittedValue([{
3303
- value: filter.value,
3304
- label: (_b2 = (_a2 = filter.valueLabels) == null ? void 0 : _a2[0]) != null ? _b2 : filter.value
3305
- }]);
3574
+ setUncommittedValue([
3575
+ {
3576
+ value: filter.value,
3577
+ label: (_b2 = (_a2 = filter.valueLabels) == null ? void 0 : _a2[0]) != null ? _b2 : filter.value
3578
+ }
3579
+ ]);
3306
3580
  }
3307
3581
  model._updateFilter(filter, update);
3308
3582
  };
@@ -3581,10 +3855,7 @@ function deserializeUrlToFilters(value) {
3581
3855
  }
3582
3856
  function toArray(filter) {
3583
3857
  var _a;
3584
- const result = [
3585
- toUrlCommaDelimitedString(filter.key, filter.keyLabel),
3586
- filter.operator
3587
- ];
3858
+ const result = [toUrlCommaDelimitedString(filter.key, filter.keyLabel), filter.operator];
3588
3859
  if (isMultiValueOperator(filter.operator)) {
3589
3860
  filter.values.forEach((value, index) => {
3590
3861
  var _a2;
@@ -4731,19 +5002,21 @@ var __spreadValues$y = (a, b) => {
4731
5002
  };
4732
5003
  const OPERATORS = [
4733
5004
  {
4734
- value: "="
5005
+ value: "=",
5006
+ description: "Equals"
4735
5007
  },
4736
5008
  {
4737
- value: "!="
5009
+ value: "!=",
5010
+ description: "Not equal"
4738
5011
  },
4739
5012
  {
4740
5013
  value: "=|",
4741
- description: "Is one of. Use to filter on multiple values.",
5014
+ description: "One of. Use to filter on multiple values.",
4742
5015
  isMulti: true
4743
5016
  },
4744
5017
  {
4745
5018
  value: "!=|",
4746
- description: "Is not one of. Use to exclude multiple values.",
5019
+ description: "Not one of. Use to exclude multiple values.",
4747
5020
  isMulti: true
4748
5021
  },
4749
5022
  {
@@ -4755,10 +5028,12 @@ const OPERATORS = [
4755
5028
  description: "Does not match regex"
4756
5029
  },
4757
5030
  {
4758
- value: "<"
5031
+ value: "<",
5032
+ description: "Less than"
4759
5033
  },
4760
5034
  {
4761
- value: ">"
5035
+ value: ">",
5036
+ description: "Greater than"
4762
5037
  }
4763
5038
  ];
4764
5039
  class AdHocFiltersVariable extends SceneObjectBase {
@@ -4948,7 +5223,7 @@ function isFilterComplete(filter) {
4948
5223
  function isMultiValueOperator(operatorValue) {
4949
5224
  const operator = OPERATORS.find((o) => o.value === operatorValue);
4950
5225
  if (!operator) {
4951
- throw new Error("Unknown operator");
5226
+ return false;
4952
5227
  }
4953
5228
  return Boolean(operator.isMulti);
4954
5229
  }
@@ -5059,9 +5334,7 @@ class SceneQueryRunner extends SceneObjectBase {
5059
5334
  })
5060
5335
  );
5061
5336
  }
5062
- this.subscribeToTimeRangeChanges(
5063
- timeRange
5064
- );
5337
+ this.subscribeToTimeRangeChanges(timeRange);
5065
5338
  if (this.shouldRunQueriesOnActivate()) {
5066
5339
  this.runQueries();
5067
5340
  }
@@ -6313,30 +6586,6 @@ function findDescendents(scene, descendentType) {
6313
6586
  const targetScenes = findAllObjects(scene, isDescendentType);
6314
6587
  return targetScenes.filter(isDescendentType);
6315
6588
  }
6316
- function getQueryController(sceneObject) {
6317
- let parent = sceneObject;
6318
- while (parent) {
6319
- if (parent.state.$behaviors) {
6320
- for (const behavior of parent.state.$behaviors) {
6321
- if (isQueryController(behavior)) {
6322
- return behavior;
6323
- }
6324
- }
6325
- }
6326
- parent = parent.parent;
6327
- }
6328
- return void 0;
6329
- }
6330
- function getUrlSyncManager(sceneObject) {
6331
- let parent = sceneObject;
6332
- while (parent) {
6333
- if ("urlSyncManager" in parent.state) {
6334
- return parent.state.urlSyncManager;
6335
- }
6336
- parent = parent.parent;
6337
- }
6338
- return void 0;
6339
- }
6340
6589
 
6341
6590
  const sceneGraph = {
6342
6591
  getVariables,
@@ -6352,9 +6601,8 @@ const sceneGraph = {
6352
6601
  findObject,
6353
6602
  findAllObjects,
6354
6603
  getAncestor,
6355
- findDescendents,
6356
6604
  getQueryController,
6357
- getUrlSyncManager
6605
+ findDescendents
6358
6606
  };
6359
6607
 
6360
6608
  class UniqueUrlKeyMapper {
@@ -7218,7 +7466,13 @@ class VizPanel extends SceneObjectBase {
7218
7466
  } else {
7219
7467
  const { importPanelPlugin } = runtime.getPluginImportUtils();
7220
7468
  try {
7221
- const result = await importPanelPlugin(pluginId);
7469
+ const panelPromise = importPanelPlugin(pluginId);
7470
+ const queryControler = sceneGraph.getQueryController(this);
7471
+ if (queryControler && queryControler.state.enableProfiling) {
7472
+ wrapPromiseInStateObservable(panelPromise).pipe(registerQueryWithController({ type: "plugin", origin: this })).subscribe(() => {
7473
+ });
7474
+ }
7475
+ const result = await panelPromise;
7222
7476
  this._pluginLoaded(result, overwriteOptions, overwriteFieldConfig, isAfterPluginChange);
7223
7477
  } catch (err) {
7224
7478
  this._pluginLoaded(getPanelPluginNotFound(pluginId));
@@ -7287,11 +7541,7 @@ class VizPanel extends SceneObjectBase {
7287
7541
  }
7288
7542
  async changePluginType(pluginId, newOptions, newFieldConfig) {
7289
7543
  var _a, _b;
7290
- const {
7291
- options: prevOptions,
7292
- fieldConfig: prevFieldConfig,
7293
- pluginId: prevPluginId
7294
- } = this.state;
7544
+ const { options: prevOptions, fieldConfig: prevFieldConfig, pluginId: prevPluginId } = this.state;
7295
7545
  this._dataWithFieldConfig = void 0;
7296
7546
  await this._loadPlugin(pluginId, newOptions != null ? newOptions : {}, newFieldConfig, true);
7297
7547
  const panel = {
@@ -10673,6 +10923,7 @@ class SceneRefreshPicker extends SceneObjectBase {
10673
10923
  this._autoRefreshBlocked = false;
10674
10924
  this.onRefresh = () => {
10675
10925
  const queryController = sceneGraph.getQueryController(this);
10926
+ queryController == null ? void 0 : queryController.startProfile(this);
10676
10927
  if (queryController == null ? void 0 : queryController.state.isRunning) {
10677
10928
  queryController.cancelAll();
10678
10929
  return;
@@ -10801,7 +11052,9 @@ function SceneRefreshPickerRenderer({ model }) {
10801
11052
  tooltip,
10802
11053
  width,
10803
11054
  text,
10804
- onRefresh: model.onRefresh,
11055
+ onRefresh: () => {
11056
+ model.onRefresh();
11057
+ },
10805
11058
  primary,
10806
11059
  onIntervalChanged: model.onIntervalChanged,
10807
11060
  isLoading: isRunning,