profiling.d.ts 4.8 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 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. timestamp: string;
  81. release: Release | null;
  82. platform: string;
  83. environment?: string;
  84. debug_meta?: {
  85. images: Image[];
  86. };
  87. profile: {
  88. samples: SentrySampledProfileSample[];
  89. stacks: SentrySampledProfileStack[];
  90. frames: SentrySampledProfileFrame[];
  91. thread_metadata?: Record<string, {name?: string; priority?: number}>;
  92. queue_metadata?: Record<string, {label: string}>;
  93. };
  94. transaction: SentrySampledProfileTransaction;
  95. measurements?: Measurements;
  96. };
  97. ////////////////
  98. interface RawProfileBase {
  99. endValue: number;
  100. startValue: number;
  101. name: string;
  102. threadID: number;
  103. unit: string;
  104. spans?: Span[];
  105. threadID: number;
  106. }
  107. // Android traces follow this format
  108. interface EventedProfile extends RawProfileBase {
  109. events: ReadonlyArray<Event>;
  110. type: 'evented';
  111. }
  112. // iOS traces follow this format
  113. interface SampledProfile extends RawProfileBase {
  114. weights: number[];
  115. samples: number[][];
  116. samples_profiles?: number[][];
  117. type: 'sampled';
  118. }
  119. type Event = {at: number; frame: number; type: 'O' | 'C'};
  120. type Span = {
  121. duration_ms: number;
  122. name: string;
  123. queue_label: string;
  124. relative_start_ms: number;
  125. thread_id: number;
  126. children?: Span[];
  127. };
  128. type FrameInfo = {
  129. key: string | number;
  130. name: string;
  131. file?: string;
  132. path?: string;
  133. line?: number;
  134. column?: number;
  135. is_application?: boolean;
  136. resource?: string;
  137. threadId?: number;
  138. inline?: boolean;
  139. instructionAddr?: string;
  140. symbol?: string;
  141. symbolAddr?: string;
  142. symbolicatorStatus?: SymbolicatorStatus;
  143. image?: string;
  144. // This is used for native platforms to indicate the name of the assembly, path of the dylib, etc
  145. package?: string;
  146. // This is the import path for the module
  147. module?: string;
  148. // nodejs only
  149. columnNumber?: number;
  150. lineNumber?: number;
  151. scriptName?: string;
  152. scriptId?: number;
  153. };
  154. type ProfileInput =
  155. | Profiling.Schema
  156. | JSSelfProfiling.Trace
  157. | Profiling.SentrySampledProfile;
  158. type ImportedProfiles = {
  159. name: string;
  160. profileID: string;
  161. activeProfileIndex: number;
  162. profiles: ReadonlyArray<ProfileInput>;
  163. };
  164. // We have extended the speedscope schema to include some additional metadata and measurements
  165. interface Schema extends SpeedscopeSchema {
  166. metadata: {
  167. androidAPILevel: number;
  168. deviceClassification: string;
  169. deviceLocale: string;
  170. deviceManufacturer: string;
  171. deviceModel: string;
  172. deviceOSName: string;
  173. deviceOSVersion: string;
  174. environment: string;
  175. organizationID: number;
  176. platform: string;
  177. profileID: string;
  178. projectID: number;
  179. received: string;
  180. release: Release | null;
  181. traceID: string;
  182. transactionID: string;
  183. transactionName: string;
  184. };
  185. profileID: string;
  186. projectID: number;
  187. measurements?: Measurements;
  188. }
  189. }