profiling.d.ts 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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. colno?: number;
  55. col?: number;
  56. column?: number;
  57. filename?: string;
  58. function?: string;
  59. instruction_addr?: string;
  60. lineno?: number;
  61. module?: string;
  62. package?: string;
  63. abs_path?: 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. version: '2';
  121. debug_meta?: {
  122. images: Image[];
  123. };
  124. platform: string;
  125. measurements?: ContinuousMeasurements;
  126. profile: ContinuousProfile;
  127. }
  128. ////////////////
  129. interface RawProfileBase {
  130. endValue: number;
  131. startValue: number;
  132. name: string;
  133. threadID: number;
  134. unit: string;
  135. spans?: Span[];
  136. threadID: number;
  137. }
  138. // Android traces follow this format
  139. interface EventedProfile extends RawProfileBase {
  140. events: ReadonlyArray<Event>;
  141. type: 'evented';
  142. }
  143. // iOS traces follow this format
  144. interface SampledProfile extends RawProfileBase {
  145. weights: number[];
  146. samples: number[][];
  147. samples_profiles?: number[][];
  148. sample_durations_ns?: number[];
  149. type: 'sampled';
  150. }
  151. type ContinuousProfile = {
  152. samples: SentrySampledProfileChunkSample[];
  153. frames: SentrySampledProfileFrame[];
  154. stacks: SentrySampledProfileStack[];
  155. thread_metadata?: Record<string, {name?: string; priority?: number}>;
  156. };
  157. type Event = {at: number; frame: number; type: 'O' | 'C'};
  158. type Span = {
  159. duration_ms: number;
  160. name: string;
  161. queue_label: string;
  162. relative_start_ms: number;
  163. thread_id: number;
  164. children?: Span[];
  165. };
  166. type FrameInfo = {
  167. key: string | number;
  168. name: string;
  169. file?: string;
  170. path?: string;
  171. line?: number;
  172. column?: number;
  173. col?: number;
  174. colno?: number;
  175. is_application?: boolean;
  176. resource?: string;
  177. threadId?: number;
  178. inline?: boolean;
  179. instructionAddr?: string;
  180. symbol?: string;
  181. symbolAddr?: string;
  182. symbolicatorStatus?: SymbolicatorStatus;
  183. image?: string;
  184. // This is used for native platforms to indicate the name of the assembly, path of the dylib, etc
  185. package?: string;
  186. // This is the import path for the module
  187. module?: string;
  188. // nodejs only
  189. columnNumber?: number;
  190. lineNumber?: number;
  191. scriptName?: string;
  192. scriptId?: number;
  193. };
  194. type ProfileInput =
  195. | Profiling.Schema
  196. | JSSelfProfiling.Trace
  197. | Profiling.SentrySampledProfile
  198. | Profiling.SentryContinousProfileChunk;
  199. type ImportedProfiles = {
  200. name: string;
  201. profileID: string;
  202. activeProfileIndex: number;
  203. profiles: ReadonlyArray<ProfileInput>;
  204. };
  205. // We have extended the speedscope schema to include some additional metadata and measurements
  206. interface Schema extends SpeedscopeSchema {
  207. metadata: {
  208. androidAPILevel: number;
  209. deviceClassification: string;
  210. deviceLocale: string;
  211. deviceManufacturer: string;
  212. deviceModel: string;
  213. deviceOSName: string;
  214. deviceOSVersion: string;
  215. environment: string;
  216. organizationID: number;
  217. platform: string;
  218. profileID: string;
  219. projectID: number;
  220. received: string;
  221. release: Release | null;
  222. traceID: string;
  223. transactionID: string;
  224. transactionName: string;
  225. timestamp?: string;
  226. };
  227. profileID: string;
  228. projectID: number;
  229. measurements?: Measurements;
  230. }
  231. }