profiling.d.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. declare namespace Profiling {
  2. interface RawProfileBase {
  3. endValue: number;
  4. startValue: number;
  5. name: string;
  6. threadID: number;
  7. unit: string;
  8. spans?: Span[];
  9. threadID: number;
  10. }
  11. // Android traces follow this format
  12. interface EventedProfile extends RawProfileBase {
  13. events: ReadonlyArray<Event>;
  14. type: 'evented';
  15. }
  16. // iOS traces follow this format
  17. interface SampledProfile extends RawProfileBase {
  18. weights: number[];
  19. samples: number[][];
  20. type: 'sampled';
  21. }
  22. interface NodeProfile extends Profiling.SampledProfile {
  23. frames: Profiling.FrameInfo[];
  24. }
  25. type Event = {at: number; frame: number; type: 'O' | 'C'};
  26. type Span = {
  27. duration_ms: number;
  28. name: string;
  29. queue_label: string;
  30. relative_start_ms: number;
  31. thread_id: number;
  32. children?: Span[];
  33. };
  34. type FrameInfo = {
  35. key: string | number;
  36. name: string;
  37. file?: string;
  38. line?: number;
  39. column?: number;
  40. is_application?: boolean;
  41. image?: string;
  42. resource?: string;
  43. threadId?: number;
  44. // nodejs only
  45. columnNumber?: number;
  46. lineNumber?: number;
  47. scriptName?: string;
  48. scriptId?: number;
  49. };
  50. type ProfileTypes =
  51. | EventedProfile
  52. | SampledProfile
  53. | JSSelfProfiling.Trace
  54. | NodeProfile;
  55. type ImportedProfiles = {
  56. name: string;
  57. profileID: string;
  58. activeProfileIndex: number;
  59. profiles: ProfileTypes[];
  60. };
  61. // This extends speedscope's schema - we are keeping this as is, but we are likely to diverge as we add more
  62. // sentry related features to the flamegraphs. This should happen after the MVP integration
  63. type Schema = {
  64. profileID: string;
  65. profiles: ReadonlyArray<ProfileTypes>;
  66. projectID: number;
  67. shared: {
  68. frames: ReadonlyArray<Omit<FrameInfo, 'key'>>;
  69. };
  70. activeProfileIndex?: number;
  71. metadata: {
  72. androidAPILevel: number;
  73. deviceClassification: string;
  74. deviceLocale: string;
  75. deviceManufacturer: string;
  76. deviceModel: string;
  77. deviceOSName: string;
  78. deviceOSVersion: string;
  79. durationNS: number;
  80. environment: string;
  81. organizationID: number;
  82. platform: string;
  83. profileID: string;
  84. projectID: number;
  85. received: string;
  86. traceID: string;
  87. transactionID: string;
  88. transactionName: string;
  89. version: string;
  90. };
  91. };
  92. }