Skip to content

Commit

Permalink
adapt formula per review-comment
Browse files Browse the repository at this point in the history
  • Loading branch information
shellmayr committed Jan 15, 2025
1 parent 26d342c commit c7f09a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions snuba/web/rpc/v1/resolvers/R_eap_spans/common/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from snuba.query.dsl import CurriedFunctions as cf
from snuba.query.dsl import Functions as f
from snuba.query.dsl import column, literal
from snuba.query.dsl import column
from snuba.query.expressions import (
CurriedFunctionCall,
Expression,
Expand Down Expand Up @@ -548,7 +548,9 @@ def get_confidence_interval_column(
get_field_existence_expression(aggregation),
alias=f"{alias}_N",
),
f.minus(column(f"{alias}_N"), literal(1)),
f.sumIf(
sign_column, get_field_existence_expression(aggregation)
),
),
)
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,14 +474,14 @@ def test_sum_unreliable(self) -> None:

def test_avg_unreliable(self) -> None:
# store a test metric with a value of 1, every second for an hour
granularity_secs = 60
granularity_secs = 120
query_duration = 3600
store_timeseries(
BASE_TIME,
1,
3600,
# for each time interval we distribute the values from -55 to 64 to keep the avg close to 0
metrics=[DummyMetric("test_metric", get_value=lambda x: (x % 60) - 55)],
metrics=[DummyMetric("test_metric", get_value=lambda x: (x % 120) - 55)],
measurements=[
DummyMeasurement(
"client_sample_rate",
Expand Down Expand Up @@ -522,7 +522,7 @@ def test_avg_unreliable(self) -> None:
buckets=expected_buckets,
data_points=[
DataPoint(
data=-25.5, # (-55 + -54 + ... + -4) / 60 = -25.5
data=4.5, # (-55 + -54 + ... + 64) / 60 = 4.5
data_present=True,
reliability=Reliability.RELIABILITY_LOW,
avg_sampling_rate=0.0001,
Expand Down

0 comments on commit c7f09a9

Please sign in to comment.