Skip to content

Commit 84aeec2

Browse files
Rachel ChenRachel Chen
Rachel Chen
authored and
Rachel Chen
committed
un-deprecated TYPE_DOUBLE
1 parent 0951d02 commit 84aeec2

File tree

3 files changed

+33
-14
lines changed

3 files changed

+33
-14
lines changed

requirements.txt

+4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ python-rapidjson==1.8
2929
redis==4.5.4
3030
sentry-arroyo==2.19.4
3131
sentry-kafka-schemas==0.1.129
32+
<<<<<<< HEAD
3233
sentry-protos==0.1.49
34+
=======
35+
sentry-protos==0.1.51
36+
>>>>>>> 25b52cb78 (un-deprecated TYPE_DOUBLE)
3337
sentry-redis-tools==0.3.0
3438
sentry-relay==0.9.4
3539
sentry-sdk==2.18.0

snuba/web/rpc/common/common.py

+28-13
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ def transform(exp: Expression) -> Expression:
8282
"sentry.segment_id": AttributeKey.Type.TYPE_STRING, # this is converted by a processor on the storage
8383
"sentry.segment_name": AttributeKey.Type.TYPE_STRING,
8484
"sentry.is_segment": AttributeKey.Type.TYPE_BOOLEAN,
85-
"sentry.duration_ms": AttributeKey.Type.TYPE_DOUBLE,
86-
"sentry.exclusive_time_ms": AttributeKey.Type.TYPE_DOUBLE,
85+
"sentry.duration_ms": AttributeKey.Type.TYPE_FLOAT,
86+
"sentry.exclusive_time_ms": AttributeKey.Type.TYPE_FLOAT,
8787
"sentry.retention_days": AttributeKey.Type.TYPE_INT,
8888
"sentry.name": AttributeKey.Type.TYPE_STRING,
89-
"sentry.sampling_weight": AttributeKey.Type.TYPE_DOUBLE,
90-
"sentry.sampling_factor": AttributeKey.Type.TYPE_DOUBLE,
89+
"sentry.sampling_weight": AttributeKey.Type.TYPE_FLOAT,
90+
"sentry.sampling_factor": AttributeKey.Type.TYPE_FLOAT,
9191
"sentry.timestamp": AttributeKey.Type.TYPE_UNSPECIFIED,
9292
"sentry.start_timestamp": AttributeKey.Type.TYPE_UNSPECIFIED,
9393
"sentry.end_timestamp": AttributeKey.Type.TYPE_UNSPECIFIED,
@@ -102,6 +102,7 @@ def transform(exp: Expression) -> Expression:
102102

103103
def attribute_key_to_expression(attr_key: AttributeKey) -> Expression:
104104
print("typeeeeee", attr_key)
105+
105106
def _build_label_mapping_key(attr_key: AttributeKey) -> str:
106107
return attr_key.name + "_" + AttributeKey.Type.Name(attr_key.type)
107108

@@ -125,10 +126,14 @@ def _build_label_mapping_key(attr_key: AttributeKey) -> str:
125126
)
126127
if attr_key.type == AttributeKey.Type.TYPE_INT:
127128
return f.CAST(column(attr_key.name[len("sentry.") :]), "Int64", alias=alias)
128-
if attr_key.type == AttributeKey.Type.TYPE_DOUBLE:
129-
print("timestamp_columnsssss", f.CAST(
130-
column(attr_key.name[len("sentry.") :]), "Float64", alias=alias
131-
))
129+
if (
130+
attr_key.type == AttributeKey.Type.TYPE_FLOAT
131+
or attr_key.type == AttributeKey.Type.TYPE_DOUBLE
132+
):
133+
print(
134+
"timestamp_columnsssss",
135+
f.CAST(column(attr_key.name[len("sentry.") :]), "Float64", alias=alias),
136+
)
132137
return f.CAST(
133138
column(attr_key.name[len("sentry.") :]), "Float64", alias=alias
134139
)
@@ -137,7 +142,11 @@ def _build_label_mapping_key(attr_key: AttributeKey) -> str:
137142
)
138143

139144
if attr_key.name in NORMALIZED_COLUMNS:
140-
if NORMALIZED_COLUMNS[attr_key.name] == attr_key.type:
145+
# the second if statement is saying if Sentry sends Snuba TYPE_FLOATS when Snuba already supports TYPE_DOUBLE. This is needed for backward compatibility
146+
if NORMALIZED_COLUMNS[attr_key.name] == attr_key.type or (
147+
attr_key.type == AttributeKey.Type.TYPE_DOUBLE
148+
and NORMALIZED_COLUMNS[attr_key.name] == AttributeKey.Type.TYPE_FLOAT
149+
):
141150
return column(attr_key.name[len("sentry.") :], alias=attr_key.name)
142151
raise BadSnubaRPCRequestException(
143152
f"Attribute {attr_key.name} must be requested as {NORMALIZED_COLUMNS[attr_key.name]}, got {attr_key.type}"
@@ -148,10 +157,16 @@ def _build_label_mapping_key(attr_key: AttributeKey) -> str:
148157
return SubscriptableReference(
149158
alias=alias, column=column("attr_str"), key=literal(attr_key.name)
150159
)
151-
if attr_key.type == AttributeKey.Type.TYPE_DOUBLE:
152-
print("subscriptableeeee", SubscriptableReference(
153-
alias=alias, column=column("attr_num"), key=literal(attr_key.name)
154-
))
160+
if (
161+
attr_key.type == AttributeKey.Type.TYPE_FLOAT
162+
or attr_key.type == AttributeKey.Type.TYPE_DOUBLE
163+
):
164+
print(
165+
"subscriptableeeee",
166+
SubscriptableReference(
167+
alias=alias, column=column("attr_num"), key=literal(attr_key.name)
168+
),
169+
)
155170
return SubscriptableReference(
156171
alias=alias, column=column("attr_num"), key=literal(attr_key.name)
157172
)

snuba/web/rpc/v1/resolvers/R_eap_spans/resolver_trace_item_table.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def _convert_results(
196196
elif column.key.type == AttributeKey.TYPE_FLOAT:
197197
converters[column.label] = lambda x: AttributeValue(val_float=float(x))
198198
elif column.key.type == AttributeKey.TYPE_DOUBLE:
199-
converters[column.label] = lambda x: AttributeValue(val_double=double(x))
199+
converters[column.label] = lambda x: AttributeValue(val_double=float(x))
200200
elif column.HasField("aggregation"):
201201
converters[column.label] = lambda x: AttributeValue(val_float=float(x))
202202
else:

0 commit comments

Comments
 (0)