grafana / scenes

Build Grafana dashboards directly in your Grafana app plugins.
https://grafana.com/developers/scenes
Apache License 2.0
141 stars 21 forks source link

SceneVariableSet: Notify scene objects that use time macros when time changes #966

Closed torkelo closed 2 days ago

torkelo commented 4 days ago

Thought this was a clever solution (Making SceneVariableSet notify scene objects that use from and to macro when time range changes).

But it makes it so that SceneQueryRunner executes double queries when a query is using these macros (as SceneQueryRunner is already subscribing to time range).

Need a way to dedupe those updates.

Possible solutions

kaydelaney commented 4 days ago

Tested locally and it seems to work, and the code looks good. Maybe making it opt-in is safest for the moment?

torkelo commented 3 days ago

@kaydelaney after thinking more about it I did not like this solution much, becomes a bit complex to have it be opt-in from SceneVariableSet (would need to have some kind of special handling for this variable in the propagation chain).

Also feels a bit messy that when time range change we propagate variable change updates for for from and to (causing double updates when a scene object depends on both).

Opted for a simpler feature in VariableDependencyConfig that can handle the opt-in & and the time range subscription.