Просмотр исходного кода

ref(perf): Mark long-task with sentry-tracing-init (#49481)

### Summary
This changes the op of the long-task that contains the
'sentry-tracing-init' mark so that it represents the app init bundle if
it's slow. This will allow us to differentiate it in span summary since
it's a specifically bad long-task that is known to block pageload.
Kev 1 год назад
Родитель
Сommit
49f73892cd
1 измененных файлов с 22 добавлено и 0 удалено
  1. 22 0
      static/app/utils/performanceForSentry/index.tsx

+ 22 - 0
static/app/utils/performanceForSentry/index.tsx

@@ -484,6 +484,7 @@ export const addExtraMeasurements = (transaction: TransactionEvent) => {
   try {
     addAssetMeasurements(transaction);
     addCustomMeasurements(transaction);
+    addSlowAppInit(transaction);
   } catch (_) {
     // Defensive catch since this code is auxiliary.
   }
@@ -518,6 +519,27 @@ export const setGroupedEntityTag = (
   setTag(`${tagName}.grouped`, `<=${groups.find(g => n <= g)}`);
 };
 
+export const addSlowAppInit = (transaction: TransactionEvent) => {
+  const appInitSpan = transaction.spans?.find(
+    s => s.description === 'sentry-tracing-init'
+  );
+  if (!appInitSpan || !transaction.spans) {
+    return;
+  }
+  const longTaskSpan = transaction.spans.find(
+    s =>
+      s.op === 'ui.long-task' &&
+      s.endTimestamp &&
+      appInitSpan.endTimestamp &&
+      s.endTimestamp > appInitSpan.endTimestamp &&
+      s.startTimestamp < appInitSpan.startTimestamp
+  );
+  if (!longTaskSpan) {
+    return;
+  }
+  longTaskSpan.op = `ui.long-task.app-init`;
+};
+
 /**
  * A temporary util function used for interaction transactions that will attach a tag to the transaction, indicating the element
  * that was interacted with. This will allow for querying for transactions by a specific element. This is a high cardinality tag, but