Ejemplo n.º 1
0
def test_projects_one_histogram(store: RedisRealtimeMetricsStore,
                                redis_cluster: redis._RedisCluster) -> None:
    redis_cluster.hset("symbolicate_event_low_priority:duration:10:42:111:0",
                       0, 123)

    candidates = store.projects()
    assert list(candidates) == [42]
Ejemplo n.º 2
0
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())),
    ]
Ejemplo n.º 3
0
def test_get_durations_for_project_no_matching_keys(
        store: RedisRealtimeMetricsStore,
        redis_cluster: redis._RedisCluster) -> None:
    redis_cluster.hset("symbolicate_event_low_priority:histogram:10:53:111", 0,
                       123)

    counts = store.get_durations_for_project(42)
    assert list(counts) == []
Ejemplo n.º 4
0
def test_projects_multiple_metric_types(
        store: RedisRealtimeMetricsStore,
        redis_cluster: redis._RedisCluster) -> None:
    redis_cluster.set("symbolicate_event_low_priority:counter:10:42:111", 0)
    redis_cluster.hset("symbolicate_event_low_priority:duration:10:53:111:20",
                       20, 456)

    candidates = store.projects()
    assert list(candidates) == [42, 53]
Ejemplo n.º 5
0
def test_get_durations_for_project_multi_metric(
        store: RedisRealtimeMetricsStore,
        redis_cluster: redis._RedisCluster) -> None:
    redis_cluster.set("symbolicate_event_low_priority:counter:10:42:111", 0)
    redis_cluster.hset("symbolicate_event_low_priority:histogram:10:42:222", 0,
                       123)

    counts = store.get_durations_for_project(42)
    assert list(counts) == [
        DurationHistogram(timestamp=222, histogram=BucketedDurations({0: 123}))
    ]
Ejemplo n.º 6
0
def test_get_counts_for_project_multi_metric(
        store: RedisRealtimeMetricsStore,
        redis_cluster: redis._RedisCluster) -> None:
    redis_cluster.set("symbolicate_event_low_priority:counter:10:42:111", 0)
    redis_cluster.hset("symbolicate_event_low_priority:histogram:10:42:222:0",
                       0, 123)

    counts = store.get_counts_for_project(42)
    assert list(counts) == [
        BucketedCount(timestamp=111, count=0),
    ]
Ejemplo n.º 7
0
def test_get_durations_for_project_missing_project(
    store: RedisRealtimeMetricsStore,
    redis_cluster: redis._RedisCluster,
) -> None:
    redis_cluster.hset("symbolicate_event_low_priority:duration:10:53:111", 0,
                       123)

    durations = store.get_durations_for_project(project_id=42, timestamp=113)

    for hist in durations.histograms:
        assert hist.total_count() == 0
Ejemplo n.º 8
0
def test_get_durations_for_project_different_buckets(
        store: RedisRealtimeMetricsStore,
        redis_cluster: redis._RedisCluster) -> None:
    redis_cluster.hset("symbolicate_event_low_priority:histogram:10:42:111", 0,
                       123)
    redis_cluster.hset("symbolicate_event_low_priority:histogram:5:42:111", 20,
                       456)

    counts = store.get_durations_for_project(42)
    assert list(counts) == [
        DurationHistogram(timestamp=111, histogram=BucketedDurations({0: 123}))
    ]
Ejemplo n.º 9
0
def test_get_durations_for_project_empty(
        store: RedisRealtimeMetricsStore,
        redis_cluster: redis._RedisCluster) -> None:
    redis_cluster.hset(
        "symbolicate_event_low_priority:histogram:10:42:111",
        0,
        123,
    )
    redis_cluster.delete("symbolicate_event_low_priority:histogram:10:42:111")

    counts = store.get_durations_for_project(42)
    assert list(counts) == []
Ejemplo n.º 10
0
def test_get_durations_for_project_no_matching_keys(
    store: RedisRealtimeMetricsStore,
    redis_cluster: redis._RedisCluster,
) -> None:
    redis_cluster.hset("symbolicate_event_low_priority:duration:10:53:111", 0,
                       123)

    durations = store.get_durations_for_project(42, 113)

    assert list(durations) == [
        DurationHistogram(timestamp=110,
                          histogram=BucketedDurations(empty_histogram()))
    ]
Ejemplo n.º 11
0
def test_get_durations_for_project_different_bucket_sizes(
    store: RedisRealtimeMetricsStore,
    redis_cluster: redis._RedisCluster,
) -> None:
    redis_cluster.hset("symbolicate_event_low_priority:duration:10:42:110", 0,
                       123)
    redis_cluster.hset("symbolicate_event_low_priority:duration:5:42:110", 20,
                       456)

    durations = store.get_durations_for_project(42, 113)

    total = sum(h.total_count() for h in durations.histograms)

    assert total == 123
Ejemplo n.º 12
0
def test_get_durations_for_project_negative_count(
    store: RedisRealtimeMetricsStore,
    redis_cluster: redis._RedisCluster,
) -> None:
    redis_cluster.hset("symbolicate_event_low_priority:duration:10:42:110", 0,
                       -123)

    histogram = empty_histogram()
    histogram[0] = -123

    durations = store.get_durations_for_project(42, 113)

    assert list(durations) == [
        DurationHistogram(timestamp=110,
                          histogram=BucketedDurations(histogram))
    ]
Ejemplo n.º 13
0
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
Ejemplo n.º 14
0
def test_get_durations_for_project_multi_metric(
    store: RedisRealtimeMetricsStore,
    redis_cluster: redis._RedisCluster,
) -> None:
    redis_cluster.set("symbolicate_event_low_priority:counter:10:42:110", 0)
    redis_cluster.hset("symbolicate_event_low_priority:duration:10:42:220", 0,
                       123)

    histogram = empty_histogram()
    histogram[0] = 123

    durations = store.get_durations_for_project(42, 225)

    assert list(durations) == [
        DurationHistogram(timestamp=220,
                          histogram=BucketedDurations(histogram))
    ]
Ejemplo n.º 15
0
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),
    ]
Ejemplo n.º 16
0
def test_get_durations_for_project_multi_key_multi_durations(
    store: RedisRealtimeMetricsStore,
    redis_cluster: redis._RedisCluster,
) -> None:
    redis_cluster.hset("symbolicate_event_low_priority:duration:10:42:110", 0,
                       123)
    redis_cluster.hset("symbolicate_event_low_priority:duration:10:42:110", 10,
                       456)
    redis_cluster.hset("symbolicate_event_low_priority:duration:10:53:110", 0,
                       123)

    histogram = empty_histogram()
    histogram[0] = 123
    histogram[10] = 456

    durations = store.get_durations_for_project(42, 113)

    assert list(durations) == [
        DurationHistogram(timestamp=110,
                          histogram=BucketedDurations(histogram)),
    ]