profiling.d.ts 4.7 KB

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