You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you. Great work. Would still like to see some additional changes before we can publish this. Let us know if you don't agree.
Instance management:
It does works better now, but I still see that potential raise conditions could occur when initializing the session.
As I wrote earlier:
Since you're using the datasource instance management you should initialize and cache a field on the CassandraDatasource struct. To me it seems like the clusterconfig should be initialized and cached on CassandraDatasource struct and then you'll use that to create/open a session per request and close it at the end.
In the example it uses the NewDataSource for instantiating a new datasource instance - this is called each time a datasource in created/updated in Grafana and locking/concurrency guarantees that it only executes exactly once for every datasource created/updated in Grafana . This is the recommended location for instantiating clients and such, e.g. your clusterconfig.
Logging:
For example this line that logs, rather than using logger.Debug(fmt.Sprintf("Created datasource, ID: %d\n", settings.ID)) we recommend to use structured logging, e.g. logger.Debug("Created datasource", "uid", settings.UID)
Would recommend using lowercase keys when logging, e.g. message instead of Message, to follow Grafana's convention.
Inconsistent use of warning/error log levels, e.g. here warning are used and here error are used. Can you please use error level everywhere when logging an error?
Thank you. Great work. Would still like to see some additional changes before we can publish this. Let us know if you don't agree.
Instance management:
It does works better now, but I still see that potential raise conditions could occur when initializing the session.
As I wrote earlier:
We have an example, see /~https://github.com/grafana/grafana-plugin-examples/blob/master/examples/datasource-basic/pkg/main.go#L20, which I think should simplify your code for serving the plugin and handle the Cassandra connections/sessions.
In the example it uses the NewDataSource for instantiating a new datasource instance - this is called each time a datasource in created/updated in Grafana and locking/concurrency guarantees that it only executes exactly once for every datasource created/updated in Grafana . This is the recommended location for instantiating clients and such, e.g. your clusterconfig.
Logging:
Kind regards,
The Grafana Team
The text was updated successfully, but these errors were encountered: