-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V1 RPC of TraceItemAttributeValues #6563
base: master
Are you sure you want to change the base?
Conversation
45d0159
to
b972ec8
Compare
❌ 1 Tests Failed:
View the top 1 failed tests by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
b972ec8
to
9a74c4d
Compare
9a74c4d
to
c9cd599
Compare
@@ -108,6 +108,8 @@ def request_class(cls) -> Type[AttributeValuesRequestProto]: | |||
|
|||
def _execute(self, in_msg: AttributeValuesRequestProto) -> AttributeValuesResponse: | |||
snuba_request = _build_snuba_request(in_msg) | |||
print("snuba_request") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ill remove these
def truncate_request_meta_to_day(meta: RequestMeta) -> None: | ||
# some tables store timestamp as toStartOfDay(x) in UTC, so if you request 4PM - 8PM on a specific day, nada | ||
# this changes a request from 4PM - 8PM to a request from midnight today to 8PM tomorrow UTC. | ||
# it also changes 11PM - 1AM to midnight today to 1AM overmorrow | ||
start_timestamp = datetime.utcfromtimestamp(meta.start_timestamp.seconds) | ||
end_timestamp = datetime.utcfromtimestamp(meta.end_timestamp.seconds) | ||
start_timestamp = start_timestamp.replace( | ||
hour=0, minute=0, second=0, microsecond=0 | ||
) - timedelta(days=1) | ||
end_timestamp = end_timestamp.replace( | ||
hour=0, minute=0, second=0, microsecond=0 | ||
) + timedelta(days=1) | ||
|
||
meta.start_timestamp.seconds = int(start_timestamp.timestamp()) | ||
meta.end_timestamp.seconds = int(end_timestamp.timestamp()) | ||
|
||
|
||
def treeify_or_and_conditions(query: Query) -> None: | ||
""" | ||
look for expressions like or(a, b, c) and turn them into or(a, or(b, c)) | ||
and(a, b, c) and turn them into and(a, and(b, c)) | ||
|
||
even though clickhouse sql supports arbitrary amount of arguments there are other parts of the | ||
codebase which assume `or` and `and` have two arguments | ||
|
||
Adding this post-process step is easier than changing the rest of the query pipeline | ||
|
||
Note: does not apply to the conditions of a from_clause subquery (the nested one) | ||
this is bc transform_expressions is not implemented for composite queries | ||
""" | ||
|
||
def transform(exp: Expression) -> Expression: | ||
if not isinstance(exp, FunctionCall): | ||
return exp | ||
|
||
if exp.function_name == "and": | ||
return combine_and_conditions(exp.parameters) | ||
elif exp.function_name == "or": | ||
return combine_or_conditions(exp.parameters) | ||
else: | ||
return exp | ||
|
||
query.transform_expressions(transform) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these are in rpc/common.py
already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually I think this entire file is in snuba/web/rpc/common.py
# https://clickhouse.com/docs/en/engines/table-engines/mergetree-family/mergetree#functions-support | ||
f.multiSearchAny( | ||
column("attr_value"), | ||
literals_array(None, [literal(request.value_substring_match)]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if the value_substring_match
field is not set?
print("snuba_request") | ||
print(snuba_request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove these too
return TraceItemAttributeValuesResponse( | ||
values=[r["attr_value"] for r in res.result.get("data", [])] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is missing pagination support
Legal Boilerplate
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.