profiling.d.ts 4.8 KB

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