profiling.d.ts 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. declare namespace Profiling {
  2. type Release = import('sentry/types').Release;
  3. type Image = import('sentry/types/debugImage').Image;
  4. type SymbolicatorStatus =
  5. import('sentry/components/events/interfaces/types').SymbolicatorStatus;
  6. type MeasurementValue = {
  7. elapsed_since_start_ns: number;
  8. value: number;
  9. };
  10. type ContinuousMeasurementValue = {
  11. timestamp: number;
  12. value: number;
  13. };
  14. type Measurement = {
  15. unit: string;
  16. values: MeasurementValue[];
  17. };
  18. type ContinuousMeasurement = {
  19. unit: string;
  20. values: ContinuousMeasurementValue[];
  21. };
  22. type Measurements = {
  23. cpu_usage?: Measurement;
  24. memory_footprint?: Measurement;
  25. frozen_frame_renders?: Measurement;
  26. screen_frame_rates?: Measurement;
  27. slow_frame_renders?: Measurement;
  28. [key: string]: Measurement;
  29. };
  30. type ContinuousMeasurements = {
  31. cpu_usage?: ContinuousMeasurement;
  32. memory_footprint?: ContinuousMeasurement;
  33. frozen_frame_renders?: ContinuousMeasurement;
  34. screen_frame_rates?: ContinuousMeasurement;
  35. slow_frame_renders?: ContinuousMeasurement;
  36. [key: string]: ContinuousMeasurement;
  37. };
  38. type SentrySampledProfileSample = {
  39. stack_id: number;
  40. thread_id: string;
  41. elapsed_since_start_ns: number;
  42. queue_address?: string;
  43. };
  44. type SentrySampledProfileChunkSample = {
  45. stack_id: number;
  46. thread_id: string;
  47. timestamp: number;
  48. };
  49. type SentrySampledProfileFrame = {
  50. in_app: boolean;
  51. // These differ slightly from the speedscope schema, but just
  52. // override them right now as we don't use the speedscope schema anymore
  53. abs_path?: string;
  54. col?: number;
  55. colno?: number;
  56. column?: number;
  57. filename?: string;
  58. function?: string;
  59. instruction_addr?: string;
  60. lineno?: number;
  61. module?: string;
  62. package?: string;
  63. platform?: string;
  64. status?: SymbolicatorStatus;
  65. sym_addr?: string;
  66. symbol?: string;
  67. };
  68. type SentrySampledProfileTransaction = {
  69. name: string;
  70. trace_id: string;
  71. id: string;
  72. active_thread_id: number;
  73. };
  74. type SentrySampledProfile = {
  75. event_id: string;
  76. project_id: number;
  77. version: string;
  78. os: {
  79. name: string;
  80. version: string;
  81. build_number: string;
  82. };
  83. device: {
  84. architecture: string;
  85. is_emulator?: boolean;
  86. locale?: string;
  87. manufacturer?: string;
  88. model?: string;
  89. };
  90. runtime?: {
  91. name: string;
  92. version: string;
  93. };
  94. received: string;
  95. timestamp: string;
  96. release: Release | null;
  97. platform: 'node' | 'javascript' | string;
  98. environment?: string;
  99. debug_meta?: {
  100. images: Image[];
  101. };
  102. profile: {
  103. samples: SentrySampledProfileSample[];
  104. stacks: SentrySampledProfileStack[];
  105. frames: SentrySampledProfileFrame[];
  106. thread_metadata?: Record<string, {name?: string; priority?: number}>;
  107. queue_metadata?: Record<string, {label: string}>;
  108. };
  109. transaction: SentrySampledProfileTransaction;
  110. measurements?: Measurements;
  111. };
  112. interface SentryContinousProfileChunk {
  113. chunk_id: string;
  114. environment: string;
  115. project_id: number;
  116. received: number;
  117. release: string;
  118. organization_id: number;
  119. retention_days: number;
  120. project_id: string;
  121. version: '2';
  122. debug_meta?: {
  123. images: Image[];
  124. };
  125. platform: string;
  126. measurements?: ContinuousMeasurements;
  127. profile: ContinuousProfile;
  128. }
  129. ////////////////
  130. interface RawProfileBase {
  131. endValue: number;
  132. startValue: number;
  133. name: string;
  134. threadID: number;
  135. unit: string;
  136. spans?: Span[];
  137. threadID: number;
  138. }
  139. // Android traces follow this format
  140. interface EventedProfile extends RawProfileBase {
  141. events: ReadonlyArray<Event>;
  142. type: 'evented';
  143. }
  144. // iOS traces follow this format
  145. interface SampledProfile extends RawProfileBase {
  146. weights: number[];
  147. samples: number[][];
  148. samples_profiles?: number[][];
  149. samples_examples?: number[][];
  150. sample_durations_ns?: number[];
  151. type: 'sampled';
  152. }
  153. type ContinuousProfile = {
  154. samples: SentrySampledProfileChunkSample[];
  155. frames: SentrySampledProfileFrame[];
  156. stacks: SentrySampledProfileStack[];
  157. thread_metadata?: Record<string, {name?: string; priority?: number}>;
  158. };
  159. type Event = {at: number; frame: number; type: 'O' | 'C'};
  160. type Span = {
  161. duration_ms: number;
  162. name: string;
  163. queue_label: string;
  164. relative_start_ms: number;
  165. thread_id: number;
  166. children?: Span[];
  167. };
  168. type FrameInfo = {
  169. col?: number;
  170. colno?: number;
  171. column?: number;
  172. file?: string;
  173. image?: string;
  174. inline?: boolean;
  175. instructionAddr?: string;
  176. is_application?: boolean;
  177. key: string | number;
  178. line?: number;
  179. // This is the import path for the module
  180. module?: string;
  181. name: string;
  182. // This is used for native platforms to indicate the name of the assembly, path of the dylib, etc
  183. package?: string;
  184. path?: string;
  185. platform?: string;
  186. resource?: string;
  187. symbol?: string;
  188. symbolAddr?: string;
  189. symbolicatorStatus?: SymbolicatorStatus;
  190. threadId?: number;
  191. // nodejs only
  192. columnNumber?: number;
  193. lineNumber?: number;
  194. scriptName?: string;
  195. scriptId?: number;
  196. };
  197. type ProfileInput =
  198. | Profiling.Schema
  199. | JSSelfProfiling.Trace
  200. | Profiling.SentrySampledProfile
  201. | Profiling.SentryContinousProfileChunk;
  202. type ImportedProfiles = {
  203. name: string;
  204. profileID: string;
  205. activeProfileIndex: number;
  206. profiles: ReadonlyArray<ProfileInput>;
  207. };
  208. type TransactionProfileReference = {
  209. project_id: number;
  210. profile_id: string;
  211. };
  212. type ContinuousProfileReference = {
  213. project_id: number;
  214. profiler_id: string;
  215. transaction_id: string | undefined;
  216. start: number;
  217. chunk_id: string;
  218. end: number;
  219. thread_id: string;
  220. };
  221. type ProfileReference =
  222. | TransactionProfileReference
  223. | ContinuousProfileReference
  224. | string;
  225. // We have extended the speedscope schema to include some additional metadata and measurements
  226. interface Schema {
  227. metadata: {
  228. androidAPILevel: number;
  229. deviceClassification: string;
  230. deviceLocale: string;
  231. deviceManufacturer: string;
  232. deviceModel: string;
  233. deviceOSName: string;
  234. deviceOSVersion: string;
  235. environment: string;
  236. organizationID: number;
  237. platform: string;
  238. profileID: string;
  239. projectID: number;
  240. received: string;
  241. release: Release | null;
  242. traceID: string;
  243. transactionID: string;
  244. transactionName: string;
  245. timestamp?: string;
  246. };
  247. profileID: string;
  248. projectID: number;
  249. measurements?: Measurements;
  250. profiles: ReadonlyArray<
  251. Readonly<
  252. Profiling.EventedProfile | Profiling.SampledProfile | JSSelfProfiling.Trace
  253. >
  254. >;
  255. shared: {
  256. frames: ReadonlyArray<Omit<Profiling.FrameInfo, 'key'>>;
  257. profile_ids?: ReadonlyArray<string>[];
  258. profiles?: ReadonlyArray<ProfileReference>;
  259. };
  260. activeProfileIndex?: number;
  261. }
  262. }