Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: eap support formulas in timeseries endpoint #6854

Merged
merged 10 commits into from
Feb 11, 2025
Merged

Conversation

kylemumma
Copy link
Member

@kylemumma kylemumma commented Feb 4, 2025

this PR implements support for formulas in the timeseries endpoint. it closes this ticket https://github.com/getsentry/eap-planning/issues/27

major changes:

  • auto-convert TimeSeriesRequest.aggregations to TimeSeriesRequest.expressions
  • implement support for formula

tests:

  • I have a test for a non-extrapolated formula as well as an extrapolated one

design decisions

  • reliability doesnt work with formulas
  • formulas dont work w uptime checks or logs

Copy link

codecov bot commented Feb 5, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
2806 1 2805 11
View the top 1 failed test(s) by shortest run time
tests.web.rpc.v1.test_endpoint_time_series.test_endpoint_time_series.TestTimeSeriesApi::test_formula
Stack Traces | 0.982s run time
Traceback (most recent call last):
  File ".../v1/test_endpoint_time_series/test_endpoint_time_series.py", line 1015, in test_formula
    assert sorted(response.result_timeseries, key=lambda x: x.label) == [
AssertionError: assert [label: "sum + avg"\nbuckets {\n  seconds: 1738828800\n}\nbuckets {\n  seconds: 1738829100\n}\nbuckets {\n  seconds: 1738829400\n}\nbuckets {\n  seconds: 1738829700\n}\nbuckets {\n  seconds: 1738830000\n}\nbuckets {\n  seconds: 1738830300\n}\ndata_points {\n}\ndata_points {\n}\ndata_points {\n}\ndata_points {\n}\ndata_points {\n}\ndata_points {\n}\n] == [label: "sum + avg"\nbuckets {\n  seconds: 1738828800\n}\nbuckets {\n  seconds: 1738829100\n}\nbuckets {\n  seconds: 1738829400\n}\nbuckets {\n  seconds: 1738829700\n}\nbuckets {\n  seconds: 1738830000\n}\nbuckets {\n  seconds: 1738830300\n}\ndata_points {\n  data: 301\n  data_present: true\n  sample_count: 1\n}\ndata_points {\n  data: 301\n  data_present: true\n  sample_count: 1\n}\ndata_points {\n  data: 301\n  data_present: true\n  sample_count: 1\n}\ndata_points {\n  data: 301\n  data_present: true\n  sample_count: 1\n}\ndata_points {\n  data: 301\n  data_present: true\n  sample_count: 1\n}\ndata_points {\n  data: 301\n  data_present: true\n  sample_count: 1\n}\n]
  At index 0 diff: label: "sum + avg"\nbuckets {\n  seconds: 1738828800\n}\nbuckets {\n  seconds: 1738829100\n}\nbuckets {\n  seconds: 1738829400\n}\nbuckets {\n  seconds: 1738829700\n}\nbuckets {\n  seconds: 1738830000\n}\nbuckets {\n  seconds: 1738830300\n}\ndata_points {\n}\ndata_points {\n}\ndata_points {\n}\ndata_points {\n}\ndata_points {\n}\ndata_points {\n}\n != label: "sum + avg"\nbuckets {\n  seconds: 1738828800\n}\nbuckets {\n  seconds: 1738829100\n}\nbuckets {\n  seconds: 1738829400\n}\nbuckets {\n  seconds: 1738829700\n}\nbuckets {\n  seconds: 1738830000\n}\nbuckets {\n  seconds: 1738830300\n}\ndata_points {\n  data: 301\n  data_present: true\n  sample_count: 1\n}\ndata_points {\n  data: 301\n  data_present: true\n  sample_count: 1\n}\ndata_points {\n  data: 301\n  data_present: true\n  sample_count: 1\n}\ndata_points {\n  data: 301\n  data_present: true\n  sample_count: 1\n}\ndata_points {\n  data: 301\n  data_present: true\n  sample_count: 1\n}\ndata_points {\n  data: 301\n  data_present: true\n  sample_count: 1\n}\n
  Full diff:
    [
     label: "sum + avg"
    buckets {
      seconds: 1738828800
    }
    buckets {
      seconds: 1738829100
    }
    buckets {
      seconds: 1738829400
    }
    buckets {
      seconds: 1738829700
    }
    buckets {
      seconds: 1738830000
    }
    buckets {
      seconds: 1738830300
    }
    data_points {
  -   data: 301
  -   data_present: true
  -   sample_count: 1
    }
    data_points {
  -   data: 301
  -   data_present: true
  -   sample_count: 1
    }
    data_points {
  -   data: 301
  -   data_present: true
  -   sample_count: 1
    }
    data_points {
  -   data: 301
  -   data_present: true
  -   sample_count: 1
    }
    data_points {
  -   data: 301
  -   data_present: true
  -   sample_count: 1
    }
    data_points {
  -   data: 301
  -   data_present: true
  -   sample_count: 1
    }
    ,
    ]

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@kylemumma kylemumma changed the title Krm/formulasts feat: eap support formulas in timeseries endpoint Feb 7, 2025
@@ -107,5 +121,6 @@ def _execute(self, in_msg: TimeSeriesRequest) -> TimeSeriesResponse:
raise BadSnubaRPCRequestException(
"This endpoint requires meta.trace_item_type to be set (are you requesting spans? logs?)"
)
in_msg = _convert_aggregations_to_expressions(in_msg)
Copy link
Member Author

@kylemumma kylemumma Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in_msg.aggregations was deprecated to be replaced with in_msg.expressions
https://github.com/getsentry/sentry-protos/pull/105/files#diff-82c0471037e5c909123fcef5d5283670bf14ee7af2fe80b3fee909143e46f4adR26

this change makes it so any time a user passes aggregations it get converted to expressions before hitting the resolver

schema=get_entity(EntityKey("eap_spans")).get_data_model(),
sample=None,
)
def _get_reliability_context_columns(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

existing logic extracted into a new function

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all changes to this resolver is just to support the transition from TimeSeriesRequest.aggregations to TimeSeriesRequest.expressions

@kylemumma kylemumma marked this pull request as ready for review February 8, 2025 00:14
@kylemumma kylemumma requested review from a team as code owners February 8, 2025 00:14
@@ -154,7 +167,7 @@ def _convert_result_timeseries(
extrapolation_context = ExtrapolationContext.from_row(
timeseries.label, row_data
)
if extrapolation_context.is_data_present:
if row_data.get(timeseries.label, None) is not None:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidtsuk this line may interest you

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? What's the relevant or interesting change here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to rely on logic inside ExtrapolationContext to determine if we leave something out of the results.

We now are just relying on whether the data itself has the value None.

This change can happen now that davids pr to support null values properly is merged

def _get_reliability_context_columns(
expressions: Iterable[ProtoExpression],
) -> list[SelectedExpression]:
# this reliability logic ignores formulas, meaning formulas may not properly support reliability
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a final state of things or is this something that needs to be done later?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The final state until a product team complains about it. I should probably let them know about it.

@kylemumma kylemumma merged commit 6d8de6d into master Feb 11, 2025
32 checks passed
@kylemumma kylemumma deleted the krm/formulasts branch February 11, 2025 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants