How to differentiate between refresh events in the EventBus

I am working on a custom plugin that handles data fetching manually using the grafana query proxy. Currently, I am tracking refresh events and using that as a trigger for a new fetch request because I wanted to capture the functionality that if a user presses the refresh button it should refetch data in the panel.

However a side effect of this is that if any other panel triggers a refresh event it will cause an otherwise unaffected instance of my plugin to refetch. This is unintended as the default behavior for Grafana standard components is that they won’t refetch for every refresh event. As context I do not have automatic refreshes enabled, and they will not be enabled for the scope of my plugin use cases.

The issue that I am having is that looking into the EventBus to track refresh events, there doesn’t seem to be any way of differentiating refresh events, or telling where they were initiated from. It seems this was changed somewhat recently, as there is old documentation that references fields in the EventBus that do not exist anymore.

How can I differentiate between refresh events so my plugin isn’t needlessly refetching data when it doesn’t need to, matching the default behavior of other standard Grafana visualizations?

(The eventBus source code can be found here, and there is no clear way to tell the difference of any refresh event.
grafana/packages/grafana-runtime/src/services/appEvents.ts at main · grafana/grafana · GitHub )

What am I missing?!
Thanks in advance

Hi @nullburner I will assume you are working in a data source plugin.

Data source plugins shouldn’t decide when to fetch data, Grafana tells them when, for example when the user clicked refresh, or there’s an auto refresh.

My advice is to drop this functionality because it is not needed at the plugin level.
if the user needs new data, they can press the refresh data, if the user needs it at an interval, they can set the interval in the dashboard.

Hi @academo, my plugin isn’t a data source. Its a visualization panel plugin that manually controls data flow instead of letting Grafana do it. This level of data flow control is required for my plugin in order to optimize timing and processing. This is done as my plugin interfaces with very large amounts of data, and Grafana wait times for data can be extremely long from feedback from users.

This functionality is already built out in the plugin, the current problem is that the refresh events are not behaving the same as default Grafana plugins. This is because the only exposed event to subscribe to that I know of doesn’t have any additional information besides it being a refresh event.

Any help in this direction would be much appreciated.