def test_get_durations_for_project_empty( store: RedisRealtimeMetricsStore, redis_cluster: redis._RedisCluster, ) -> None: redis_cluster.hset( "symbolicate_event_low_priority:duration:10:42:111", 0, 123, ) redis_cluster.delete("symbolicate_event_low_priority:duration:10:42:111") durations = store.get_durations_for_project(42, 113) assert list(durations) == [ DurationHistogram(timestamp=110, histogram=BucketedDurations(empty_histogram())) ] store._duration_time_window = 20 durations = store.get_durations_for_project(42, 113) assert list(durations) == [ DurationHistogram(timestamp=90, histogram=BucketedDurations(empty_histogram())), DurationHistogram(timestamp=100, histogram=BucketedDurations(empty_histogram())), DurationHistogram(timestamp=110, histogram=BucketedDurations(empty_histogram())), ]
def test_get_durations_for_projects_with_gap( store: RedisRealtimeMetricsStore, redis_cluster: redis._RedisCluster) -> None: store._duration_time_window = 40 redis_cluster.hset("symbolicate_event_low_priority:duration:10:42:110", 20, 3) redis_cluster.hset("symbolicate_event_low_priority:duration:10:42:150", 30, 17) durations = store.get_durations_for_project(42, 154) assert durations.histograms[-1].total_count() == 17 assert durations.histograms[-2].total_count() == 0 assert durations.histograms[-3].total_count() == 0 assert durations.histograms[-4].total_count() == 0 assert durations.histograms[-5].total_count() == 3
def test_get_durations_for_project_unset( store: RedisRealtimeMetricsStore) -> None: durations = store.get_durations_for_project(42, 113) assert list(durations) == [ DurationHistogram(timestamp=110, histogram=BucketedDurations(empty_histogram())) ] store._duration_time_window = 20 durations = store.get_durations_for_project(42, 113) assert list(durations) == [ DurationHistogram(timestamp=90, histogram=BucketedDurations(empty_histogram())), DurationHistogram(timestamp=100, histogram=BucketedDurations(empty_histogram())), DurationHistogram(timestamp=110, histogram=BucketedDurations(empty_histogram())), ]
def test_get_durations_for_projects_with_gap( store: RedisRealtimeMetricsStore, redis_cluster: redis._RedisCluster) -> None: store._duration_time_window = 40 redis_cluster.hset("symbolicate_event_low_priority:duration:10:42:110", 20, 3) redis_cluster.hset("symbolicate_event_low_priority:duration:10:42:150", 30, 17) hist1 = empty_histogram() hist1[20] = 3 hist2 = empty_histogram() hist2[30] = 17 durations = store.get_durations_for_project(42, 154) assert list(durations) == [ DurationHistogram(timestamp=110, histogram=hist1), DurationHistogram(timestamp=120, histogram=empty_histogram()), DurationHistogram(timestamp=130, histogram=empty_histogram()), DurationHistogram(timestamp=140, histogram=empty_histogram()), DurationHistogram(timestamp=150, histogram=hist2), ]