Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
203 changes: 203 additions & 0 deletions src/sentry/search/eap/ourlogs/aggregates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
from sentry_protos.snuba.v1.trace_item_attribute_pb2 import Function

from sentry.search.eap import constants
from sentry.search.eap.columns import AggregateDefinition, AttributeArgumentDefinition


def count_processor(count_value: int | None) -> int:
if count_value is None:
return 0
else:
return count_value


LOG_AGGREGATE_DEFINITIONS = {
"count": AggregateDefinition(
internal_function=Function.FUNCTION_COUNT,
infer_search_type_from_arguments=False,
processor=count_processor,
default_search_type="integer",
arguments=[
AttributeArgumentDefinition(
attribute_types={
"string",
"number",
"integer",
},
default_arg="log.body",
)
],
),
"count_unique": AggregateDefinition(
internal_function=Function.FUNCTION_UNIQ,
default_search_type="integer",
infer_search_type_from_arguments=False,
processor=count_processor,
arguments=[
AttributeArgumentDefinition(
attribute_types={
"string",
"duration",
"number",
"integer",
"percentage",
"currency",
*constants.SIZE_TYPE,
*constants.DURATION_TYPE,
},
)
],
),
"sum": AggregateDefinition(
internal_function=Function.FUNCTION_SUM,
default_search_type="number",
arguments=[
AttributeArgumentDefinition(
attribute_types={
"duration",
"number",
"integer",
"currency",
*constants.SIZE_TYPE,
*constants.DURATION_TYPE,
},
)
],
),
"avg": AggregateDefinition(
internal_function=Function.FUNCTION_AVG,
default_search_type="number",
arguments=[
AttributeArgumentDefinition(
attribute_types={
"duration",
"number",
"integer",
"percentage",
"currency",
*constants.SIZE_TYPE,
*constants.DURATION_TYPE,
},
)
],
),
"p50": AggregateDefinition(
internal_function=Function.FUNCTION_P50,
default_search_type="number",
arguments=[
AttributeArgumentDefinition(
attribute_types={
"duration",
"number",
"integer",
"percentage",
"currency",
*constants.SIZE_TYPE,
*constants.DURATION_TYPE,
},
)
],
),
"p75": AggregateDefinition(
internal_function=Function.FUNCTION_P75,
default_search_type="number",
arguments=[
AttributeArgumentDefinition(
attribute_types={
"duration",
"number",
"integer",
"percentage",
"currency",
*constants.SIZE_TYPE,
*constants.DURATION_TYPE,
},
)
],
),
"p90": AggregateDefinition(
internal_function=Function.FUNCTION_P90,
default_search_type="number",
arguments=[
AttributeArgumentDefinition(
attribute_types={
"duration",
"number",
"integer",
"percentage",
"currency",
*constants.SIZE_TYPE,
*constants.DURATION_TYPE,
},
)
],
),
"p95": AggregateDefinition(
internal_function=Function.FUNCTION_P95,
default_search_type="number",
arguments=[
AttributeArgumentDefinition(
attribute_types={
"duration",
"number",
"integer",
"percentage",
"currency",
*constants.SIZE_TYPE,
*constants.DURATION_TYPE,
},
)
],
),
"p99": AggregateDefinition(
internal_function=Function.FUNCTION_P99,
default_search_type="number",
arguments=[
AttributeArgumentDefinition(
attribute_types={
"duration",
"number",
"integer",
"percentage",
"currency",
*constants.SIZE_TYPE,
*constants.DURATION_TYPE,
},
)
],
),
"max": AggregateDefinition(
internal_function=Function.FUNCTION_MAX,
default_search_type="number",
arguments=[
AttributeArgumentDefinition(
attribute_types={
"duration",
"number",
"integer",
"percentage",
"currency",
*constants.SIZE_TYPE,
*constants.DURATION_TYPE,
},
)
],
),
"min": AggregateDefinition(
internal_function=Function.FUNCTION_MIN,
default_search_type="number",
arguments=[
AttributeArgumentDefinition(
attribute_types={
"duration",
"number",
"integer",
"percentage",
"currency",
*constants.SIZE_TYPE,
*constants.DURATION_TYPE,
},
)
],
),
}
2 changes: 1 addition & 1 deletion src/sentry/search/eap/ourlogs/definitions.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from sentry_protos.snuba.v1.request_common_pb2 import TraceItemType

from sentry.search.eap.columns import ColumnDefinitions
from sentry.search.eap.ourlogs.aggregates import LOG_AGGREGATE_DEFINITIONS
from sentry.search.eap.ourlogs.attributes import (
OURLOG_ATTRIBUTE_DEFINITIONS,
OURLOG_VIRTUAL_CONTEXTS,
ourlog_column_to_custom_alias,
ourlog_custom_alias_to_column,
)
from sentry.search.eap.spans.aggregates import LOG_AGGREGATE_DEFINITIONS

OURLOG_DEFINITIONS = ColumnDefinitions(
aggregates=LOG_AGGREGATE_DEFINITIONS,
Expand Down
Loading
Loading