profiling.d.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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 ProfileTypes =
  117. | EventedProfile
  118. | SampledProfile
  119. | JSSelfProfiling.Trace
  120. | NodeProfile;
  121. type ImportedProfiles = {
  122. name: string;
  123. profileID: string;
  124. activeProfileIndex: number;
  125. profiles: ProfileTypes[];
  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<ProfileTypes>;
  136. projectID: number;
  137. shared: {
  138. frames: ReadonlyArray<Omit<FrameInfo, 'key'>>;
  139. };
  140. measurements?: {
  141. screen_frame_rates?: {
  142. unit: string;
  143. values: {elapsed_since_start_ns: number; value: number}[];
  144. };
  145. frozen_frame_renders?: {
  146. unit: string;
  147. values: FrameRender[];
  148. };
  149. slow_frame_renders?: {
  150. unit: string;
  151. values: FrameRender[];
  152. };
  153. };
  154. activeProfileIndex?: number;
  155. metadata: {
  156. androidAPILevel: number;
  157. deviceClassification: string;
  158. deviceLocale: string;
  159. deviceManufacturer: string;
  160. deviceModel: string;
  161. deviceOSName: string;
  162. deviceOSVersion: string;
  163. durationNS: number;
  164. environment: string;
  165. organizationID: number;
  166. platform: string;
  167. profileID: string;
  168. projectID: number;
  169. received: string;
  170. traceID: string;
  171. transactionID: string;
  172. release: Release | null;
  173. transactionName: string;
  174. };
  175. };
  176. }