profiling.d.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. declare namespace Profiling {
  2. type Release = import('sentry/types').Release;
  3. type SentrySampledProfileSample = {
  4. stack_id: number;
  5. thread_id: string;
  6. elapsed_since_start_ns: string;
  7. queue_address?: string;
  8. };
  9. type SentrySampledProfileStack = number[];
  10. type SentrySampledProfileFrame = {
  11. function?: string;
  12. instruction_addr?: string;
  13. lineno?: number;
  14. colno?: number;
  15. filename?: string;
  16. };
  17. type SentrySampledProfileDebugMetaImage = {
  18. debug_id: string;
  19. image_addr: string;
  20. code_file: string;
  21. type: string;
  22. image_size: number;
  23. image_vmaddr: string;
  24. };
  25. type SentrySampledProfileTransaction = {
  26. name: string;
  27. trace_id: string;
  28. id: string;
  29. active_thread_id: string;
  30. relative_start_ns: string;
  31. relative_end_ns: string;
  32. };
  33. type SentrySampledProfile = {
  34. event_id: string;
  35. version: string;
  36. os: {
  37. name: string;
  38. version: string;
  39. build_number: string;
  40. };
  41. device: {
  42. architecture: string;
  43. is_emulator?: boolean;
  44. locale?: string;
  45. manufacturer?: string;
  46. model?: string;
  47. };
  48. runtime?: {
  49. name: string;
  50. version: string;
  51. };
  52. timestamp: string;
  53. release: string;
  54. platform: string;
  55. environment?: string;
  56. debug_meta?: {
  57. images: SentryProfileDebugMetaImage[];
  58. };
  59. profile: {
  60. samples: SentrySampledProfileSample[];
  61. stacks: SentrySampledProfileStack[];
  62. frames: SentrySampledProfileFrame[];
  63. thread_metadata?: Record<string, {name?: string; priority?: number}>;
  64. queue_metadata?: Record<string, {label: string}>;
  65. };
  66. transactions?: SentrySampledProfileTransaction[];
  67. };
  68. ////////////////
  69. interface RawProfileBase {
  70. endValue: number;
  71. startValue: number;
  72. name: string;
  73. threadID: number;
  74. unit: string;
  75. spans?: Span[];
  76. threadID: number;
  77. }
  78. // Android traces follow this format
  79. interface EventedProfile extends RawProfileBase {
  80. events: ReadonlyArray<Event>;
  81. type: 'evented';
  82. }
  83. // iOS traces follow this format
  84. interface SampledProfile extends RawProfileBase {
  85. weights: number[];
  86. samples: number[][];
  87. type: 'sampled';
  88. }
  89. type Event = {at: number; frame: number; type: 'O' | 'C'};
  90. type Span = {
  91. duration_ms: number;
  92. name: string;
  93. queue_label: string;
  94. relative_start_ms: number;
  95. thread_id: number;
  96. children?: Span[];
  97. };
  98. type FrameInfo = {
  99. key: string | number;
  100. name: string;
  101. file?: string;
  102. path?: string;
  103. line?: number;
  104. column?: number;
  105. is_application?: boolean;
  106. image?: string;
  107. resource?: string;
  108. threadId?: number;
  109. inline?: boolean;
  110. // nodejs only
  111. columnNumber?: number;
  112. lineNumber?: number;
  113. scriptName?: string;
  114. scriptId?: number;
  115. };
  116. type ProfileInput =
  117. | Profiling.Schema
  118. | JSSelfProfiling.Trace
  119. | ChromeTrace.ProfileType
  120. | Profiling.SentrySampledProfile;
  121. type ImportedProfiles = {
  122. name: string;
  123. profileID: string;
  124. activeProfileIndex: number;
  125. profiles: ReadonlyArray<ProfileInput>;
  126. };
  127. type FrameRender = {
  128. elapsed_since_start_ns: number;
  129. value: number;
  130. };
  131. // This extends speedscope's schema - we are keeping this as is, but we are likely to diverge as we add more
  132. // sentry related features to the flamegraphs. This should happen after the MVP integration
  133. type Schema = {
  134. profileID: string;
  135. profiles: ReadonlyArray<
  136. Readonly<EventedProfile | SampledProfile | JSSelfProfiling.Trace>
  137. >;
  138. projectID: number;
  139. shared: {
  140. frames: ReadonlyArray<Omit<FrameInfo, 'key'>>;
  141. };
  142. measurements?: {
  143. screen_frame_rates?: {
  144. unit: string;
  145. values: {elapsed_since_start_ns: number; value: number}[];
  146. };
  147. frozen_frame_renders?: {
  148. unit: string;
  149. values: FrameRender[];
  150. };
  151. slow_frame_renders?: {
  152. unit: string;
  153. values: FrameRender[];
  154. };
  155. };
  156. activeProfileIndex?: number;
  157. metadata: {
  158. androidAPILevel: number;
  159. deviceClassification: string;
  160. deviceLocale: string;
  161. deviceManufacturer: string;
  162. deviceModel: string;
  163. deviceOSName: string;
  164. deviceOSVersion: string;
  165. durationNS: number;
  166. environment: string;
  167. organizationID: number;
  168. platform: string;
  169. profileID: string;
  170. projectID: number;
  171. received: string;
  172. traceID: string;
  173. transactionID: string;
  174. release: Release | null;
  175. transactionName: string;
  176. };
  177. };
  178. }