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

fix(spans): Return all queried span tags #72937

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/sentry/api/endpoints/organization_spans_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def get(self, request: Request, organization) -> Response:
# TODO: prepend the list of sentry defined fields here
(row["array_join(tags.key)"], TagKey(row["array_join(tags.key)"]))
for row in results["data"]
]
],
max_limit=max_span_tags,
)

return self.paginate(
Expand Down Expand Up @@ -116,20 +117,28 @@ def get(self, request: Request, organization, key: str) -> Response:

sentry_sdk.set_tag("query.tag_key", key)

max_span_tag_values = options.get("performance.spans-tags-values.max")

executor = SpanFieldValuesAutocompletionExecutor(
params=cast(ParamsType, params),
snuba_params=snuba_params,
key=key,
query=request.GET.get("query"),
max_span_tag_values=max_span_tag_values,
)
tag_values = executor.execute()

paginator = SequencePaginator([(tag_value.value, tag_value) for tag_value in tag_values])
paginator = SequencePaginator(
[(tag_value.value, tag_value) for tag_value in tag_values],
max_limit=max_span_tag_values,
)

return self.paginate(
request=request,
paginator=paginator,
on_results=lambda results: serialize(results, request.user),
default_per_page=max_span_tag_values,
max_per_page=max_span_tag_values,
)


Expand Down Expand Up @@ -162,12 +171,13 @@ def __init__(
snuba_params: SnubaParams,
key: str,
query: str | None,
max_span_tag_values: int,
):
self.params = params
self.snuba_params = snuba_params
self.key = key
self.query = query
self.max_span_tags = options.get("performance.spans-tags-values.max")
self.max_span_tag_values = max_span_tag_values

def execute(self) -> list[TagValue]:
if (
Expand Down Expand Up @@ -248,7 +258,7 @@ def get_autocomplete_query_base(self) -> QueryBuilder:
snuba_params=self.snuba_params,
selected_columns=[self.key, "count()", "min(timestamp)", "max(timestamp)"],
orderby="-count()",
limit=self.max_span_tags,
limit=self.max_span_tag_values,
sample_rate=options.get("performance.spans-tags-key.sample-rate"),
config=QueryBuilderConfig(
transform_alias_to_input_format=True,
Expand Down
Loading