profiling.d.ts 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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: 'node' | 'javascript' | 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. sample_durations_ns?: number[];
  109. type: 'sampled';
  110. }
  111. type Event = {at: number; frame: number; type: 'O' | 'C'};
  112. type Span = {
  113. duration_ms: number;
  114. name: string;
  115. queue_label: string;
  116. relative_start_ms: number;
  117. thread_id: number;
  118. children?: Span[];
  119. };
  120. type FrameInfo = {
  121. key: string | number;
  122. name: string;
  123. file?: string;
  124. path?: string;
  125. line?: number;
  126. column?: number;
  127. is_application?: boolean;
  128. resource?: string;
  129. threadId?: number;
  130. inline?: boolean;
  131. instructionAddr?: string;
  132. symbol?: string;
  133. symbolAddr?: string;
  134. symbolicatorStatus?: SymbolicatorStatus;
  135. image?: string;
  136. // This is used for native platforms to indicate the name of the assembly, path of the dylib, etc
  137. package?: string;
  138. // This is the import path for the module
  139. module?: string;
  140. // nodejs only
  141. columnNumber?: number;
  142. lineNumber?: number;
  143. scriptName?: string;
  144. scriptId?: number;
  145. };
  146. type ProfileInput =
  147. | Profiling.Schema
  148. | JSSelfProfiling.Trace
  149. | Profiling.SentrySampledProfile;
  150. type ImportedProfiles = {
  151. name: string;
  152. profileID: string;
  153. activeProfileIndex: number;
  154. profiles: ReadonlyArray<ProfileInput>;
  155. };
  156. // We have extended the speedscope schema to include some additional metadata and measurements
  157. interface Schema extends SpeedscopeSchema {
  158. metadata: {
  159. androidAPILevel: number;
  160. deviceClassification: string;
  161. deviceLocale: string;
  162. deviceManufacturer: string;
  163. deviceModel: string;
  164. deviceOSName: string;
  165. deviceOSVersion: string;
  166. environment: string;
  167. organizationID: number;
  168. platform: string;
  169. profileID: string;
  170. projectID: number;
  171. received: string;
  172. release: Release | null;
  173. traceID: string;
  174. transactionID: string;
  175. transactionName: string;
  176. };
  177. profileID: string;
  178. projectID: number;
  179. measurements?: Measurements;
  180. }
  181. }