Skip to content

Commit 69bff7d

Browse files
committed
query precedence
1 parent ee0d9c4 commit 69bff7d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/sentry/profiles/flamegraph.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,11 @@ def get_profile_candidates_from_profiles(self) -> ProfileCandidates:
452452
max_profiles = options.get("profiling.flamegraph.profile-set.size")
453453

454454
transaction_constraint = "is_transaction:true"
455-
query = f"{transaction_constraint} {self.query}" if self.query else transaction_constraint
455+
query = (
456+
f"({transaction_constraint}) and ({self.query})"
457+
if self.query
458+
else transaction_constraint
459+
)
456460
results = self.get_spans_based_candidates(query=query, limit=max_profiles)
457461

458462
transaction_profile_candidates: list[TransactionProfileCandidate] = [
@@ -616,7 +620,7 @@ def get_spans_based_candidates(self, query: str | None, limit: int) -> EAPRespon
616620
# add constraints in order to fetch only spans with profiles
617621
profiling_constraint = "(has:profile.id) or (has:profiler.id has:thread.id)"
618622
if query is not None and len(query) > 0:
619-
query = f"{query} and {profiling_constraint}"
623+
query = f"({query}) and ({profiling_constraint})"
620624
else:
621625
query = profiling_constraint
622626
return Spans.run_table_query(

0 commit comments

Comments
 (0)