@@ -822,20 +822,16 @@ def test_create_timeseries(self, monitor_resource_mock):
822822
823823 self .assertEqual (len (time_series .points ), 1 )
824824 value = time_series .points [0 ].value
825- self .assertEqual (value .distribution_value .count , 1 )
826825
827- time_series_list = exporter .create_time_series_list (v_data )
828-
829- self .assertEqual (len (time_series_list ), 1 )
830- time_series = time_series_list [0 ]
831- self .check_labels (
832- time_series .metric .labels , {FRONTEND_KEY_CLEAN : "1200" },
833- include_opencensus = True )
834- self .assertIsNotNone (time_series .resource )
835-
836- self .assertEqual (len (time_series .points ), 1 )
837- value = time_series .points [0 ].value
838- self .assertEqual (value .distribution_value .count , 1 )
826+ expected_distb = google .api .distribution_pb2 .Distribution (
827+ count = 1 ,
828+ mean = 26214400.0 ,
829+ bucket_options = google .api .distribution_pb2 .Distribution .BucketOptions ( # noqa
830+ explicit_buckets = google .api .distribution_pb2 .Distribution .BucketOptions .Explicit ( # noqa
831+ bounds = [0.0 , 16777216.0 , 268435456.0 ])),
832+ bucket_counts = [0 , 0 , 1 , 0 ]
833+ )
834+ self .assertEqual (value .distribution_value , expected_distb )
839835
840836 @mock .patch ('opencensus.ext.stackdriver.stats_exporter.'
841837 'monitored_resource.get_instance' )
@@ -1213,7 +1209,16 @@ def test_create_timeseries_multiple_tag_values(self,
12131209
12141210 self .assertEqual (len (ts1 .points ), 1 )
12151211 value1 = ts1 .points [0 ].value
1216- self .assertEqual (value1 .distribution_value .count , 1 )
1212+
1213+ expected_distb = google .api .distribution_pb2 .Distribution (
1214+ count = 1 ,
1215+ mean = 26214400.0 ,
1216+ bucket_options = google .api .distribution_pb2 .Distribution .BucketOptions ( # noqa
1217+ explicit_buckets = google .api .distribution_pb2 .Distribution .BucketOptions .Explicit ( # noqa
1218+ bounds = [0.0 , 16777216.0 , 268435456.0 ])),
1219+ bucket_counts = [0 , 0 , 1 , 0 ]
1220+ )
1221+ self .assertEqual (value1 .distribution_value , expected_distb )
12171222
12181223 # Verify second time series
12191224 self .assertEqual (ts2 .resource .type , "global" )
@@ -1224,7 +1229,16 @@ def test_create_timeseries_multiple_tag_values(self,
12241229
12251230 self .assertEqual (len (ts2 .points ), 1 )
12261231 value2 = ts2 .points [0 ].value
1227- self .assertEqual (value2 .distribution_value .count , 1 )
1232+
1233+ expected_distb = google .api .distribution_pb2 .Distribution (
1234+ count = 1 ,
1235+ mean = 12582912.0 ,
1236+ bucket_options = google .api .distribution_pb2 .Distribution .BucketOptions ( # noqa
1237+ explicit_buckets = google .api .distribution_pb2 .Distribution .BucketOptions .Explicit ( # noqa
1238+ bounds = [0.0 , 16777216.0 , 268435456.0 ])),
1239+ bucket_counts = [0 , 1 , 0 , 0 ]
1240+ )
1241+ self .assertEqual (value2 .distribution_value , expected_distb )
12281242
12291243 @mock .patch ('opencensus.ext.stackdriver.stats_exporter.'
12301244 'monitored_resource.get_instance' ,
@@ -1315,12 +1329,18 @@ def test_create_timeseries_from_distribution(self):
13151329 include_opencensus = True )
13161330 self .assertEqual (len (time_series .points ), 1 )
13171331 [point ] = time_series .points
1332+
13181333 dv = point .value .distribution_value
1319- self .assertEqual (100 , dv .count )
1320- self .assertEqual (825.0 , dv .sum_of_squared_deviation )
1321- self .assertEqual ([0 , 20 , 20 , 20 , 20 , 20 ], dv .bucket_counts )
1322- self .assertEqual ([0 , 2 , 4 , 6 , 8 ],
1323- dv .bucket_options .explicit_buckets .bounds )
1334+ expected_distb = google .api .distribution_pb2 .Distribution (
1335+ count = 100 ,
1336+ mean = 4.5 ,
1337+ sum_of_squared_deviation = 825.0 ,
1338+ bucket_options = google .api .distribution_pb2 .Distribution .BucketOptions ( # noqa
1339+ explicit_buckets = google .api .distribution_pb2 .Distribution .BucketOptions .Explicit ( # noqa
1340+ bounds = [0 , 2 , 4 , 6 , 8 ])),
1341+ bucket_counts = [0 , 20 , 20 , 20 , 20 , 20 ]
1342+ )
1343+ self .assertEqual (dv , expected_distb )
13241344
13251345 def test_create_timeseries_multiple_tags (self ):
13261346 """Check that exporter creates timeseries for multiple tag values.
0 commit comments