|
@@ -1160,6 +1160,58 @@ def create_mock_transactions(
|
|
|
},
|
|
|
)
|
|
|
|
|
|
+ def load_m_n_plus_one_issue():
|
|
|
+ trace_id = uuid4().hex
|
|
|
+ transaction_user = generate_user()
|
|
|
+
|
|
|
+ parent_span_id = uuid4().hex[:16]
|
|
|
+ duration = 200
|
|
|
+
|
|
|
+ def make_repeating_span(i):
|
|
|
+ nonlocal timestamp
|
|
|
+ nonlocal duration
|
|
|
+ start_timestamp = timestamp + timedelta(milliseconds=i * (duration + 1))
|
|
|
+ end_timestamp = start_timestamp + timedelta(milliseconds=duration)
|
|
|
+ op = "http" if i % 2 == 0 else "db"
|
|
|
+ description = "GET /" if i % 2 == 0 else "SELECT * FROM authors WHERE id = %s"
|
|
|
+ hash = "63f1e89e6a073441" if i % 2 == 0 else "a109ff3ef40f7fb3"
|
|
|
+ return {
|
|
|
+ "timestamp": end_timestamp.timestamp(),
|
|
|
+ "start_timestamp": start_timestamp.timestamp(),
|
|
|
+ "description": description,
|
|
|
+ "op": op,
|
|
|
+ "span_id": uuid4().hex[:16],
|
|
|
+ "parent_span_id": parent_span_id,
|
|
|
+ "hash": hash,
|
|
|
+ }
|
|
|
+
|
|
|
+ span_count = 10
|
|
|
+ repeating_spans = [make_repeating_span(i) for i in range(span_count)]
|
|
|
+
|
|
|
+ parent_span = {
|
|
|
+ "timestamp": (
|
|
|
+ timestamp + timedelta(milliseconds=span_count * (duration + 1))
|
|
|
+ ).timestamp(),
|
|
|
+ "start_timestamp": timestamp.timestamp(),
|
|
|
+ "description": "execute",
|
|
|
+ "op": "graphql.execute",
|
|
|
+ "parent_span_id": uuid4().hex[:16],
|
|
|
+ "span_id": parent_span_id,
|
|
|
+ "hash": "0f43fb6f6e01ca52",
|
|
|
+ }
|
|
|
+
|
|
|
+ create_sample_event(
|
|
|
+ project=backend_project,
|
|
|
+ platform="transaction",
|
|
|
+ transaction="/m_n_plus_one_db/backend/",
|
|
|
+ event_id=uuid4().hex,
|
|
|
+ user=transaction_user,
|
|
|
+ timestamp=timestamp + timedelta(milliseconds=span_count * (duration + 1) + 100),
|
|
|
+ start_timestamp=timestamp,
|
|
|
+ trace=trace_id,
|
|
|
+ spans=[parent_span] + repeating_spans,
|
|
|
+ )
|
|
|
+
|
|
|
def load_performance_issues():
|
|
|
print(f" > Loading performance issues data") # NOQA
|
|
|
print(f" > Loading n plus one issue") # NOQA
|
|
@@ -1170,6 +1222,8 @@ def create_mock_transactions(
|
|
|
load_uncompressed_asset_issue()
|
|
|
print(f" > Loading render blocking asset issue") # NOQA
|
|
|
load_render_blocking_asset_issue()
|
|
|
+ print(f" > Loading MN+1 issue") # NOQA
|
|
|
+ load_m_n_plus_one_issue()
|
|
|
|
|
|
load_performance_issues()
|
|
|
|