profiling.d.ts 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. declare namespace Profiling {
  2. type Release = import('sentry/types').Release;
  3. type SpeedscopeSchema = import('sentry/utils/profiling/speedscope').SpeedscopeSchema;
  4. type Image = import('sentry/types/debugImage').Image;
  5. type SymbolicatorStatus =
  6. import('sentry/components/events/interfaces/types').SymbolicatorStatus;
  7. type MeasurementValue = {
  8. elapsed_since_start_ns: number;
  9. value: number;
  10. };
  11. type ContinuousMeasurementValue = {
  12. timestamp: number;
  13. value: number;
  14. };
  15. type Measurement = {
  16. unit: string;
  17. values: MeasurementValue[];
  18. };
  19. type ContinuousMeasurement = {
  20. unit: string;
  21. values: ContinuousMeasurementValue[];
  22. };
  23. type Measurements = {
  24. cpu_usage?: Measurement;
  25. memory_footprint?: Measurement;
  26. frozen_frame_renders?: Measurement;
  27. screen_frame_rates?: Measurement;
  28. slow_frame_renders?: Measurement;
  29. [key: string]: Measurement;
  30. };
  31. type ContinuousMeasurements = {
  32. cpu_usage?: ContinuousMeasurement;
  33. memory_footprint?: ContinuousMeasurement;
  34. frozen_frame_renders?: ContinuousMeasurement;
  35. screen_frame_rates?: ContinuousMeasurement;
  36. slow_frame_renders?: ContinuousMeasurement;
  37. [key: string]: ContinuousMeasurement;
  38. };
  39. type SentrySampledProfileSample = {
  40. stack_id: number;
  41. thread_id: string;
  42. elapsed_since_start_ns: number;
  43. queue_address?: string;
  44. };
  45. type SentrySampledProfileChunkSample = {
  46. stack_id: number;
  47. thread_id: string;
  48. timestamp: number;
  49. };
  50. type SentrySampledProfileFrame = {
  51. in_app: boolean;
  52. // These differ slightly from the speedscope schema, but just
  53. // override them right now as we don't use the speedscope schema anymore
  54. abs_path?: string;
  55. col?: number;
  56. colno?: number;
  57. column?: number;
  58. filename?: string;
  59. function?: string;
  60. instruction_addr?: string;
  61. lineno?: number;
  62. module?: string;
  63. package?: string;
  64. platform?: string;
  65. status?: SymbolicatorStatus;
  66. sym_addr?: string;
  67. symbol?: string;
  68. };
  69. type SentrySampledProfileTransaction = {
  70. name: string;
  71. trace_id: string;
  72. id: string;
  73. active_thread_id: number;
  74. };
  75. type SentrySampledProfile = {
  76. event_id: string;
  77. project_id: number;
  78. version: string;
  79. os: {
  80. name: string;
  81. version: string;
  82. build_number: string;
  83. };
  84. device: {
  85. architecture: string;
  86. is_emulator?: boolean;
  87. locale?: string;
  88. manufacturer?: string;
  89. model?: string;
  90. };
  91. runtime?: {
  92. name: string;
  93. version: string;
  94. };
  95. received: string;
  96. timestamp: string;
  97. release: Release | null;
  98. platform: 'node' | 'javascript' | string;
  99. environment?: string;
  100. debug_meta?: {
  101. images: Image[];
  102. };
  103. profile: {
  104. samples: SentrySampledProfileSample[];
  105. stacks: SentrySampledProfileStack[];
  106. frames: SentrySampledProfileFrame[];
  107. thread_metadata?: Record<string, {name?: string; priority?: number}>;
  108. queue_metadata?: Record<string, {label: string}>;
  109. };
  110. transaction: SentrySampledProfileTransaction;
  111. measurements?: Measurements;
  112. };
  113. interface SentryContinousProfileChunk {
  114. chunk_id: string;
  115. environment: string;
  116. project_id: number;
  117. received: number;
  118. release: string;
  119. organization_id: number;
  120. retention_days: number;
  121. project_id: string;
  122. version: '2';
  123. debug_meta?: {
  124. images: Image[];
  125. };
  126. platform: string;
  127. measurements?: ContinuousMeasurements;
  128. profile: ContinuousProfile;
  129. }
  130. ////////////////
  131. interface RawProfileBase {
  132. endValue: number;
  133. startValue: number;
  134. name: string;
  135. threadID: number;
  136. unit: string;
  137. spans?: Span[];
  138. threadID: number;
  139. }
  140. // Android traces follow this format
  141. interface EventedProfile extends RawProfileBase {
  142. events: ReadonlyArray<Event>;
  143. type: 'evented';
  144. }
  145. // iOS traces follow this format
  146. interface SampledProfile extends RawProfileBase {
  147. weights: number[];
  148. samples: number[][];
  149. samples_profiles?: 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. // We have extended the speedscope schema to include some additional metadata and measurements
  209. interface Schema extends SpeedscopeSchema {
  210. metadata: {
  211. androidAPILevel: number;
  212. deviceClassification: string;
  213. deviceLocale: string;
  214. deviceManufacturer: string;
  215. deviceModel: string;
  216. deviceOSName: string;
  217. deviceOSVersion: string;
  218. environment: string;
  219. organizationID: number;
  220. platform: string;
  221. profileID: string;
  222. projectID: number;
  223. received: string;
  224. release: Release | null;
  225. traceID: string;
  226. transactionID: string;
  227. transactionName: string;
  228. timestamp?: string;
  229. };
  230. profileID: string;
  231. projectID: number;
  232. measurements?: Measurements;
  233. }
  234. }