-
Notifications
You must be signed in to change notification settings - Fork 190
Support a datasource which may be a map #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support a datasource which may be a map #190
Conversation
In recent versions of Grafana the datasource can be either a string or a map with entries for type and uid. Support both of these cases by using an interface which will allow backwards compatiblity.
|
I am kind of hesitant to open the floodgates for more |
|
I am OK with that, I can keep my branch open so that users who need this before generics are available/have not upgraded yet. I guess it really depends on how fast you want to move this library to generics. |
|
Oh, I haven't seen this PR. I submitted a different one without generics but also without |
|
Hey everyone! I was wondering whether this might be merged soon? This might solve mpostument/grafana-sync#43 which is blocking some parts for us. |
|
Pretty please... |
|
@GiedriusS I gave the generics bit a go, but there's a few issues unless someone has some insight I think you may be limited to using interface or the Reference type that @colega introduced. Here's my attempt at using it. https://go.dev/play/p/Ogk59A6RHbC The main issue I see is that you would have to know ahead of time what the data type is in order to serialize the code. You'd likely have to create a t := Board[map[string]string]{} It fails to address the core of the issue which is we don't know if it'll be a map or a string. If anyone has any suggestion on how to use generics AND allow for nondeterministic behavior or the response i'm happy to try to add this in. |
|
Just a heads-up that we're all still waiting :) As far as I can tell the instructions on the main site won't work until a fix is pushed out https://grafana.com/docs/grafana-cloud/metrics-control-usage/control-prometheus-metrics-usage/usage-analysis-cortextool/ Thanks |
|
I'll take a look soon, a bit on vacation ATM. |
|
Any updates on this change? |
|
@GiedriusS any thoughts on this PR or alternate approaches you'd prefer? |
GiedriusS
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge this as is and wait for proper sum type support in Go ;(
In recent versions of Grafana the datasource can be either a string or a map with entries for type and uid. Support both of these cases by using an interface which will allow backwards compatiblity.
In recent versions of Grafana the datasource can be either a string or a
map with entries for type and uid. Support both of these cases by using
an interface which will allow backwards compatiblity.
Alternatively, I could change Datasource to a more concrete type that
can marshal/unmarshal from a string or map, but that would break anyone
just setting it to a string right now. Let me know what you think!
See grafana/grafana#33817 for more context on the
change in Grafana.