Skip to content

Commit 71c78dc

Browse files
committed
EAP storage type vs search type in aliasign
1 parent 5c70df7 commit 71c78dc

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/sentry/data_export/utils.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from sentry.data_export.base import ExportError
1313
from sentry.search.eap.types import SupportedTraceItemType
1414
from sentry.search.eap.utils import (
15+
INTERNAL_TO_PUBLIC_ALIAS_MAPPINGS,
1516
can_expose_attribute,
1617
translate_internal_to_public_alias,
1718
)
@@ -21,7 +22,7 @@
2122
from sentry.utils.sdk import capture_exception
2223

2324

24-
def eap_scalar_type_from_anyvalue_which(
25+
def eap_storage_scalar_type_from_protobuf(
2526
which: str | None,
2627
) -> Literal["string", "number", "boolean"] | None:
2728
if which is None:
@@ -122,11 +123,23 @@ def _merge_trace_export_cell(out: dict[str, Any], new_key: str, value: Any) -> N
122123

123124
def _export_column_name_for_scalar_trace_attribute(
124125
internal_key: str,
125-
eap_type: Literal["string", "number", "boolean"],
126+
eap_storage_type: Literal["string", "number", "boolean"],
126127
item_type: SupportedTraceItemType,
127128
) -> str:
129+
# eap_storage_type is not same as search_type used in translate_internal_to_public_alias
130+
per_type = INTERNAL_TO_PUBLIC_ALIAS_MAPPINGS.get(item_type)
131+
if per_type is not None:
132+
for typ in ("string", "number", "boolean"):
133+
if internal_key in per_type.get(typ, {}):
134+
public_alias, public_name, _ = translate_internal_to_public_alias(
135+
internal_key, typ, item_type
136+
)
137+
if public_alias is not None and public_name is not None:
138+
return public_name
139+
break
140+
# column_to_alias still needs a type; use storage type.
128141
public_alias, public_name, _ = translate_internal_to_public_alias(
129-
internal_key, eap_type, item_type
142+
internal_key, eap_storage_type, item_type
130143
)
131144
if public_alias is not None and public_name is not None:
132145
return public_name
@@ -149,12 +162,12 @@ def trace_item_to_row(
149162
continue
150163
which = av.WhichOneof("value")
151164
value = None if which is None else anyvalue_to_python(av)
152-
eap_type = eap_scalar_type_from_anyvalue_which(which)
153-
if eap_type is None:
165+
eap_storage_type = eap_storage_scalar_type_from_protobuf(which)
166+
if eap_storage_type is None:
154167
new_key = internal_key
155168
else:
156169
new_key = _export_column_name_for_scalar_trace_attribute(
157-
internal_key, eap_type, item_type
170+
internal_key, eap_storage_type, item_type
158171
)
159172
_merge_trace_export_cell(row, new_key, value)
160173

0 commit comments

Comments
 (0)