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.
this change ensures that the Dispose() method is called both in external-mode and core-mode.
changes:
added CheckHealth to the sql_engine.go structure (otherwise there is no CheckHealth in external-mode)
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)
just run it as always (yarn start and make run)
verify that you are running mysql in it's normal mode
go to plugins, choose mysql. verify that in the signature section it says core
make sure the mysql datasource plugin still works (just run a query like select 4*5 in explore)
go to the datasource config page, press [save & test]
clear the terminal where the logs are shown
press [save & test] again
verify that after a couple seconds the required log-lines appear (Disposing DB... & DB disposed) (these will appear after a short delay, not immediately)
make sure it runs as an external plugin. add this to the grafana-config:
[feature_toggles]
externalCorePlugins = true
[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)
this change ensures that the
Dispose()
method is called both in external-mode and core-mode.changes:
CheckHealth
to thesql_engine.go
structure (otherwise there is noCheckHealth
in external-mode)ProvideService
things intomysqL_service.go
(added a forward forCheckHealth
)how to test: basically, we need to see the debug-level log-lines
Disposing DB...
andDB disposed
, in bothcore
andexternal
mode. so, make sure the grafana you use has log-level-debug enabled, something like this in the config:1.as core plugin (the default behavior)
yarn start
andmake run
)plugins
, choosemysql
. verify that in thesignature
section it sayscore
select 4*5
in explore)[save & test]
[save & test]
againDisposing DB...
&DB disposed
) (these will appear after a short delay, not immediately)[plugin.mysql] as_external = true