def test_failure_rate_format_expressions() -> None: unprocessed = Query( {}, TableSource("events", ColumnSet([])), selected_columns=[ SelectedExpression(name=None, expression=Column(None, None, "column2")), SelectedExpression("perf", FunctionCall("perf", "failure_rate", ())), ], ) expected = Query( {}, TableSource("events", ColumnSet([])), selected_columns=[ SelectedExpression(name=None, expression=Column(None, None, "column2")), SelectedExpression( "perf", divide( FunctionCall( None, "countIf", (binary_condition( None, ConditionFunctions.NOT_IN, Column(None, None, "transaction_status"), FunctionCall( None, "tuple", ( Literal(alias=None, value=0), Literal(alias=None, value=1), Literal(alias=None, value=2), ), ), ), ), ), count(), "perf", ), ), ], ) failure_rate_processor(ColumnSet([])).process_query( unprocessed, HTTPRequestSettings()) assert (expected.get_selected_columns_from_ast() == unprocessed.get_selected_columns_from_ast()) ret = unprocessed.get_selected_columns_from_ast()[1].expression.accept( ClickhouseExpressionFormatter()) assert ret == ( "(divide(countIf(notIn(transaction_status, tuple(0, 1, 2))), count()) AS perf)" )
def test_failure_rate_format_expressions() -> None: unprocessed = Query( {}, TableSource("events", ColumnSet([])), selected_columns=[ SelectedExpression(name=None, expression=Column(None, None, "column2")), SelectedExpression("perf", FunctionCall("perf", "failure_rate", ())), ], ) expected = Query( {}, TableSource("events", ColumnSet([])), selected_columns=[ SelectedExpression(name=None, expression=Column(None, None, "column2")), SelectedExpression( "perf", divide( FunctionCall( None, "countIf", ( combine_and_conditions( [ binary_condition( None, ConditionFunctions.NEQ, Column(None, None, "transaction_status"), Literal(None, code), ) for code in [0, 1, 2] ] ), ), ), count(), "perf", ), ), ], ) failure_rate_processor(ColumnSet([])).process_query( unprocessed, HTTPRequestSettings() ) assert ( expected.get_selected_columns_from_ast() == unprocessed.get_selected_columns_from_ast() ) ret = unprocessed.get_selected_columns_from_ast()[1].expression.accept( ClickhouseExpressionFormatter() ) assert ret == ( "(divide(countIf(notEquals(transaction_status, 0) AND notEquals(transaction_status, 1) AND notEquals(transaction_status, 2)), count()) AS perf)" )
def get_query_processors(self) -> Sequence[QueryProcessor]: return [ TimeSeriesProcessor({"time": "finish_ts"}, ("start_ts", "finish_ts")), TagsExpanderProcessor(), BasicFunctionsProcessor(), apdex_processor(self.get_data_model()), failure_rate_processor(self.get_data_model()), ]
def get_query_processors(self) -> Sequence[QueryProcessor]: return [ TagsExpanderProcessor(), BasicFunctionsProcessor(), apdex_processor(self.get_data_model()), failure_rate_processor(self.get_data_model()), TimeSeriesColumnProcessor(self.__time_group_columns), ]
def get_query_processors(self) -> Sequence[QueryProcessor]: columnset = self.get_data_model() return [ TagsExpanderProcessor(), BasicFunctionsProcessor(), # Apdex and Impact seem very good candidates for # being defined by the Transaction entity when it will # exist, so it would run before Storage selection. apdex_processor(columnset), failure_rate_processor(columnset), HandledFunctionsProcessor("exception_stacks.mechanism_handled", columnset), TimeSeriesColumnProcessor({"time": "timestamp"}), ]
def get_query_processors(self) -> Sequence[QueryProcessor]: return [ TimeSeriesProcessor({"time": "finish_ts"}, ("start_ts", "finish_ts", "timestamp")), TagsExpanderProcessor(), BasicFunctionsProcessor(), apdex_processor(), failure_rate_processor(), ReferrerRateLimiterProcessor(), ProjectReferrerRateLimiter("project_id"), ProjectRateLimiterProcessor(project_column="project_id"), ResourceQuotaProcessor("project_id"), ]