@@ -2611,14 +2611,30 @@ def test_functions_dataset_simple(self):
26112611 "start" : iso_format (self .three_days_ago ),
26122612 "end" : iso_format (self .one_day_ago ),
26132613 "interval" : "1d" ,
2614- "yAxis" : "cpm()" ,
2614+ "yAxis" : [ "cpm()" , "p95(function.duration)" ] ,
26152615 }
26162616
26172617 response = self .client .get (self .url , data = data , format = "json" )
26182618 assert response .status_code == 200 , response .content
2619- assert sum (row [1 ][0 ]["count" ] for row in response .data ["data" ]) == pytest .approx (
2619+
2620+ assert sum (row [1 ][0 ]["count" ] for row in response .data ["cpm()" ]["data" ]) == pytest .approx (
26202621 100 / ((self .one_day_ago - self .three_days_ago ).total_seconds () / 60 ), rel = 1e-3
26212622 )
2623+ assert any (
2624+ row [1 ][0 ]["count" ] > 0 for row in response .data ["p95(function.duration)" ]["data" ]
2625+ )
2626+
2627+ for y_axis in ["cpm()" , "p95(function.duration)" ]:
2628+ assert response .data [y_axis ]["meta" ]["fields" ] == {
2629+ "time" : "date" ,
2630+ "cpm" : "number" ,
2631+ "p95_function_duration" : "duration" ,
2632+ }
2633+ assert response .data [y_axis ]["meta" ]["units" ] == {
2634+ "time" : None ,
2635+ "cpm" : None ,
2636+ "p95_function_duration" : "nanosecond" ,
2637+ }
26222638
26232639
26242640@region_silo_test
@@ -2667,17 +2683,28 @@ def test_functions_dataset_simple(self):
26672683 "field" : ["function" , "count()" ],
26682684 "start" : iso_format (self .three_days_ago ),
26692685 "end" : iso_format (self .one_day_ago ),
2670- "yAxis" : "cpm()" ,
2686+ "yAxis" : [ "cpm()" , "p95(function.duration)" ] ,
26712687 "interval" : "1d" ,
26722688 "topEvents" : 2 ,
26732689 "excludeOther" : 1 ,
26742690 }
26752691
26762692 response = self .client .get (self .url , data = data , format = "json" )
26772693 assert response .status_code == 200 , response .content
2678- assert sum (row [1 ][0 ]["count" ] for row in response .data ["foo" ]["data" ]) == pytest .approx (
2694+ assert sum (
2695+ row [1 ][0 ]["count" ] for row in response .data ["foo" ]["cpm()" ]["data" ]
2696+ ) == pytest .approx (
26792697 100 / ((self .one_day_ago - self .three_days_ago ).total_seconds () / 60 ), rel = 1e-3
26802698 )
2681- assert sum (row [1 ][0 ]["count" ] for row in response .data ["bar" ]["data" ]) == pytest .approx (
2699+ assert sum (
2700+ row [1 ][0 ]["count" ] for row in response .data ["bar" ]["cpm()" ]["data" ]
2701+ ) == pytest .approx (
26822702 10 / ((self .one_day_ago - self .three_days_ago ).total_seconds () / 60 ), rel = 1e-3
26832703 )
2704+
2705+ assert any (
2706+ row [1 ][0 ]["count" ] > 0 for row in response .data ["foo" ]["p95(function.duration)" ]["data" ]
2707+ )
2708+ assert any (
2709+ row [1 ][0 ]["count" ] > 0 for row in response .data ["bar" ]["p95(function.duration)" ]["data" ]
2710+ )
0 commit comments