librato / librato-metrics

Ruby wrapper to make it easy to interact with Librato's API.
https://librato.com
Other
108 stars 52 forks source link

Fetch response is case insensitive #95

Open mheffner opened 10 years ago

mheffner commented 10 years ago

If possible, it would be nice to treat the key strings in the fetch response as case insensitive.

The following query will return data for the source "bLaH", but given the API downcases the source names, the hash lookup would then break:

Librato::Metrics.fetch(metric_name, :count => count, :source => "bLaH")["bLaH"]

Maybe a Hash override that downcased key values before lookup?

nextmat commented 10 years ago

Hmm, to clarify you are asking that the hash-accessor keys be case-insensitive?

mheffner commented 10 years ago

@nextmat Correct, so that the following would work:

{"blah" => <...>}["bLaH"]

nextmat commented 10 years ago

@mheffner The only real way to do this consistently is rewrite all the of the responses from native types to something that wraps them for case-insensitive access. For small payloads this is no big deal but in larger cases it could be a memory/perf issue.

After pondering a bit I'm of the opinion that if this is something people want they should do it after they get the results from this lib, via something like HashWithIndifferentAccess or map.