Browse Source

fix(metrics): Remap builtin span MRI (#66612)

For consistency sake, we should use self time everywhere and not
exclusive time even though they're the same thing.
Tony Xiao 1 year ago
parent
commit
f74199fcd8
2 changed files with 19 additions and 2 deletions
  1. 10 2
      static/app/utils/metrics/mri.spec.tsx
  2. 9 0
      static/app/utils/metrics/mri.tsx

+ 10 - 2
static/app/utils/metrics/mri.spec.tsx

@@ -24,7 +24,7 @@ describe('parseMRI', () => {
     }
   );
 
-  it.each(['transactions', 'custom'])(
+  it.each(['spans', 'transactions', 'custom'])(
     'should correctly parse a valid MRI string - use case %s',
     useCase => {
       const mri: MRI = `c:${useCase as UseCase}/xyz@test`;
@@ -38,7 +38,7 @@ describe('parseMRI', () => {
     }
   );
 
-  it.each(['sessions', 'spans'])(
+  it.each(['sessions'])(
     'should correctly parse a valid MRI string - use case %s',
     useCase => {
       const mri: MRI = `c:${useCase as UseCase}/xyz@test`;
@@ -79,6 +79,14 @@ describe('parseMRI', () => {
       expect(parseMRI(mri)).toEqual(parsedMRI);
     }
   );
+
+  it.each([
+    ['d:transactions/duration@millisecond', 'transaction.duration'],
+    ['d:spans/duration@millisecond', 'span.duration'],
+    ['d:spans/exclusive_time@millisecond', 'span.self_time'],
+  ])('should remap certain mri names', (mri, name) => {
+    expect(parseMRI(mri)?.name).toEqual(name);
+  });
 });
 
 describe('getUseCaseFromMRI', () => {

+ 9 - 0
static/app/utils/metrics/mri.tsx

@@ -48,6 +48,15 @@ function parseName(name: string, useCase: UseCase): string {
     }
     return name;
   }
+  if (useCase === 'spans') {
+    if (name === 'exclusive_time') {
+      return 'span.self_time';
+    }
+    if (name === 'duration') {
+      return 'span.duration';
+    }
+    return name;
+  }
   return `${useCase}.${name}`;
 }