Skip to content
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

feat(discover): Add snql support to the events-facets endpoint #29674

Merged
merged 7 commits into from
Nov 3, 2021

Conversation

wmak
Copy link
Member

@wmak wmak commented Oct 29, 2021

  • This also adds support for turbo + sample rate to the QueryBuilder
  • This updates the tests so feature modifying for snql is easier
  • Otherwise mostly copy paste from the existing code

- This also adds support for turbo + sample rate to the QueryBuilder
- This updates the tests so feature modifying for snql is easier
- Otherwise mostly copy paste from the existing code
+ f" tags_key:[{','.join(aggregate_tags)}]",
selected_columns=["count()", "tags_key", "tags_value"],
orderby=["tags_key", "-count()"],
limitby=["tags_key", TOP_VALUES_DEFAULT_LIMIT],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The limitby arg is of type Tuple(str, int), so you'll probably run into problems with Mypy when enabling it on this file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you fixed the wrong one here. It's QueryBuilder that's expecting the Tuple but you changed it for the raw_query call instead.

def get_facets(
query: str,
params: ParamsType,
referrer: str = None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this type hint not contradictory? It has type str but a default value of None.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 I'm shocked pyright doesn't complain about this.

key_name_builder = QueryBuilder(
Dataset.Discover,
params,
# Exclude tracing tags as they are noisy and generally not helpful.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment doesn't seem relevant anymore if we don't need to explicitly exclude tracing tags

if tag == "environment":
# Add here tags that you want to be individual
individual_tags.append(tag)
elif i >= len(top_tags) - 10:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can we declare this 10 as a constant somewhere?

+ f" tags_key:[{','.join(aggregate_tags)}]",
selected_columns=["count()", "tags_key", "tags_value"],
orderby=["tags_key", "-count()"],
limitby=["tags_key", TOP_VALUES_DEFAULT_LIMIT],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you fixed the wrong one here. It's QueryBuilder that's expecting the Tuple but you changed it for the raw_query call instead.

@@ -1099,7 +1228,7 @@ def get_facets(query, params, limit=10, referrer=None):
orderby="-count",
dataset=Dataset.Discover,
referrer=referrer,
sample=sample_rate,
sample_rate=sample_rate,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DId you mean to change this? This is the non snql code path.

@@ -1170,7 +1299,7 @@ def get_facets(query, params, limit=10, referrer=None):
sample=sample_rate,
# Ensures Snuba will not apply FINAL
turbo=sample_rate is not None,
limitby=[TOP_VALUES_DEFAULT_LIMIT, "tags_key"],
limitby=(TOP_VALUES_DEFAULT_LIMIT, "tags_key"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you changed the wrong one, see comment above.

if tag == "environment":
# Add here tags that you want to be individual
individual_tags.append(tag)
elif i >= len(top_tags) - (TOP_VALUES_DEFAULT_LIMIT + 1):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why this is using TOP_VALUES_DEFAULT_LIMIT + 1 other than the fact that it's 9? Would it be better to declare a separate constant with the value 10?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait I'm being dumb, yeah needs to be a separate constant 🤦

@github-actions github-actions bot locked and limited conversation to collaborators Nov 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants