Frame encoding within Grafana
Case Backend Plugin:
- If going to frontend leave it encoded
- If going to alerting, decode it
Case Core (Internal) Datasource:
- Encode Frames when sending to frontend
Underlying assumption is we do not want to just always decode and then encode it, even though this would reduce possible code paths. The reasons not to do it are:
- Decoding and Encoding consumes resources, so do not want to do it if it is not needed.
- It would get in the way of trying out new features in the SDK with a current version of Grafana. Warning, the "why" is a bit confusing, but follows: In many cases when using a backend plugin we want to try out newer data frame features without updating Grafana. This can be done because FrameMeta and FieldMeta are in the SDK and encoded to bytes. So if both the backend plugin and frontend use new properties, Grafana doesn't need to be updated because in this case it is just passing bytes.
From perspective when authoring
When authoring X, ideally:
- Core (Internal) Datasource: Just return data frames, do not need to worry about encoding.
- Backend Plugin: Same as above (and it is already like this)
- Alerting: Receive unencoded data frames
However with Alerting, until we have removed tsdb.TimeSeries from alerting, it is probably fine to just un-encode them if that is easier.