Skip to content

Commit 4337d72

Browse files
authored
fix(detectors): Update span evidence section for MN+1 Detector (#97523)
this pr fixes an issue where for MN+1 detection we only showed 1 repeating span, when there could be a pattern of multiple spans. also removes the pattern span id section, which is not particularly useful
1 parent 1919d91 commit 4337d72

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/sentry/performance_issues/detectors/experiments/mn_plus_one_db_span_detector.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,12 @@ def _maybe_performance_problem(self) -> PerformanceProblem | None:
254254
"offender_span_ids": offender_span_ids,
255255
"transaction_name": self.event.get("transaction", ""),
256256
"parent_span": get_span_evidence_value(common_parent_span),
257-
"repeating_spans": get_span_evidence_value(db_span),
258-
"repeating_spans_compact": get_span_evidence_value(db_span, include_op=False),
257+
"repeating_spans": [get_span_evidence_value(span) for span in self.pattern],
258+
"repeating_spans_compact": [
259+
get_span_evidence_value(span, include_op=False) for span in self.pattern
260+
],
259261
"number_repeating_spans": str(len(offender_spans)),
260262
"pattern_size": len(self.pattern),
261-
"pattern_span_ids": [span["span_id"] for span in self.pattern],
262263
"num_pattern_repetitions": times_occurred,
263264
},
264265
evidence_display=[

tests/sentry/performance_issues/experiments/test_m_n_plus_one_db_detector.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,26 @@ def test_detects_prisma_client_m_n_plus_one(self) -> None:
178178
"op": "db",
179179
"parent_span": "default - render route (app) /products",
180180
"parent_span_ids": ["1bb013326ff579a4"],
181-
"repeating_spans": f'db - {first_db_span["description"]}',
182-
"repeating_spans_compact": first_db_span["description"],
181+
"repeating_spans": [
182+
"default - prisma:engine:serialize",
183+
"default - prisma:client:operation",
184+
"default - prisma:client:serialize",
185+
"http.client - POST https://accelerate.prisma-data.net/5.21.1/298c9a80d6e969bf5a29b56584687fa4e2ad329bc97098090a7b081d6222e653/graphql",
186+
"default - prisma:engine",
187+
"default - prisma:engine:connection",
188+
'db - SELECT "public"."reviews"."id", "public"."reviews"."productid", "public"."reviews"."rating", "public"."reviews"."customerid", "public"."reviews"."description", "public"."reviews"."created" FROM "public"."reviews" WHERE "public"."reviews"."id" = $1 OFFSET $2 /* traceparent=\'00-ee80032db36ee0e24a2f3c2f71fd5f11-aa3a15d285888d70-01\' */',
189+
],
190+
"repeating_spans_compact": [
191+
"prisma:engine:serialize",
192+
"prisma:client:operation",
193+
"prisma:client:serialize",
194+
"POST https://accelerate.prisma-data.net/5.21.1/298c9a80d6e969bf5a29b56584687fa4e2ad329bc97098090a7b081d6222e653/graphql",
195+
"prisma:engine",
196+
"prisma:engine:connection",
197+
'SELECT "public"."reviews"."id", "public"."reviews"."productid", "public"."reviews"."rating", "public"."reviews"."customerid", "public"."reviews"."description", "public"."reviews"."created" FROM "public"."reviews" WHERE "public"."reviews"."id" = $1 OFFSET $2 /* traceparent=\'00-ee80032db36ee0e24a2f3c2f71fd5f11-aa3a15d285888d70-01\' */',
198+
],
183199
"transaction_name": "GET /products",
184200
"pattern_size": num_spans_in_pattern,
185-
"pattern_span_ids": pattern_span_ids,
186201
"num_pattern_repetitions": num_pattern_repetitions,
187202
}
188203

0 commit comments

Comments
 (0)