Skip to content

Commit

Permalink
WIP some code
Browse files Browse the repository at this point in the history
  • Loading branch information
armenzg committed Sep 20, 2023
1 parent 981e80f commit fcdff1f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/sentry/snuba/metrics/extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,10 @@ def apdex_tag_spec(project: Project, argument: Optional[str]) -> List[TagSpec]:
]


def epm_tag_spec(_1: Project, _2: Optional[str]) -> List[TagSpec]:
pass


DERIVED_METRICS = {
"apdex": {
"tag_spec_func": apdex_tag_spec,
Expand Down
19 changes: 13 additions & 6 deletions src/sentry/snuba/metrics/fields/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
min_timestamp,
miserable_users,
on_demand_apdex_snql_factory,
on_demand_epm_snql_factory,
on_demand_failure_count_snql_factory,
on_demand_failure_rate_snql_factory,
rate_snql_factory,
Expand Down Expand Up @@ -1785,21 +1786,27 @@ def generate_where_statements(
),
# Custom operations used for on demand derived metrics.
DerivedOp(
op="on_demand_failure_count",
op="on_demand_apdex",
can_orderby=True,
snql_func=on_demand_failure_count_snql_factory,
snql_func=on_demand_apdex_snql_factory,
default_null_value=0,
),
DerivedOp(
op="on_demand_failure_rate",
op="on_demand_epm",
can_orderby=True,
snql_func=on_demand_failure_rate_snql_factory,
snql_func=on_demand_epm_snql_factory,
default_null_value=0,
),
DerivedOp(
op="on_demand_apdex",
op="on_demand_failure_count",
can_orderby=True,
snql_func=on_demand_apdex_snql_factory,
snql_func=on_demand_failure_count_snql_factory,
default_null_value=0,
),
DerivedOp(
op="on_demand_failure_rate",
can_orderby=True,
snql_func=on_demand_failure_rate_snql_factory,
default_null_value=0,
),
]
Expand Down
14 changes: 14 additions & 0 deletions src/sentry/snuba/metrics/fields/snql.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,20 @@ def max_timestamp(aggregate_filter, org_id, use_case_id, alias=None):
return timestamp_column_snql("maxIf", aggregate_filter, org_id, use_case_id, alias)


def on_demand_epm_snql_factory(
aggregate_filter: Function, org_id: int, use_case_id: UseCaseID, alias: str
) -> Function:
"""Divide the total count of events by the time period"""
# XXX: This whole thing is wrong. Just pushing the code so
return Function(
"divide",
# [
# XXX: Count if within a time range?
# ],
alias="epm_alias",
)


def on_demand_failure_rate_snql_factory(aggregate_filter, org_id, use_case_id, alias=None):
"""Divide the number of transactions that failed from the total."""
return Function(
Expand Down

0 comments on commit fcdff1f

Please sign in to comment.