grafana / grafana

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
https://grafana.com
GNU Affero General Public License v3.0
60.72k stars 11.61k forks source link

mysql: fix dispose-method not called in external-mode #87330

Closed gabor closed 1 week ago

gabor commented 2 weeks ago

this change ensures that the Dispose() method is called both in external-mode and core-mode.

changes:

  1. added CheckHealth to the sql_engine.go structure (otherwise there is no CheckHealth in external-mode)
  2. moved all the ProvideService things into mysqL_service.go (added a forward for CheckHealth)

how to test: basically, we need to see the debug-level log-lines Disposing DB... and DB disposed, in both core and external mode. so, make sure the grafana you use has log-level-debug enabled, something like this in the config:

[log]
level = debug

1.as core plugin (the default behavior)

[plugin.mysql] as_external = true



- build the plugin
        - run `make build-plugin-go PLUGIN_ID=mysql` . this will generate the "backend" binaries in `public/app/plugins/datasource/mysql/dist`
        - run `yarn workspace @grafana-plugins/mysql build`. this will generate the "frontend" files in `public/app/plugins/datasource/mysql/dist`
        - at this point all the needed files are in `public/app/plugins/datasource/mysql/dist`
        - make sure to copy/move the `dist` files to somewhere where your grafana expects plugin-files (i think in the usual devel grafana situation it's the `path/plugins` folder.
- run grafana
- go to `plugins`, choose `mysql`. check what it says under `signature`. it should be `unsigned`, not `core`.
- do the same steps as we did in the core-mode (verify sql works, verify `[save&test]` shows the required log-lines)
gabor commented 1 week ago

/deploy-to-hg

ephemeral-instances-bot[bot] commented 1 week ago
ephemeral-instances-bot[bot] commented 1 week ago