profiling.d.ts 5.7 KB

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