Fix Metric.send() to play nice with multiple metrics#56
Fix Metric.send() to play nice with multiple metrics#56kuzmich wants to merge 2 commits intoDataDog:masterfrom
Conversation
Otherwise it will not process point values
|
+1, running into this problem for integrating with Runscope API tests. Any estimate on getting this added? |
|
@yannmh can you have a look into this one please ? |
|
Thanks a lot @kuzmich for the very detailed explanations ! 1 - You are right, it's a bit confusing. While the documentation attests that the method can be used only with a single list, the examples show the same method being used with a single list and positional arguments. 2 & 3 - I rebased your work, and added an extra commit on top of it to comply with the syntax demoed in the documentation examples (http://docs.datadoghq.com/api/#metrics), i.e. pass a list of metrics as a single positional argument. Metric.send(metrics)instead of Metric.send(*metrics)I opened a new PR here: #59. Thanks again @robinske we can release it this week. |
|
thanks @yannmh, ended up writing the integration without the sdk |
In short, method signature and usage (http://docs.datadoghq.com/api/#metrics) is different and misguiding. Also, it will send the wrong data if user pass list of metrics with
pointsas a single value. Below is a detailed explanation.Here's a Metric.send() method without docstrings:
There're few issues with it:
metricswill be a list of a sinle list ([[your metrics here]]). Let's see what happens next.for metric in metricswill take a list of metrics and compare it with a dict - indeed, list is not a dict, so no calls to cls._process_points(). It will absolutely not changemetricsin any way. Sincepointsmust be a list of lists of timestamp and a value[[timestamp, value]], wrong data will be sent. Though datadog api will say202 Accepted, it will not not accept any data at all.Metric.send(*metrics)), and it will call_process_points()and transform data in the right way. But then it will take only first metric (it will be a dict), and sinceseriesmust be a list, not a dict, we will get an error. And that's what I changed - 1 line of code.