Get explodes when underlying metric is composite
Howdy!
So when I make call to get
b = self.conn.get('SuperSecret-metric-name')
I get the following exception
'The server sent me something that is not a Gauge nor a Counter.'
What is going on is the metric being returned is a composite metric.
In fact with this commit I get something that works
https://github.com/Bachmann1234/python-librato/commit/e35bcd4d8a6400097a82ad3cfd67783c740468ba
Now, normally I would just make a PR about this and call it a day. But, I do not wanna do that here. Because this would make the get method return an object in some cases and a dict in other cases. Which seems bad.
I saw that basic composite support was added in https://github.com/librato/python-librato/pull/79
You chose not to make an object. Was this just the easiest thing at the time? In short... would it be a problem if I made a composite object and had get return that?
If I do that could I change get_composite to return the object instead of the raw response dict?
Also, where can I read more about these? My initial poking around did not find too much detail.
Ah, found this http://support.metrics.librato.com/knowledgebase/articles/337431-composite-metrics-language-specification
@Bachmann1234 sorry I haven't had a chance to move forward on this. To answer your question, yes, #79 was to get the easiest thing done which is why I did not pollute the get() method (yet). I think if get returned a composite object that would be great, but I agree it shouldn't return the raw dict. Hopefully we'll have some bandwidth to devote to this soon. Thanks!
You bring a good point @Bachmann1234, thanks.
Composite metrics are a little bit peculiar and I would advice modeling them with basic data structures. Is there any particular pain we would fix if we model composite responses with objects ?
@drio nah. If using the dict is better for you go ahead. I was raising it for consistency reasons. Either having all dicts or all objects.
I was mostly playing around our metrics trying to make a report back when I was playing in this area of the library. Nothing mission critical.