Skip to content

Commit 17c06e9

Browse files
authored
ref(ourlogs): Move log aggregate definitions to own file (#100922)
Not sure why these definitions were in the spans folder. Moving it out to the logs folder.
1 parent d0390a8 commit 17c06e9

File tree

3 files changed

+204
-192
lines changed

3 files changed

+204
-192
lines changed
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
from sentry_protos.snuba.v1.trace_item_attribute_pb2 import Function
2+
3+
from sentry.search.eap import constants
4+
from sentry.search.eap.columns import AggregateDefinition, AttributeArgumentDefinition
5+
6+
7+
def count_processor(count_value: int | None) -> int:
8+
if count_value is None:
9+
return 0
10+
else:
11+
return count_value
12+
13+
14+
LOG_AGGREGATE_DEFINITIONS = {
15+
"count": AggregateDefinition(
16+
internal_function=Function.FUNCTION_COUNT,
17+
infer_search_type_from_arguments=False,
18+
processor=count_processor,
19+
default_search_type="integer",
20+
arguments=[
21+
AttributeArgumentDefinition(
22+
attribute_types={
23+
"string",
24+
"number",
25+
"integer",
26+
},
27+
default_arg="log.body",
28+
)
29+
],
30+
),
31+
"count_unique": AggregateDefinition(
32+
internal_function=Function.FUNCTION_UNIQ,
33+
default_search_type="integer",
34+
infer_search_type_from_arguments=False,
35+
processor=count_processor,
36+
arguments=[
37+
AttributeArgumentDefinition(
38+
attribute_types={
39+
"string",
40+
"duration",
41+
"number",
42+
"integer",
43+
"percentage",
44+
"currency",
45+
*constants.SIZE_TYPE,
46+
*constants.DURATION_TYPE,
47+
},
48+
)
49+
],
50+
),
51+
"sum": AggregateDefinition(
52+
internal_function=Function.FUNCTION_SUM,
53+
default_search_type="number",
54+
arguments=[
55+
AttributeArgumentDefinition(
56+
attribute_types={
57+
"duration",
58+
"number",
59+
"integer",
60+
"currency",
61+
*constants.SIZE_TYPE,
62+
*constants.DURATION_TYPE,
63+
},
64+
)
65+
],
66+
),
67+
"avg": AggregateDefinition(
68+
internal_function=Function.FUNCTION_AVG,
69+
default_search_type="number",
70+
arguments=[
71+
AttributeArgumentDefinition(
72+
attribute_types={
73+
"duration",
74+
"number",
75+
"integer",
76+
"percentage",
77+
"currency",
78+
*constants.SIZE_TYPE,
79+
*constants.DURATION_TYPE,
80+
},
81+
)
82+
],
83+
),
84+
"p50": AggregateDefinition(
85+
internal_function=Function.FUNCTION_P50,
86+
default_search_type="number",
87+
arguments=[
88+
AttributeArgumentDefinition(
89+
attribute_types={
90+
"duration",
91+
"number",
92+
"integer",
93+
"percentage",
94+
"currency",
95+
*constants.SIZE_TYPE,
96+
*constants.DURATION_TYPE,
97+
},
98+
)
99+
],
100+
),
101+
"p75": AggregateDefinition(
102+
internal_function=Function.FUNCTION_P75,
103+
default_search_type="number",
104+
arguments=[
105+
AttributeArgumentDefinition(
106+
attribute_types={
107+
"duration",
108+
"number",
109+
"integer",
110+
"percentage",
111+
"currency",
112+
*constants.SIZE_TYPE,
113+
*constants.DURATION_TYPE,
114+
},
115+
)
116+
],
117+
),
118+
"p90": AggregateDefinition(
119+
internal_function=Function.FUNCTION_P90,
120+
default_search_type="number",
121+
arguments=[
122+
AttributeArgumentDefinition(
123+
attribute_types={
124+
"duration",
125+
"number",
126+
"integer",
127+
"percentage",
128+
"currency",
129+
*constants.SIZE_TYPE,
130+
*constants.DURATION_TYPE,
131+
},
132+
)
133+
],
134+
),
135+
"p95": AggregateDefinition(
136+
internal_function=Function.FUNCTION_P95,
137+
default_search_type="number",
138+
arguments=[
139+
AttributeArgumentDefinition(
140+
attribute_types={
141+
"duration",
142+
"number",
143+
"integer",
144+
"percentage",
145+
"currency",
146+
*constants.SIZE_TYPE,
147+
*constants.DURATION_TYPE,
148+
},
149+
)
150+
],
151+
),
152+
"p99": AggregateDefinition(
153+
internal_function=Function.FUNCTION_P99,
154+
default_search_type="number",
155+
arguments=[
156+
AttributeArgumentDefinition(
157+
attribute_types={
158+
"duration",
159+
"number",
160+
"integer",
161+
"percentage",
162+
"currency",
163+
*constants.SIZE_TYPE,
164+
*constants.DURATION_TYPE,
165+
},
166+
)
167+
],
168+
),
169+
"max": AggregateDefinition(
170+
internal_function=Function.FUNCTION_MAX,
171+
default_search_type="number",
172+
arguments=[
173+
AttributeArgumentDefinition(
174+
attribute_types={
175+
"duration",
176+
"number",
177+
"integer",
178+
"percentage",
179+
"currency",
180+
*constants.SIZE_TYPE,
181+
*constants.DURATION_TYPE,
182+
},
183+
)
184+
],
185+
),
186+
"min": AggregateDefinition(
187+
internal_function=Function.FUNCTION_MIN,
188+
default_search_type="number",
189+
arguments=[
190+
AttributeArgumentDefinition(
191+
attribute_types={
192+
"duration",
193+
"number",
194+
"integer",
195+
"percentage",
196+
"currency",
197+
*constants.SIZE_TYPE,
198+
*constants.DURATION_TYPE,
199+
},
200+
)
201+
],
202+
),
203+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from sentry_protos.snuba.v1.request_common_pb2 import TraceItemType
22

33
from sentry.search.eap.columns import ColumnDefinitions
4+
from sentry.search.eap.ourlogs.aggregates import LOG_AGGREGATE_DEFINITIONS
45
from sentry.search.eap.ourlogs.attributes import (
56
OURLOG_ATTRIBUTE_DEFINITIONS,
67
OURLOG_VIRTUAL_CONTEXTS,
78
ourlog_column_to_custom_alias,
89
ourlog_custom_alias_to_column,
910
)
10-
from sentry.search.eap.spans.aggregates import LOG_AGGREGATE_DEFINITIONS
1111

1212
OURLOG_DEFINITIONS = ColumnDefinitions(
1313
aggregates=LOG_AGGREGATE_DEFINITIONS,

0 commit comments

Comments
 (0)