From f945f96b52edda0cc2bc342119aa4d609f88eaa9 Mon Sep 17 00:00:00 2001 From: xurui-c <159840875+xurui-c@users.noreply.github.com> Date: Fri, 17 Jan 2025 12:43:29 -0800 Subject: [PATCH] fix(eap-api): Sentry distinguishes floats and doubles (#83629) Follow up on https://github.com/getsentry/sentry/pull/83566 Even when Snuba sends back doubles, Sentry uses `TYPE_MAP` to resolve them into floats. This is unintended behavior. This PR makes it so that Sentry looks at Snuba's response to determine if the values are doubles, instead of looking at `TYPE_MAP` to determine that. Co-authored-by: Rachel Chen --- src/sentry/snuba/spans_rpc.py | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/src/sentry/snuba/spans_rpc.py b/src/sentry/snuba/spans_rpc.py index 9523cb81fdd5ac..3b11a485a88026 100644 --- a/src/sentry/snuba/spans_rpc.py +++ b/src/sentry/snuba/spans_rpc.py @@ -12,15 +12,7 @@ from sentry.api.event_search import SearchFilter, SearchKey, SearchValue from sentry.exceptions import InvalidSearchQuery from sentry.search.eap.columns import ResolvedColumn, ResolvedFunction -from sentry.search.eap.constants import ( - BOOLEAN, - DOUBLE, - FLOAT, - INT, - MAX_ROLLUP_POINTS, - STRING, - VALID_GRANULARITIES, -) +from sentry.search.eap.constants import MAX_ROLLUP_POINTS, VALID_GRANULARITIES from sentry.search.eap.spans import SearchResolver from sentry.search.eap.types import CONFIDENCES, ConfidenceData, EAPResponse, SearchResolverConfig from sentry.search.events.fields import get_function_alias, is_function @@ -138,16 +130,7 @@ def run_table_query( for index, result in enumerate(column_value.results): result_value: str | int | float - if resolved_column.proto_type == STRING: - result_value = result.val_str - elif resolved_column.proto_type == INT: - result_value = result.val_int - elif resolved_column.proto_type == FLOAT: - result_value = result.val_float - elif resolved_column.proto_type == DOUBLE: - result_value = result.val_double - elif resolved_column.proto_type == BOOLEAN: - result_value = result.val_bool + result_value = getattr(result, str(result.WhichOneof("value"))) result_value = process_value(result_value) final_data[index][attribute] = resolved_column.process_column(result_value) if has_reliability: