@grafana/scenes 6.33.0--canary.1232.17398095824.0 → 6.33.1--canary.1235.17401388269.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/behaviors/LongFrameDetector.js +185 -0
- package/dist/esm/behaviors/LongFrameDetector.js.map +1 -0
- package/dist/esm/behaviors/SceneRenderProfiler.js +103 -20
- package/dist/esm/behaviors/SceneRenderProfiler.js.map +1 -1
- package/dist/esm/querying/SceneQueryRunner.js +41 -14
- package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
- package/dist/esm/querying/layers/annotations/AnnotationsDataLayer.js +1 -12
- package/dist/esm/querying/layers/annotations/AnnotationsDataLayer.js.map +1 -1
- package/dist/esm/querying/layers/annotations/standardAnnotationQuery.js +1 -3
- package/dist/esm/querying/layers/annotations/standardAnnotationQuery.js.map +1 -1
- package/dist/esm/utils/writeSceneLog.js +10 -1
- package/dist/esm/utils/writeSceneLog.js.map +1 -1
- package/dist/esm/variables/adhoc/patchGetAdhocFilters.js +2 -2
- package/dist/esm/variables/adhoc/patchGetAdhocFilters.js.map +1 -1
- package/dist/index.d.ts +36 -3
- package/dist/index.js +399 -167
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/esm/variables/DrilldownDependenciesManager.js +0 -60
- package/dist/esm/variables/DrilldownDependenciesManager.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -137,21 +137,21 @@ class UserActionEvent extends data.BusEventWithPayload {
|
|
|
137
137
|
}
|
|
138
138
|
UserActionEvent.type = "scene-object-user-action";
|
|
139
139
|
|
|
140
|
-
var __typeError$
|
|
140
|
+
var __typeError$5 = (msg) => {
|
|
141
141
|
throw TypeError(msg);
|
|
142
142
|
};
|
|
143
|
-
var __accessCheck$
|
|
144
|
-
var __privateGet$
|
|
145
|
-
var __privateAdd$
|
|
146
|
-
var __privateSet$
|
|
143
|
+
var __accessCheck$5 = (obj, member, msg) => member.has(obj) || __typeError$5("Cannot " + msg);
|
|
144
|
+
var __privateGet$5 = (obj, member, getter) => (__accessCheck$5(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
145
|
+
var __privateAdd$5 = (obj, member, value) => member.has(obj) ? __typeError$5("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
146
|
+
var __privateSet$5 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value);
|
|
147
147
|
var _ref;
|
|
148
148
|
class SceneObjectRef {
|
|
149
149
|
constructor(ref) {
|
|
150
|
-
__privateAdd$
|
|
151
|
-
__privateSet$
|
|
150
|
+
__privateAdd$5(this, _ref);
|
|
151
|
+
__privateSet$5(this, _ref, ref);
|
|
152
152
|
}
|
|
153
153
|
resolve() {
|
|
154
|
-
return __privateGet$
|
|
154
|
+
return __privateGet$5(this, _ref);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
_ref = new WeakMap();
|
|
@@ -599,14 +599,23 @@ function writeSceneLog(logger, message, ...rest) {
|
|
|
599
599
|
console.log(`${logger}: `, message, ...rest);
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
|
+
function writeSceneLogStyled(logger, message, style, ...rest) {
|
|
603
|
+
let loggingEnabled = false;
|
|
604
|
+
if (typeof window !== "undefined") {
|
|
605
|
+
loggingEnabled = localStorage.getItem("grafana.debug.scenes") === "true";
|
|
606
|
+
}
|
|
607
|
+
if (loggingEnabled) {
|
|
608
|
+
console.log(`%c${logger}: ${message}`, style, ...rest);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
602
611
|
|
|
603
|
-
var __typeError$
|
|
612
|
+
var __typeError$4 = (msg) => {
|
|
604
613
|
throw TypeError(msg);
|
|
605
614
|
};
|
|
606
|
-
var __accessCheck$
|
|
607
|
-
var __privateGet$
|
|
608
|
-
var __privateAdd$
|
|
609
|
-
var __privateSet$
|
|
615
|
+
var __accessCheck$4 = (obj, member, msg) => member.has(obj) || __typeError$4("Cannot " + msg);
|
|
616
|
+
var __privateGet$4 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
617
|
+
var __privateAdd$4 = (obj, member, value) => member.has(obj) ? __typeError$4("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
618
|
+
var __privateSet$4 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
|
|
610
619
|
var _running, _tryCompleteProfileFrameId;
|
|
611
620
|
function isQueryController(s) {
|
|
612
621
|
return "isQueryController" in s;
|
|
@@ -616,10 +625,10 @@ class SceneQueryController extends SceneObjectBase {
|
|
|
616
625
|
super({ ...state, isRunning: false });
|
|
617
626
|
this.profiler = profiler;
|
|
618
627
|
this.isQueryController = true;
|
|
619
|
-
__privateAdd$
|
|
620
|
-
__privateAdd$
|
|
628
|
+
__privateAdd$4(this, _running, /* @__PURE__ */ new Set());
|
|
629
|
+
__privateAdd$4(this, _tryCompleteProfileFrameId, null);
|
|
621
630
|
this.runningQueriesCount = () => {
|
|
622
|
-
return __privateGet$
|
|
631
|
+
return __privateGet$4(this, _running).size;
|
|
623
632
|
};
|
|
624
633
|
if (profiler) {
|
|
625
634
|
this.profiler = profiler;
|
|
@@ -628,7 +637,7 @@ class SceneQueryController extends SceneObjectBase {
|
|
|
628
637
|
this.addActivationHandler(() => {
|
|
629
638
|
var _a;
|
|
630
639
|
(_a = this.profiler) == null ? void 0 : _a.setQueryController(this);
|
|
631
|
-
return () => __privateGet$
|
|
640
|
+
return () => __privateGet$4(this, _running).clear();
|
|
632
641
|
});
|
|
633
642
|
}
|
|
634
643
|
startProfile(name) {
|
|
@@ -643,19 +652,19 @@ class SceneQueryController extends SceneObjectBase {
|
|
|
643
652
|
(_a = this.profiler) == null ? void 0 : _a.cancelProfile();
|
|
644
653
|
}
|
|
645
654
|
queryStarted(entry) {
|
|
646
|
-
__privateGet$
|
|
655
|
+
__privateGet$4(this, _running).add(entry);
|
|
647
656
|
this.changeRunningQueryCount(1, entry);
|
|
648
657
|
if (!this.state.isRunning) {
|
|
649
658
|
this.setState({ isRunning: true });
|
|
650
659
|
}
|
|
651
660
|
}
|
|
652
661
|
queryCompleted(entry) {
|
|
653
|
-
if (!__privateGet$
|
|
662
|
+
if (!__privateGet$4(this, _running).has(entry)) {
|
|
654
663
|
return;
|
|
655
664
|
}
|
|
656
|
-
__privateGet$
|
|
665
|
+
__privateGet$4(this, _running).delete(entry);
|
|
657
666
|
this.changeRunningQueryCount(-1);
|
|
658
|
-
if (__privateGet$
|
|
667
|
+
if (__privateGet$4(this, _running).size === 0) {
|
|
659
668
|
this.setState({ isRunning: false });
|
|
660
669
|
}
|
|
661
670
|
}
|
|
@@ -672,10 +681,10 @@ class SceneQueryController extends SceneObjectBase {
|
|
|
672
681
|
}
|
|
673
682
|
}
|
|
674
683
|
if (this.state.enableProfiling) {
|
|
675
|
-
if (__privateGet$
|
|
676
|
-
cancelAnimationFrame(__privateGet$
|
|
684
|
+
if (__privateGet$4(this, _tryCompleteProfileFrameId)) {
|
|
685
|
+
cancelAnimationFrame(__privateGet$4(this, _tryCompleteProfileFrameId));
|
|
677
686
|
}
|
|
678
|
-
__privateSet$
|
|
687
|
+
__privateSet$4(this, _tryCompleteProfileFrameId, requestAnimationFrame(() => {
|
|
679
688
|
var _a2;
|
|
680
689
|
(_a2 = this.profiler) == null ? void 0 : _a2.tryCompletingProfile();
|
|
681
690
|
}));
|
|
@@ -683,7 +692,7 @@ class SceneQueryController extends SceneObjectBase {
|
|
|
683
692
|
}
|
|
684
693
|
cancelAll() {
|
|
685
694
|
var _a;
|
|
686
|
-
for (const entry of __privateGet$
|
|
695
|
+
for (const entry of __privateGet$4(this, _running).values()) {
|
|
687
696
|
(_a = entry.cancel) == null ? void 0 : _a.call(entry);
|
|
688
697
|
}
|
|
689
698
|
}
|
|
@@ -853,6 +862,187 @@ function isValid$1(value, roundUp, timeZone) {
|
|
|
853
862
|
return parsed.isValid();
|
|
854
863
|
}
|
|
855
864
|
|
|
865
|
+
var __typeError$3 = (msg) => {
|
|
866
|
+
throw TypeError(msg);
|
|
867
|
+
};
|
|
868
|
+
var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Cannot " + msg);
|
|
869
|
+
var __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
870
|
+
var __privateAdd$3 = (obj, member, value) => member.has(obj) ? __typeError$3("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
871
|
+
var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
|
|
872
|
+
var _isTracking, _callback, _frameTrackingId, _lastFrameTime, _loafObserver;
|
|
873
|
+
const LONG_FRAME_THRESHOLD = 50;
|
|
874
|
+
class LongFrameDetector {
|
|
875
|
+
constructor() {
|
|
876
|
+
__privateAdd$3(this, _isTracking, false);
|
|
877
|
+
__privateAdd$3(this, _callback, null);
|
|
878
|
+
// Manual tracking state
|
|
879
|
+
__privateAdd$3(this, _frameTrackingId, null);
|
|
880
|
+
__privateAdd$3(this, _lastFrameTime, 0);
|
|
881
|
+
// LoAF tracking state
|
|
882
|
+
__privateAdd$3(this, _loafObserver, null);
|
|
883
|
+
/**
|
|
884
|
+
* Measure frame durations using requestAnimationFrame
|
|
885
|
+
*/
|
|
886
|
+
this.measureFrames = () => {
|
|
887
|
+
if (!__privateGet$3(this, _isTracking)) {
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
const currentFrameTime = performance.now();
|
|
891
|
+
const frameLength = currentFrameTime - __privateGet$3(this, _lastFrameTime);
|
|
892
|
+
if (frameLength > LONG_FRAME_THRESHOLD) {
|
|
893
|
+
const event = {
|
|
894
|
+
duration: frameLength,
|
|
895
|
+
timestamp: currentFrameTime,
|
|
896
|
+
method: "manual"
|
|
897
|
+
};
|
|
898
|
+
if (__privateGet$3(this, _callback)) {
|
|
899
|
+
__privateGet$3(this, _callback).call(this, event);
|
|
900
|
+
}
|
|
901
|
+
if (typeof performance !== "undefined" && performance.mark && performance.measure) {
|
|
902
|
+
const frameId = `long-frame-manual-${currentFrameTime.toFixed(0)}`;
|
|
903
|
+
const startMarkName = `${frameId}-start`;
|
|
904
|
+
const endMarkName = `${frameId}-end`;
|
|
905
|
+
const measureName = `Long Frame (Manual): ${frameLength.toFixed(1)}ms`;
|
|
906
|
+
try {
|
|
907
|
+
performance.mark(startMarkName, { startTime: currentFrameTime - frameLength });
|
|
908
|
+
performance.mark(endMarkName, { startTime: currentFrameTime });
|
|
909
|
+
performance.measure(measureName, startMarkName, endMarkName);
|
|
910
|
+
} catch (e) {
|
|
911
|
+
performance.mark(measureName);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
writeSceneLog(
|
|
915
|
+
"LongFrameDetector",
|
|
916
|
+
`Long frame detected (manual): ${frameLength}ms (threshold: ${LONG_FRAME_THRESHOLD}ms)`
|
|
917
|
+
);
|
|
918
|
+
}
|
|
919
|
+
__privateSet$3(this, _lastFrameTime, currentFrameTime);
|
|
920
|
+
if (__privateGet$3(this, _isTracking)) {
|
|
921
|
+
__privateSet$3(this, _frameTrackingId, requestAnimationFrame(this.measureFrames));
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Check if LoAF API is available in the browser
|
|
927
|
+
*/
|
|
928
|
+
isLoAFAvailable() {
|
|
929
|
+
return typeof PerformanceObserver !== "undefined" && PerformanceObserver.supportedEntryTypes && PerformanceObserver.supportedEntryTypes.includes("long-animation-frame");
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Start detecting long frames and call the provided callback when they occur
|
|
933
|
+
*/
|
|
934
|
+
start(callback) {
|
|
935
|
+
if (__privateGet$3(this, _isTracking)) {
|
|
936
|
+
writeSceneLog("LongFrameDetector", "Already tracking frames, stopping previous session");
|
|
937
|
+
this.stop();
|
|
938
|
+
}
|
|
939
|
+
__privateSet$3(this, _callback, callback);
|
|
940
|
+
__privateSet$3(this, _isTracking, true);
|
|
941
|
+
if (this.isLoAFAvailable()) {
|
|
942
|
+
this.startLoAFTracking();
|
|
943
|
+
} else {
|
|
944
|
+
this.startManualFrameTracking();
|
|
945
|
+
}
|
|
946
|
+
writeSceneLog(
|
|
947
|
+
"LongFrameDetector",
|
|
948
|
+
`Started tracking with ${this.isLoAFAvailable() ? "LoAF API" : "manual"} method, threshold: ${LONG_FRAME_THRESHOLD}ms`
|
|
949
|
+
);
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Stop detecting long frames
|
|
953
|
+
*/
|
|
954
|
+
stop() {
|
|
955
|
+
if (!__privateGet$3(this, _isTracking)) {
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
__privateSet$3(this, _isTracking, false);
|
|
959
|
+
__privateSet$3(this, _callback, null);
|
|
960
|
+
this.stopLoAFTracking();
|
|
961
|
+
this.stopManualFrameTracking();
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Check if currently tracking frames
|
|
965
|
+
*/
|
|
966
|
+
isTracking() {
|
|
967
|
+
return __privateGet$3(this, _isTracking);
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Start tracking using the Long Animation Frame API
|
|
971
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/PerformanceLongAnimationFrameTiming
|
|
972
|
+
*/
|
|
973
|
+
startLoAFTracking() {
|
|
974
|
+
if (!this.isLoAFAvailable()) {
|
|
975
|
+
writeSceneLog("LongFrameDetector", "LoAF API not available, falling back to manual tracking");
|
|
976
|
+
this.startManualFrameTracking();
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
try {
|
|
980
|
+
__privateSet$3(this, _loafObserver, new PerformanceObserver((list) => {
|
|
981
|
+
for (const entry of list.getEntries()) {
|
|
982
|
+
const event = {
|
|
983
|
+
duration: entry.duration,
|
|
984
|
+
timestamp: entry.startTime,
|
|
985
|
+
method: "loaf"
|
|
986
|
+
};
|
|
987
|
+
if (__privateGet$3(this, _callback)) {
|
|
988
|
+
__privateGet$3(this, _callback).call(this, event);
|
|
989
|
+
}
|
|
990
|
+
if (typeof performance !== "undefined" && performance.mark && performance.measure) {
|
|
991
|
+
const frameId = `long-frame-${entry.startTime.toFixed(0)}`;
|
|
992
|
+
const startMarkName = `${frameId}-start`;
|
|
993
|
+
const endMarkName = `${frameId}-end`;
|
|
994
|
+
const measureName = `Long Frame (LoAF): ${entry.duration.toFixed(1)}ms`;
|
|
995
|
+
try {
|
|
996
|
+
performance.mark(startMarkName, { startTime: entry.startTime });
|
|
997
|
+
performance.mark(endMarkName, { startTime: entry.startTime + entry.duration });
|
|
998
|
+
performance.measure(measureName, startMarkName, endMarkName);
|
|
999
|
+
} catch (e) {
|
|
1000
|
+
performance.mark(measureName);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
writeSceneLog("LongFrameDetector", `Long frame detected (LoAF): ${entry.duration}ms at ${entry.startTime}ms`);
|
|
1004
|
+
}
|
|
1005
|
+
}));
|
|
1006
|
+
__privateGet$3(this, _loafObserver).observe({ type: "long-animation-frame", buffered: false });
|
|
1007
|
+
} catch (error) {
|
|
1008
|
+
writeSceneLog("LongFrameDetector", "Failed to start LoAF tracking, falling back to manual:", error);
|
|
1009
|
+
this.startManualFrameTracking();
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Stop LoAF tracking
|
|
1014
|
+
*/
|
|
1015
|
+
stopLoAFTracking() {
|
|
1016
|
+
if (__privateGet$3(this, _loafObserver)) {
|
|
1017
|
+
__privateGet$3(this, _loafObserver).disconnect();
|
|
1018
|
+
__privateSet$3(this, _loafObserver, null);
|
|
1019
|
+
writeSceneLog("LongFrameDetector", "Stopped LoAF tracking");
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Start manual frame tracking using requestAnimationFrame
|
|
1024
|
+
*/
|
|
1025
|
+
startManualFrameTracking() {
|
|
1026
|
+
__privateSet$3(this, _lastFrameTime, performance.now());
|
|
1027
|
+
__privateSet$3(this, _frameTrackingId, requestAnimationFrame(() => this.measureFrames()));
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Stop manual frame tracking
|
|
1031
|
+
*/
|
|
1032
|
+
stopManualFrameTracking() {
|
|
1033
|
+
if (__privateGet$3(this, _frameTrackingId)) {
|
|
1034
|
+
cancelAnimationFrame(__privateGet$3(this, _frameTrackingId));
|
|
1035
|
+
__privateSet$3(this, _frameTrackingId, null);
|
|
1036
|
+
writeSceneLog("LongFrameDetector", "Stopped manual frame tracking");
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
_isTracking = new WeakMap();
|
|
1041
|
+
_callback = new WeakMap();
|
|
1042
|
+
_frameTrackingId = new WeakMap();
|
|
1043
|
+
_lastFrameTime = new WeakMap();
|
|
1044
|
+
_loafObserver = new WeakMap();
|
|
1045
|
+
|
|
856
1046
|
var __typeError$2 = (msg) => {
|
|
857
1047
|
throw TypeError(msg);
|
|
858
1048
|
};
|
|
@@ -860,9 +1050,17 @@ var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Ca
|
|
|
860
1050
|
var __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
861
1051
|
var __privateAdd$2 = (obj, member, value) => member.has(obj) ? __typeError$2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
862
1052
|
var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), member.set(obj, value), value);
|
|
863
|
-
var
|
|
1053
|
+
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
1054
|
+
set _(value) {
|
|
1055
|
+
__privateSet$2(obj, member, value);
|
|
1056
|
+
},
|
|
1057
|
+
get _() {
|
|
1058
|
+
return __privateGet$2(obj, member, getter);
|
|
1059
|
+
}
|
|
1060
|
+
});
|
|
1061
|
+
var _profileInProgress, _profileStartTs, _trailAnimationFrameId, _recordedTrailingSpans, _longFrameDetector, _longFramesCount, _longFramesTotalTime, _visibilityChangeHandler;
|
|
864
1062
|
const POST_STORM_WINDOW = 2e3;
|
|
865
|
-
const
|
|
1063
|
+
const DEFAULT_LONG_FRAME_THRESHOLD = 30;
|
|
866
1064
|
const TAB_INACTIVE_THRESHOLD = 1e3;
|
|
867
1065
|
class SceneRenderProfiler {
|
|
868
1066
|
constructor(queryController) {
|
|
@@ -872,10 +1070,13 @@ class SceneRenderProfiler {
|
|
|
872
1070
|
__privateAdd$2(this, _trailAnimationFrameId, null);
|
|
873
1071
|
// Will keep measured lengths trailing frames
|
|
874
1072
|
__privateAdd$2(this, _recordedTrailingSpans, []);
|
|
875
|
-
|
|
1073
|
+
// Long frame tracking
|
|
1074
|
+
__privateAdd$2(this, _longFrameDetector);
|
|
1075
|
+
__privateAdd$2(this, _longFramesCount, 0);
|
|
1076
|
+
__privateAdd$2(this, _longFramesTotalTime, 0);
|
|
876
1077
|
__privateAdd$2(this, _visibilityChangeHandler, null);
|
|
877
1078
|
this.measureTrailingFrames = (measurementStartTs, lastFrameTime, profileStartTs) => {
|
|
878
|
-
var _a;
|
|
1079
|
+
var _a, _b, _c, _d;
|
|
879
1080
|
const currentFrameTime = performance.now();
|
|
880
1081
|
const frameLength = currentFrameTime - lastFrameTime;
|
|
881
1082
|
if (frameLength > TAB_INACTIVE_THRESHOLD) {
|
|
@@ -894,18 +1095,60 @@ class SceneRenderProfiler {
|
|
|
894
1095
|
const slowFrames = processRecordedSpans(__privateGet$2(this, _recordedTrailingSpans));
|
|
895
1096
|
const slowFramesTime = slowFrames.reduce((acc, val) => acc + val, 0);
|
|
896
1097
|
writeSceneLog(
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
slowFramesTime,
|
|
900
|
-
slowFrames,
|
|
901
|
-
__privateGet$2(this, _profileInProgress)
|
|
1098
|
+
"SceneRenderProfiler",
|
|
1099
|
+
`Profile tail recorded - Slow frames: ${slowFramesTime.toFixed(1)}ms (${slowFrames.length} frames)`
|
|
902
1100
|
);
|
|
1101
|
+
writeSceneLog("", ` \u251C\u2500 Origin: ${((_a = __privateGet$2(this, _profileInProgress)) == null ? void 0 : _a.origin) || "unknown"}`);
|
|
1102
|
+
writeSceneLog("", ` \u2514\u2500 Crumbs:`, ((_b = __privateGet$2(this, _profileInProgress)) == null ? void 0 : _b.crumbs) || []);
|
|
903
1103
|
__privateSet$2(this, _recordedTrailingSpans, []);
|
|
904
1104
|
const profileDuration = measurementStartTs - profileStartTs;
|
|
905
|
-
|
|
906
|
-
this.
|
|
907
|
-
|
|
908
|
-
|
|
1105
|
+
if (typeof performance !== "undefined" && performance.mark) {
|
|
1106
|
+
const profileName = ((_c = __privateGet$2(this, _profileInProgress)) == null ? void 0 : _c.origin) || "unknown";
|
|
1107
|
+
const totalTime = profileDuration + slowFramesTime;
|
|
1108
|
+
performance.mark(`Dashboard Profile End: ${profileName}`);
|
|
1109
|
+
const startMarkName = `Dashboard Profile Start: ${profileName}`;
|
|
1110
|
+
try {
|
|
1111
|
+
performance.measure(
|
|
1112
|
+
`Dashboard Profile: ${profileName} (${totalTime.toFixed(1)}ms)`,
|
|
1113
|
+
startMarkName,
|
|
1114
|
+
`Dashboard Profile End: ${profileName}`
|
|
1115
|
+
);
|
|
1116
|
+
} catch (e) {
|
|
1117
|
+
performance.mark(`Dashboard Profile Complete: ${profileName} (${totalTime.toFixed(1)}ms)`);
|
|
1118
|
+
}
|
|
1119
|
+
if (slowFrames.length > 0) {
|
|
1120
|
+
const slowFramesMarkName = `Slow Frames Summary: ${slowFrames.length} frames (${slowFramesTime.toFixed(
|
|
1121
|
+
1
|
|
1122
|
+
)}ms)`;
|
|
1123
|
+
performance.mark(slowFramesMarkName);
|
|
1124
|
+
slowFrames.forEach((frameTime, index) => {
|
|
1125
|
+
if (frameTime > 16) {
|
|
1126
|
+
try {
|
|
1127
|
+
const frameStartTime = __privateGet$2(this, _profileStartTs) + profileDuration + (index > 0 ? slowFrames.slice(0, index).reduce((sum, t) => sum + t, 0) : 0);
|
|
1128
|
+
const frameId = `slow-frame-${index}`;
|
|
1129
|
+
const frameStartMark = `${frameId}-start`;
|
|
1130
|
+
const frameEndMark = `${frameId}-end`;
|
|
1131
|
+
performance.mark(frameStartMark, { startTime: frameStartTime });
|
|
1132
|
+
performance.mark(frameEndMark, { startTime: frameStartTime + frameTime });
|
|
1133
|
+
performance.measure(`Slow Frame ${index + 1}: ${frameTime.toFixed(1)}ms`, frameStartMark, frameEndMark);
|
|
1134
|
+
} catch (e) {
|
|
1135
|
+
performance.mark(`Slow Frame ${index + 1}: ${frameTime.toFixed(1)}ms`);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
const completionTimestamp = performance.now();
|
|
1142
|
+
writeSceneLog("SceneRenderProfiler", "Profile completed");
|
|
1143
|
+
writeSceneLog("", ` \u251C\u2500 Timestamp: ${completionTimestamp.toFixed(1)}ms`);
|
|
1144
|
+
writeSceneLog("", ` \u251C\u2500 Total time: ${(profileDuration + slowFramesTime).toFixed(1)}ms`);
|
|
1145
|
+
writeSceneLog("", ` \u251C\u2500 Slow frames: ${slowFramesTime}ms (${slowFrames.length} frames)`);
|
|
1146
|
+
writeSceneLog("", ` \u2514\u2500 Long frames: ${__privateGet$2(this, _longFramesTotalTime)}ms (${__privateGet$2(this, _longFramesCount)} frames)`);
|
|
1147
|
+
__privateGet$2(this, _longFrameDetector).stop();
|
|
1148
|
+
writeSceneLogStyled(
|
|
1149
|
+
"SceneRenderProfiler",
|
|
1150
|
+
`Stopped long frame detection - profile complete at ${completionTimestamp.toFixed(1)}ms`,
|
|
1151
|
+
"color: #00CC00; font-weight: bold;"
|
|
909
1152
|
);
|
|
910
1153
|
__privateSet$2(this, _trailAnimationFrameId, null);
|
|
911
1154
|
const profileEndTs = profileStartTs + profileDuration + slowFramesTime;
|
|
@@ -917,7 +1160,7 @@ class SceneRenderProfiler {
|
|
|
917
1160
|
end: profileEndTs
|
|
918
1161
|
});
|
|
919
1162
|
const networkDuration = captureNetwork(profileStartTs, profileEndTs);
|
|
920
|
-
if (((
|
|
1163
|
+
if (((_d = this.queryController) == null ? void 0 : _d.state.onProfileComplete) && __privateGet$2(this, _profileInProgress)) {
|
|
921
1164
|
this.queryController.state.onProfileComplete({
|
|
922
1165
|
origin: __privateGet$2(this, _profileInProgress).origin,
|
|
923
1166
|
crumbs: __privateGet$2(this, _profileInProgress).crumbs,
|
|
@@ -925,6 +1168,8 @@ class SceneRenderProfiler {
|
|
|
925
1168
|
networkDuration,
|
|
926
1169
|
startTs: profileStartTs,
|
|
927
1170
|
endTs: profileEndTs,
|
|
1171
|
+
longFramesCount: __privateGet$2(this, _longFramesCount),
|
|
1172
|
+
longFramesTotalTime: __privateGet$2(this, _longFramesTotalTime),
|
|
928
1173
|
// @ts-ignore
|
|
929
1174
|
jsHeapSizeLimit: performance.memory ? performance.memory.jsHeapSizeLimit : 0,
|
|
930
1175
|
// @ts-ignore
|
|
@@ -944,6 +1189,7 @@ class SceneRenderProfiler {
|
|
|
944
1189
|
}
|
|
945
1190
|
}
|
|
946
1191
|
};
|
|
1192
|
+
__privateSet$2(this, _longFrameDetector, new LongFrameDetector());
|
|
947
1193
|
this.setupVisibilityChangeHandler();
|
|
948
1194
|
}
|
|
949
1195
|
setQueryController(queryController) {
|
|
@@ -968,6 +1214,7 @@ class SceneRenderProfiler {
|
|
|
968
1214
|
document.removeEventListener("visibilitychange", __privateGet$2(this, _visibilityChangeHandler));
|
|
969
1215
|
__privateSet$2(this, _visibilityChangeHandler, null);
|
|
970
1216
|
}
|
|
1217
|
+
__privateGet$2(this, _longFrameDetector).stop();
|
|
971
1218
|
this.cancelProfile();
|
|
972
1219
|
}
|
|
973
1220
|
startProfile(name) {
|
|
@@ -997,14 +1244,32 @@ class SceneRenderProfiler {
|
|
|
997
1244
|
* - "clean": Started when no profile is currently active
|
|
998
1245
|
*/
|
|
999
1246
|
_startNewProfile(name, force = false) {
|
|
1247
|
+
var _a;
|
|
1000
1248
|
__privateSet$2(this, _profileInProgress, { origin: name, crumbs: [] });
|
|
1001
1249
|
__privateSet$2(this, _profileStartTs, performance.now());
|
|
1002
|
-
|
|
1250
|
+
__privateSet$2(this, _longFramesCount, 0);
|
|
1251
|
+
__privateSet$2(this, _longFramesTotalTime, 0);
|
|
1252
|
+
if (typeof performance !== "undefined" && performance.mark) {
|
|
1253
|
+
const markName = `Dashboard Profile Start: ${name}`;
|
|
1254
|
+
performance.mark(markName);
|
|
1255
|
+
}
|
|
1256
|
+
writeSceneLogStyled(
|
|
1003
1257
|
"SceneRenderProfiler",
|
|
1004
1258
|
`Profile started[${force ? "forced" : "clean"}]`,
|
|
1005
|
-
|
|
1006
|
-
__privateGet$2(this, _profileStartTs)
|
|
1259
|
+
"color: #FFCC00; font-weight: bold;"
|
|
1007
1260
|
);
|
|
1261
|
+
writeSceneLog("", ` \u251C\u2500 Origin: ${((_a = __privateGet$2(this, _profileInProgress)) == null ? void 0 : _a.origin) || "unknown"}`);
|
|
1262
|
+
writeSceneLog("", ` \u2514\u2500 Timestamp: ${__privateGet$2(this, _profileStartTs).toFixed(1)}ms`);
|
|
1263
|
+
__privateGet$2(this, _longFrameDetector).start((event) => {
|
|
1264
|
+
if (!__privateGet$2(this, _profileInProgress) || !__privateGet$2(this, _profileStartTs)) {
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
if (event.timestamp < __privateGet$2(this, _profileStartTs)) {
|
|
1268
|
+
return;
|
|
1269
|
+
}
|
|
1270
|
+
__privateWrapper(this, _longFramesCount)._++;
|
|
1271
|
+
__privateSet$2(this, _longFramesTotalTime, __privateGet$2(this, _longFramesTotalTime) + event.duration);
|
|
1272
|
+
});
|
|
1008
1273
|
}
|
|
1009
1274
|
recordProfileTail(measurementStartTime, profileStartTs) {
|
|
1010
1275
|
__privateSet$2(this, _trailAnimationFrameId, requestAnimationFrame(
|
|
@@ -1015,7 +1280,7 @@ class SceneRenderProfiler {
|
|
|
1015
1280
|
var _a;
|
|
1016
1281
|
writeSceneLog("SceneRenderProfiler", "Trying to complete profile", __privateGet$2(this, _profileInProgress));
|
|
1017
1282
|
if (((_a = this.queryController) == null ? void 0 : _a.runningQueriesCount()) === 0 && __privateGet$2(this, _profileInProgress)) {
|
|
1018
|
-
writeSceneLog("SceneRenderProfiler", "All queries completed,
|
|
1283
|
+
writeSceneLog("SceneRenderProfiler", "All queries completed, starting tail measurement");
|
|
1019
1284
|
this.recordProfileTail(performance.now(), __privateGet$2(this, _profileStartTs));
|
|
1020
1285
|
}
|
|
1021
1286
|
}
|
|
@@ -1038,7 +1303,11 @@ class SceneRenderProfiler {
|
|
|
1038
1303
|
cancelAnimationFrame(__privateGet$2(this, _trailAnimationFrameId));
|
|
1039
1304
|
__privateSet$2(this, _trailAnimationFrameId, null);
|
|
1040
1305
|
}
|
|
1306
|
+
__privateGet$2(this, _longFrameDetector).stop();
|
|
1307
|
+
writeSceneLog("SceneRenderProfiler", "Stopped long frame detection - profile cancelled");
|
|
1041
1308
|
__privateSet$2(this, _recordedTrailingSpans, []);
|
|
1309
|
+
__privateSet$2(this, _longFramesCount, 0);
|
|
1310
|
+
__privateSet$2(this, _longFramesTotalTime, 0);
|
|
1042
1311
|
}
|
|
1043
1312
|
}
|
|
1044
1313
|
addCrumb(crumb) {
|
|
@@ -1052,10 +1321,13 @@ _profileInProgress = new WeakMap();
|
|
|
1052
1321
|
_profileStartTs = new WeakMap();
|
|
1053
1322
|
_trailAnimationFrameId = new WeakMap();
|
|
1054
1323
|
_recordedTrailingSpans = new WeakMap();
|
|
1324
|
+
_longFrameDetector = new WeakMap();
|
|
1325
|
+
_longFramesCount = new WeakMap();
|
|
1326
|
+
_longFramesTotalTime = new WeakMap();
|
|
1055
1327
|
_visibilityChangeHandler = new WeakMap();
|
|
1056
1328
|
function processRecordedSpans(spans) {
|
|
1057
1329
|
for (let i = spans.length - 1; i >= 0; i--) {
|
|
1058
|
-
if (spans[i] >
|
|
1330
|
+
if (spans[i] > DEFAULT_LONG_FRAME_THRESHOLD) {
|
|
1059
1331
|
return spans.slice(0, i + 1);
|
|
1060
1332
|
}
|
|
1061
1333
|
}
|
|
@@ -2868,6 +3140,49 @@ function getEnrichedDataRequest(sourceRunner) {
|
|
|
2868
3140
|
return null;
|
|
2869
3141
|
}
|
|
2870
3142
|
|
|
3143
|
+
let originalGetAdhocFilters = void 0;
|
|
3144
|
+
let allActiveFilterSets = /* @__PURE__ */ new Set();
|
|
3145
|
+
function patchGetAdhocFilters(filterVar) {
|
|
3146
|
+
filterVar.addActivationHandler(() => {
|
|
3147
|
+
allActiveFilterSets.add(filterVar);
|
|
3148
|
+
return () => allActiveFilterSets.delete(filterVar);
|
|
3149
|
+
});
|
|
3150
|
+
if (originalGetAdhocFilters) {
|
|
3151
|
+
return;
|
|
3152
|
+
}
|
|
3153
|
+
const templateSrv = runtime.getTemplateSrv();
|
|
3154
|
+
if (!(templateSrv == null ? void 0 : templateSrv.getAdhocFilters)) {
|
|
3155
|
+
console.log("Failed to patch getAdhocFilters");
|
|
3156
|
+
return;
|
|
3157
|
+
}
|
|
3158
|
+
originalGetAdhocFilters = templateSrv.getAdhocFilters;
|
|
3159
|
+
templateSrv.getAdhocFilters = function getAdhocFiltersScenePatch(dsName) {
|
|
3160
|
+
var _a;
|
|
3161
|
+
if (allActiveFilterSets.size === 0) {
|
|
3162
|
+
return originalGetAdhocFilters.call(templateSrv, dsName);
|
|
3163
|
+
}
|
|
3164
|
+
const ds = runtime.getDataSourceSrv().getInstanceSettings(dsName);
|
|
3165
|
+
if (!ds) {
|
|
3166
|
+
return [];
|
|
3167
|
+
}
|
|
3168
|
+
for (const filter of allActiveFilterSets.values()) {
|
|
3169
|
+
if (((_a = filter.state.datasource) == null ? void 0 : _a.uid) === ds.uid) {
|
|
3170
|
+
return filter.state.filters;
|
|
3171
|
+
}
|
|
3172
|
+
}
|
|
3173
|
+
return [];
|
|
3174
|
+
}.bind(templateSrv);
|
|
3175
|
+
}
|
|
3176
|
+
function findActiveAdHocFilterVariableByUid(dsUid) {
|
|
3177
|
+
var _a;
|
|
3178
|
+
for (const filter of allActiveFilterSets.values()) {
|
|
3179
|
+
if (interpolate(filter, (_a = filter.state.datasource) == null ? void 0 : _a.uid) === dsUid) {
|
|
3180
|
+
return filter;
|
|
3181
|
+
}
|
|
3182
|
+
}
|
|
3183
|
+
return void 0;
|
|
3184
|
+
}
|
|
3185
|
+
|
|
2871
3186
|
const allActiveGroupByVariables = /* @__PURE__ */ new Set();
|
|
2872
3187
|
function findActiveGroupByVariablesByUid(dsUid) {
|
|
2873
3188
|
var _a;
|
|
@@ -3766,49 +4081,6 @@ function toSelectableValue$1(input) {
|
|
|
3766
4081
|
return result;
|
|
3767
4082
|
}
|
|
3768
4083
|
|
|
3769
|
-
let originalGetAdhocFilters = void 0;
|
|
3770
|
-
const allActiveFilterSets = /* @__PURE__ */ new Set();
|
|
3771
|
-
function patchGetAdhocFilters(filterVar) {
|
|
3772
|
-
filterVar.addActivationHandler(() => {
|
|
3773
|
-
allActiveFilterSets.add(filterVar);
|
|
3774
|
-
return () => allActiveFilterSets.delete(filterVar);
|
|
3775
|
-
});
|
|
3776
|
-
if (originalGetAdhocFilters) {
|
|
3777
|
-
return;
|
|
3778
|
-
}
|
|
3779
|
-
const templateSrv = runtime.getTemplateSrv();
|
|
3780
|
-
if (!(templateSrv == null ? void 0 : templateSrv.getAdhocFilters)) {
|
|
3781
|
-
console.log("Failed to patch getAdhocFilters");
|
|
3782
|
-
return;
|
|
3783
|
-
}
|
|
3784
|
-
originalGetAdhocFilters = templateSrv.getAdhocFilters;
|
|
3785
|
-
templateSrv.getAdhocFilters = function getAdhocFiltersScenePatch(dsName) {
|
|
3786
|
-
var _a;
|
|
3787
|
-
if (allActiveFilterSets.size === 0) {
|
|
3788
|
-
return originalGetAdhocFilters.call(templateSrv, dsName);
|
|
3789
|
-
}
|
|
3790
|
-
const ds = runtime.getDataSourceSrv().getInstanceSettings(dsName);
|
|
3791
|
-
if (!ds) {
|
|
3792
|
-
return [];
|
|
3793
|
-
}
|
|
3794
|
-
for (const filter of allActiveFilterSets.values()) {
|
|
3795
|
-
if (((_a = filter.state.datasource) == null ? void 0 : _a.uid) === ds.uid) {
|
|
3796
|
-
return filter.state.filters;
|
|
3797
|
-
}
|
|
3798
|
-
}
|
|
3799
|
-
return [];
|
|
3800
|
-
}.bind(templateSrv);
|
|
3801
|
-
}
|
|
3802
|
-
function findActiveAdHocFilterVariableByUid(dsUid) {
|
|
3803
|
-
var _a;
|
|
3804
|
-
for (const filter of allActiveFilterSets.values()) {
|
|
3805
|
-
if (interpolate(filter, (_a = filter.state.datasource) == null ? void 0 : _a.uid) === dsUid) {
|
|
3806
|
-
return filter;
|
|
3807
|
-
}
|
|
3808
|
-
}
|
|
3809
|
-
return void 0;
|
|
3810
|
-
}
|
|
3811
|
-
|
|
3812
4084
|
function LoadingIndicator(props) {
|
|
3813
4085
|
return /* @__PURE__ */ React__default.default.createElement(ui.Tooltip, { content: i18n.t("grafana-scenes.utils.loading-indicator.content-cancel-query", "Cancel query") }, /* @__PURE__ */ React__default.default.createElement(
|
|
3814
4086
|
ui.Icon,
|
|
@@ -6410,60 +6682,6 @@ function areDifferentLayers(a, b) {
|
|
|
6410
6682
|
return false;
|
|
6411
6683
|
}
|
|
6412
6684
|
|
|
6413
|
-
class DrilldownDependenciesManager {
|
|
6414
|
-
constructor(variableDependency) {
|
|
6415
|
-
this._variableDependency = variableDependency;
|
|
6416
|
-
}
|
|
6417
|
-
/**
|
|
6418
|
-
* Walk up scene graph and find the closest filterset with matching data source
|
|
6419
|
-
*/
|
|
6420
|
-
findAndSubscribeToDrilldowns(interpolatedUid) {
|
|
6421
|
-
const filtersVar = findActiveAdHocFilterVariableByUid(interpolatedUid);
|
|
6422
|
-
const groupByVar = findActiveGroupByVariablesByUid(interpolatedUid);
|
|
6423
|
-
let hasChanges = false;
|
|
6424
|
-
if (this._adhocFiltersVar !== filtersVar) {
|
|
6425
|
-
this._adhocFiltersVar = filtersVar;
|
|
6426
|
-
hasChanges = true;
|
|
6427
|
-
}
|
|
6428
|
-
if (this._groupByVar !== groupByVar) {
|
|
6429
|
-
this._groupByVar = groupByVar;
|
|
6430
|
-
hasChanges = true;
|
|
6431
|
-
}
|
|
6432
|
-
if (hasChanges) {
|
|
6433
|
-
this._updateExplicitDrilldownVariableDependencies();
|
|
6434
|
-
}
|
|
6435
|
-
}
|
|
6436
|
-
_updateExplicitDrilldownVariableDependencies() {
|
|
6437
|
-
const explicitDependencies = [];
|
|
6438
|
-
if (this._adhocFiltersVar) {
|
|
6439
|
-
explicitDependencies.push(this._adhocFiltersVar.state.name);
|
|
6440
|
-
}
|
|
6441
|
-
if (this._groupByVar) {
|
|
6442
|
-
explicitDependencies.push(this._groupByVar.state.name);
|
|
6443
|
-
}
|
|
6444
|
-
this._variableDependency.setVariableNames(explicitDependencies);
|
|
6445
|
-
}
|
|
6446
|
-
get adHocFiltersVar() {
|
|
6447
|
-
return this._adhocFiltersVar;
|
|
6448
|
-
}
|
|
6449
|
-
get groupByVar() {
|
|
6450
|
-
return this._groupByVar;
|
|
6451
|
-
}
|
|
6452
|
-
getFilters() {
|
|
6453
|
-
var _a;
|
|
6454
|
-
return this._adhocFiltersVar ? [...(_a = this._adhocFiltersVar.state.originFilters) != null ? _a : [], ...this._adhocFiltersVar.state.filters].filter(
|
|
6455
|
-
(f) => isFilterComplete(f) && isFilterApplicable(f)
|
|
6456
|
-
) : void 0;
|
|
6457
|
-
}
|
|
6458
|
-
getGroupByKeys() {
|
|
6459
|
-
return this._groupByVar ? this._groupByVar.getApplicableKeys() : void 0;
|
|
6460
|
-
}
|
|
6461
|
-
cleanup() {
|
|
6462
|
-
this._adhocFiltersVar = void 0;
|
|
6463
|
-
this._groupByVar = void 0;
|
|
6464
|
-
}
|
|
6465
|
-
}
|
|
6466
|
-
|
|
6467
6685
|
let counter$1 = 100;
|
|
6468
6686
|
function getNextRequestId$1() {
|
|
6469
6687
|
return "SQR" + counter$1++;
|
|
@@ -6481,7 +6699,6 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
6481
6699
|
onAnyVariableChanged: this.onAnyVariableChanged.bind(this),
|
|
6482
6700
|
dependsOnScopes: true
|
|
6483
6701
|
});
|
|
6484
|
-
this._drilldownDependenciesManager = new DrilldownDependenciesManager(this._variableDependency);
|
|
6485
6702
|
this.onDataReceived = (data$1) => {
|
|
6486
6703
|
const preProcessedData = data.preProcessPanelData(data$1, this.state.data);
|
|
6487
6704
|
this._resultAnnotations = data$1.annotations;
|
|
@@ -6597,7 +6814,7 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
6597
6814
|
* Check if value changed is a adhoc filter o group by variable that did not exist when we issued the last query
|
|
6598
6815
|
*/
|
|
6599
6816
|
onAnyVariableChanged(variable) {
|
|
6600
|
-
if (this.
|
|
6817
|
+
if (this._adhocFiltersVar === variable || this._groupByVar === variable || !this.isQueryModeAuto()) {
|
|
6601
6818
|
return;
|
|
6602
6819
|
}
|
|
6603
6820
|
if (variable instanceof AdHocFiltersVariable && this._isRelevantAutoVariable(variable)) {
|
|
@@ -6651,7 +6868,8 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
6651
6868
|
(_a = this._timeSub) == null ? void 0 : _a.unsubscribe();
|
|
6652
6869
|
this._timeSub = void 0;
|
|
6653
6870
|
this._timeSubRange = void 0;
|
|
6654
|
-
this.
|
|
6871
|
+
this._adhocFiltersVar = void 0;
|
|
6872
|
+
this._groupByVar = void 0;
|
|
6655
6873
|
}
|
|
6656
6874
|
setContainerWidth(width) {
|
|
6657
6875
|
if (!this._containerWidth && width > 0) {
|
|
@@ -6732,7 +6950,7 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
6732
6950
|
try {
|
|
6733
6951
|
const datasource = (_c = this.state.datasource) != null ? _c : findFirstDatasource(queries);
|
|
6734
6952
|
const ds = await getDataSource(datasource, this._scopedVars);
|
|
6735
|
-
this.
|
|
6953
|
+
this.findAndSubscribeToAdHocFilters(ds.uid);
|
|
6736
6954
|
const runRequest = runtime.getRunRequest();
|
|
6737
6955
|
const { primary, secondaries, processors } = this.prepareRequests(timeRange, ds);
|
|
6738
6956
|
writeSceneLog("SceneQueryRunner", "Starting runRequest", this.state.key);
|
|
@@ -6776,7 +6994,7 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
6776
6994
|
return clone;
|
|
6777
6995
|
}
|
|
6778
6996
|
prepareRequests(timeRange, ds) {
|
|
6779
|
-
var _a;
|
|
6997
|
+
var _a, _b;
|
|
6780
6998
|
const { minInterval, queries } = this.state;
|
|
6781
6999
|
let request = {
|
|
6782
7000
|
app: "scenes",
|
|
@@ -6800,13 +7018,14 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
6800
7018
|
// This asks the scene root to provide context properties like app, panel and dashboardUID
|
|
6801
7019
|
...getEnrichedDataRequest(this)
|
|
6802
7020
|
};
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
7021
|
+
if (this._adhocFiltersVar) {
|
|
7022
|
+
request.filters = [
|
|
7023
|
+
...(_a = this._adhocFiltersVar.state.originFilters) != null ? _a : [],
|
|
7024
|
+
...this._adhocFiltersVar.state.filters
|
|
7025
|
+
].filter((f) => isFilterComplete(f) && isFilterApplicable(f));
|
|
6807
7026
|
}
|
|
6808
|
-
if (
|
|
6809
|
-
request.groupByKeys =
|
|
7027
|
+
if (this._groupByVar) {
|
|
7028
|
+
request.groupByKeys = this._groupByVar.getApplicableKeys();
|
|
6810
7029
|
}
|
|
6811
7030
|
request.targets = request.targets.map((query) => {
|
|
6812
7031
|
var _a2;
|
|
@@ -6826,7 +7045,7 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
6826
7045
|
const primaryTimeRange = timeRange.state.value;
|
|
6827
7046
|
let secondaryRequests = [];
|
|
6828
7047
|
let secondaryProcessors = /* @__PURE__ */ new Map();
|
|
6829
|
-
for (const provider of (
|
|
7048
|
+
for (const provider of (_b = this.getClosestExtraQueryProviders()) != null ? _b : []) {
|
|
6830
7049
|
for (const { req, processor } of provider.getExtraQueries(request)) {
|
|
6831
7050
|
const requestId = getNextRequestId$1();
|
|
6832
7051
|
secondaryRequests.push({ ...req, requestId });
|
|
@@ -6873,6 +7092,31 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
6873
7092
|
});
|
|
6874
7093
|
return Array.from(found.values());
|
|
6875
7094
|
}
|
|
7095
|
+
/**
|
|
7096
|
+
* Walk up scene graph and find the closest filterset with matching data source
|
|
7097
|
+
*/
|
|
7098
|
+
findAndSubscribeToAdHocFilters(interpolatedUid) {
|
|
7099
|
+
const filtersVar = findActiveAdHocFilterVariableByUid(interpolatedUid);
|
|
7100
|
+
if (this._adhocFiltersVar !== filtersVar) {
|
|
7101
|
+
this._adhocFiltersVar = filtersVar;
|
|
7102
|
+
this._updateExplicitVariableDependencies();
|
|
7103
|
+
}
|
|
7104
|
+
const groupByVar = findActiveGroupByVariablesByUid(interpolatedUid);
|
|
7105
|
+
if (this._groupByVar !== groupByVar) {
|
|
7106
|
+
this._groupByVar = groupByVar;
|
|
7107
|
+
this._updateExplicitVariableDependencies();
|
|
7108
|
+
}
|
|
7109
|
+
}
|
|
7110
|
+
_updateExplicitVariableDependencies() {
|
|
7111
|
+
const explicitDependencies = [];
|
|
7112
|
+
if (this._adhocFiltersVar) {
|
|
7113
|
+
explicitDependencies.push(this._adhocFiltersVar.state.name);
|
|
7114
|
+
}
|
|
7115
|
+
if (this._groupByVar) {
|
|
7116
|
+
explicitDependencies.push(this._groupByVar.state.name);
|
|
7117
|
+
}
|
|
7118
|
+
this._variableDependency.setVariableNames(explicitDependencies);
|
|
7119
|
+
}
|
|
6876
7120
|
isQueryModeAuto() {
|
|
6877
7121
|
var _a;
|
|
6878
7122
|
return ((_a = this.state.runQueriesMode) != null ? _a : "auto") === "auto";
|
|
@@ -9826,7 +10070,7 @@ let counter = 100;
|
|
|
9826
10070
|
function getNextRequestId() {
|
|
9827
10071
|
return "AQ" + counter++;
|
|
9828
10072
|
}
|
|
9829
|
-
function executeAnnotationQuery(datasource, timeRange, query, layer
|
|
10073
|
+
function executeAnnotationQuery(datasource, timeRange, query, layer) {
|
|
9830
10074
|
var _a;
|
|
9831
10075
|
if (datasource.annotationQuery && shouldUseLegacyRunner(datasource)) {
|
|
9832
10076
|
console.warn("Using deprecated annotationQuery method, please upgrade your datasource");
|
|
@@ -9893,8 +10137,6 @@ function executeAnnotationQuery(datasource, timeRange, query, layer, filters, gr
|
|
|
9893
10137
|
}
|
|
9894
10138
|
],
|
|
9895
10139
|
scopes: sceneGraph.getScopes(layer),
|
|
9896
|
-
filters,
|
|
9897
|
-
groupByKeys,
|
|
9898
10140
|
...getEnrichedDataRequest(layer)
|
|
9899
10141
|
};
|
|
9900
10142
|
const runRequest = runtime.getRunRequest();
|
|
@@ -9993,7 +10235,6 @@ class AnnotationsDataLayer extends SceneDataLayerBase {
|
|
|
9993
10235
|
this._scopedVars = {
|
|
9994
10236
|
__sceneObject: wrapInSafeSerializableSceneObject(this)
|
|
9995
10237
|
};
|
|
9996
|
-
this._drilldownDependenciesManager = new DrilldownDependenciesManager(this._variableDependency);
|
|
9997
10238
|
}
|
|
9998
10239
|
onEnable() {
|
|
9999
10240
|
this.publishEvent(new runtime.RefreshEvent(), true);
|
|
@@ -10025,12 +10266,10 @@ class AnnotationsDataLayer extends SceneDataLayerBase {
|
|
|
10025
10266
|
this.runWithTimeRange(timeRange);
|
|
10026
10267
|
}
|
|
10027
10268
|
async runWithTimeRange(timeRange) {
|
|
10028
|
-
var _a;
|
|
10029
10269
|
const { query } = this.state;
|
|
10030
10270
|
if (!query.enable) {
|
|
10031
10271
|
return;
|
|
10032
10272
|
}
|
|
10033
|
-
this._drilldownDependenciesManager.findAndSubscribeToDrilldowns((_a = query.datasource) == null ? void 0 : _a.uid);
|
|
10034
10273
|
if (this.querySub) {
|
|
10035
10274
|
this.querySub.unsubscribe();
|
|
10036
10275
|
}
|
|
@@ -10040,14 +10279,7 @@ class AnnotationsDataLayer extends SceneDataLayerBase {
|
|
|
10040
10279
|
}
|
|
10041
10280
|
try {
|
|
10042
10281
|
const ds = await this.resolveDataSource(query);
|
|
10043
|
-
let stream = executeAnnotationQuery(
|
|
10044
|
-
ds,
|
|
10045
|
-
timeRange,
|
|
10046
|
-
query,
|
|
10047
|
-
this,
|
|
10048
|
-
this._drilldownDependenciesManager.getFilters(),
|
|
10049
|
-
this._drilldownDependenciesManager.getGroupByKeys()
|
|
10050
|
-
).pipe(
|
|
10282
|
+
let stream = executeAnnotationQuery(ds, timeRange, query, this).pipe(
|
|
10051
10283
|
registerQueryWithController({
|
|
10052
10284
|
type: "AnnotationsDataLayer/annotationsLoading",
|
|
10053
10285
|
origin: this,
|