def test_normal_rate_long_duration(self) -> None:
        # 1 event/s for 3m, 9m durations
        histograms = []
        for _ in range(6 * 3):
            hist = DurationsHistogram(bucket_size=10)
            hist.incr(duration=9 * 60, count=10)
            histograms.append(hist)
        durations = BucketedDurationsHistograms(timestamp=0, width=10, histograms=histograms)

        assert excessive_event_duration(project_id=1, durations=durations)
Example #2
0
    def test_low_rate_long_duration(self) -> None:
        # 1 event/m for 3m, 9m durations
        histograms = []
        durations = None
        for i in range(6 * 3):
            hist = DurationsHistogram(bucket_size=10)
            if i % 6 == 0:
                hist.incr(duration=9 * 60, count=1)
            histograms.append(hist)
            durations = BucketedDurationsHistograms(timestamp=0, width=10, histograms=histograms)

        assert durations is not None
        assert not excessive_event_duration(project_id=1, durations=durations)
Example #3
0
def excessive_event_duration(project_id: int, durations: BucketedDurationsHistograms) -> bool:
    """Whether the project's symbolication requests are taking too long to process."""
    total_histogram = DurationsHistogram(bucket_size=durations.histograms[0].bucket_size)
    for histogram in durations.histograms:
        total_histogram.incr_from(histogram)

    try:
        p75_duration = total_histogram.percentile(0.75)
    except ValueError:
        return False
    events_per_minute = total_histogram.total_count() / (durations.total_time() / 60)

    # Note, We had these tagged with tags={"project_id": project_id} during our initial
    # evaluation, however the cardinality for this is really too high to leave that on
    # forever in production.
    metrics.gauge("symbolication.lpq.computation.durations.p75", p75_duration)
    metrics.gauge("symbolication.lpq.computation.durations.events_per_minutes", events_per_minute)

    if events_per_minute > 15 and p75_duration > 6 * 60:
        return True
    else:
        return False
 def test_no_durations(self) -> None:
     durations = BucketedDurationsHistograms(
         timestamp=0, width=10, histograms=[DurationsHistogram()] * 5 * 6
     )
     assert not excessive_event_duration(project_id=1, durations=durations)