profiling.d.ts 5.0 KB

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