profiling.d.ts 5.6 KB

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