feat(chalice): CH max query execution time
This commit is contained in:
parent
4f8e03d38e
commit
e7f061c439
4 changed files with 11 additions and 11 deletions
|
|
@ -1870,10 +1870,7 @@ def get_errors_per_type(project_id, startTimestamp=TimeUTC.now(delta_days=-1), e
|
|||
return __complete_missing_steps(rows=rows, start_time=startTimestamp,
|
||||
end_time=endTimestamp,
|
||||
density=density,
|
||||
neutral={"4xx": 0,
|
||||
"5xx": 0,
|
||||
"js": 0,
|
||||
"integrations": 0})
|
||||
neutral={"4xx": 0, "5xx": 0, "js": 0, "integrations": 0})
|
||||
|
||||
|
||||
def resource_type_vs_response_end(project_id, startTimestamp=TimeUTC.now(delta_days=-1),
|
||||
|
|
|
|||
|
|
@ -1636,7 +1636,6 @@ def get_domains_errors_4xx(project_id, startTimestamp=TimeUTC.now(delta_days=-1)
|
|||
|
||||
def get_domains_errors_5xx(project_id, startTimestamp=TimeUTC.now(delta_days=-1),
|
||||
endTimestamp=TimeUTC.now(), density=6, **args):
|
||||
raise Exception("not supported widget")
|
||||
step_size = __get_step_size(startTimestamp, endTimestamp, density)
|
||||
ch_sub_query = __get_basic_constraints(table_name="resources", round_start=True, data=args)
|
||||
ch_sub_query.append("intDiv(resources.status, 100) == %(status_code)s")
|
||||
|
|
@ -1648,7 +1647,7 @@ def get_domains_errors_5xx(project_id, startTimestamp=TimeUTC.now(delta_days=-1)
|
|||
groupArray([domain, toString(count)]) AS keys
|
||||
FROM (SELECT toUnixTimestamp(toStartOfInterval(resources.datetime, INTERVAL %(step_size)s second)) * 1000 AS timestamp,
|
||||
resources.url_host AS domain, COUNT(resources.session_id) AS count
|
||||
FROM resources {"INNER JOIN sessions_metadata USING(session_id)" if len(meta_condition) > 0 else ""}
|
||||
FROM o_resources AS resources {"INNER JOIN sessions_metadata USING(session_id)" if len(meta_condition) > 0 else ""}
|
||||
WHERE {" AND ".join(ch_sub_query)}
|
||||
GROUP BY timestamp,resources.url_host
|
||||
ORDER BY timestamp, count DESC
|
||||
|
|
@ -1659,6 +1658,7 @@ def get_domains_errors_5xx(project_id, startTimestamp=TimeUTC.now(delta_days=-1)
|
|||
"endTimestamp": endTimestamp,
|
||||
"step_size": step_size,
|
||||
"status_code": 5, **__get_constraint_values(args)}
|
||||
print(ch.execute(query=ch_query, params=params))
|
||||
rows = ch.execute(query=ch_query, params=params)
|
||||
rows = __nested_array_to_dict_array(rows)
|
||||
neutral = __get_domains_errors_neutral(rows)
|
||||
|
|
@ -1874,10 +1874,7 @@ def get_errors_per_type(project_id, startTimestamp=TimeUTC.now(delta_days=-1), e
|
|||
return __complete_missing_steps(rows=rows, start_time=startTimestamp,
|
||||
end_time=endTimestamp,
|
||||
density=density,
|
||||
neutral={"4xx": 0,
|
||||
"5xx": 0,
|
||||
"js": 0,
|
||||
"integrations": 0})
|
||||
neutral={"4xx": 0, "5xx": 0, "js": 0, "integrations": 0})
|
||||
|
||||
|
||||
def resource_type_vs_response_end(project_id, startTimestamp=TimeUTC.now(delta_days=-1),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
import clickhouse_driver
|
||||
from decouple import config
|
||||
|
||||
settings = None
|
||||
if config('pg_timeout', cast=int, default=-1) <= 0:
|
||||
settings = {"max_execution_time": config('pg_timeout', cast=int)}
|
||||
|
||||
|
||||
class ClickHouseClient:
|
||||
__client = None
|
||||
|
|
@ -8,7 +12,8 @@ class ClickHouseClient:
|
|||
def __init__(self):
|
||||
self.__client = clickhouse_driver.Client(host=config("ch_host"),
|
||||
database="default",
|
||||
port=config("ch_port", cast=int)) \
|
||||
port=config("ch_port", cast=int),
|
||||
settings=settings) \
|
||||
if self.__client is None else self.__client
|
||||
|
||||
def __enter__(self):
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ captcha_key=
|
|||
captcha_server=
|
||||
ch_host=
|
||||
ch_port=
|
||||
pg_timeout=30
|
||||
change_password_link=/reset-password?invitation=%s&&pass=%s
|
||||
email_basic=http://127.0.0.1:8000/async/basic/%s
|
||||
email_plans=http://127.0.0.1:8000/async/plans/%s
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue