profiling.d.ts 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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 FunctionMetric = {
  198. avg: number;
  199. count: number;
  200. examples: Exclude<ProfileReference, string>[];
  201. fingerprint: number;
  202. in_app: boolean;
  203. name: string;
  204. p75: number;
  205. p95: number;
  206. p99: number;
  207. package: string;
  208. sum: number;
  209. };
  210. type ProfileInput =
  211. | Profiling.Schema
  212. | JSSelfProfiling.Trace
  213. | Profiling.SentrySampledProfile
  214. | Profiling.SentryContinousProfileChunk;
  215. type ImportedProfiles = {
  216. name: string;
  217. profileID: string;
  218. activeProfileIndex: number;
  219. profiles: ReadonlyArray<ProfileInput>;
  220. };
  221. type BaseTransactionProfileReference = {
  222. profile_id: string;
  223. };
  224. type BaseContinuousProfileReference = {
  225. end: number;
  226. profiler_id: string;
  227. start: number;
  228. thread_id: string;
  229. };
  230. type BaseProfileReference =
  231. | BaseTransactionProfileReference
  232. | BaseContinuousProfileReference;
  233. type TransactionProfileReference = BaseTransactionProfileReference & {
  234. project_id: number;
  235. };
  236. type ContinuousProfileReference = BaseContinuousProfileReference & {
  237. project_id: number;
  238. transaction_id: string | undefined;
  239. chunk_id: string;
  240. };
  241. type ProfileReference =
  242. | TransactionProfileReference
  243. | ContinuousProfileReference
  244. | string;
  245. // We have extended the speedscope schema to include some additional metadata and measurements
  246. interface Schema {
  247. metadata: {
  248. androidAPILevel: number;
  249. deviceClassification: string;
  250. deviceLocale: string;
  251. deviceManufacturer: string;
  252. deviceModel: string;
  253. deviceOSName: string;
  254. deviceOSVersion: string;
  255. environment: string;
  256. organizationID: number;
  257. platform: string;
  258. profileID: string;
  259. projectID: number;
  260. received: string;
  261. release: Release | null;
  262. traceID: string;
  263. transactionID: string;
  264. transactionName: string;
  265. timestamp?: string;
  266. };
  267. profileID: string;
  268. projectID: number;
  269. measurements?: Measurements;
  270. profiles: ReadonlyArray<
  271. Readonly<
  272. Profiling.EventedProfile | Profiling.SampledProfile | JSSelfProfiling.Trace
  273. >
  274. >;
  275. shared: {
  276. frames: ReadonlyArray<Omit<Profiling.FrameInfo, 'key'>>;
  277. profile_ids?: ReadonlyArray<string>[];
  278. profiles?: ReadonlyArray<ProfileReference>;
  279. };
  280. activeProfileIndex?: number;
  281. metrics?: FunctionMetric[];
  282. }
  283. }