Skip to content

Commit 70438a5

Browse files
authored
feat(logs): Hide meta attributes for trace items (#93217)
### Summary We have to add meta information for attributes (eg. appending pii scrubbing reasons in Relay when a log gets filtered), and since attributes is the only storage of data for trace items, attributes is where we'll have to store it. This was stored in `_meta` on events previously, hence the name. These meta fields should never appear in autocompletes, schema hints etcs. (not exposed) but should still be returned when requesting trace items in trace item details. We may in the future also consider also returning them in the events endpoint but that will double all attribute requests on /events to show filter reasons in a table. Refs LOGS-81
1 parent b0bc701 commit 70438a5

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/sentry/search/eap/ourlogs/attributes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@
114114
if definition.private
115115
}
116116

117+
# For dynamic internal attributes (eg. meta information for attributes) we match by the beginning of the key.
118+
LOGS_PRIVATE_ATTRIBUTE_PREFIXES: set[str] = {"sentry._meta"}
119+
117120
LOGS_REPLACEMENT_ATTRIBUTES: set[str] = {
118121
definition.replacement
119122
for definition in OURLOG_ATTRIBUTE_DEFINITIONS.values()

src/sentry/search/eap/spans/attributes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,9 @@ def is_starred_segment_context_constructor(params: SnubaParams) -> VirtualColumn
588588
if definition.private
589589
}
590590

591+
# For dynamic internal attributes (eg. meta information for attributes) we match by the beginning of the key.
592+
SPANS_PRIVATE_ATTRIBUTE_PREFIXES: set[str] = {"sentry._meta"}
593+
591594
SPANS_REPLACEMENT_ATTRIBUTES: set[str] = {
592595
definition.replacement
593596
for definition in SPAN_ATTRIBUTE_DEFINITIONS.values()

src/sentry/search/eap/utils.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
from sentry.search.eap.ourlogs.attributes import (
1717
LOGS_INTERNAL_TO_PUBLIC_ALIAS_MAPPINGS,
1818
LOGS_INTERNAL_TO_SECONDARY_ALIASES_MAPPING,
19+
LOGS_PRIVATE_ATTRIBUTE_PREFIXES,
1920
LOGS_PRIVATE_ATTRIBUTES,
2021
LOGS_REPLACEMENT_ATTRIBUTES,
2122
LOGS_REPLACEMENT_MAP,
2223
)
2324
from sentry.search.eap.spans.attributes import (
2425
SPAN_INTERNAL_TO_SECONDARY_ALIASES_MAPPING,
2526
SPANS_INTERNAL_TO_PUBLIC_ALIAS_MAPPINGS,
27+
SPANS_PRIVATE_ATTRIBUTE_PREFIXES,
2628
SPANS_PRIVATE_ATTRIBUTES,
2729
SPANS_REPLACEMENT_ATTRIBUTES,
2830
SPANS_REPLACEMENT_MAP,
@@ -128,6 +130,11 @@ def validate_sampling(sampling_mode: SAMPLING_MODES | None) -> DownsampledStorag
128130
SupportedTraceItemType.LOGS: LOGS_PRIVATE_ATTRIBUTES,
129131
}
130132

133+
PRIVATE_ATTRIBUTE_PREFIXES: dict[SupportedTraceItemType, set[str]] = {
134+
SupportedTraceItemType.SPANS: SPANS_PRIVATE_ATTRIBUTE_PREFIXES,
135+
SupportedTraceItemType.LOGS: LOGS_PRIVATE_ATTRIBUTE_PREFIXES,
136+
}
137+
131138
SENTRY_CONVENTIONS_REPLACEMENT_ATTRIBUTES: dict[SupportedTraceItemType, set[str]] = {
132139
SupportedTraceItemType.SPANS: SPANS_REPLACEMENT_ATTRIBUTES,
133140
SupportedTraceItemType.LOGS: LOGS_REPLACEMENT_ATTRIBUTES,
@@ -162,7 +169,10 @@ def get_secondary_aliases(
162169

163170

164171
def can_expose_attribute(attribute: str, item_type: SupportedTraceItemType) -> bool:
165-
return attribute not in PRIVATE_ATTRIBUTES.get(item_type, {})
172+
return attribute not in PRIVATE_ATTRIBUTES.get(item_type, {}) and not any(
173+
attribute.lower().startswith(prefix.lower())
174+
for prefix in PRIVATE_ATTRIBUTE_PREFIXES.get(item_type, {})
175+
)
166176

167177

168178
def handle_downsample_meta(meta: DownsampledStorageMeta) -> bool:

0 commit comments

Comments
 (0)