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 Measurements = {
  12. frozen_frame_renders?: {
  13. unit: string;
  14. values: MeasurementValue[];
  15. };
  16. screen_frame_rates?: {
  17. unit: string;
  18. values: MeasurementValue[];
  19. };
  20. slow_frame_renders?: {
  21. unit: string;
  22. values: MeasurementValue[];
  23. };
  24. };
  25. type SentrySampledProfileSample = {
  26. stack_id: number;
  27. thread_id: string;
  28. elapsed_since_start_ns: number;
  29. queue_address?: string;
  30. };
  31. type SentrySampledProfileStack = number[];
  32. type SentrySampledProfileFrame = {
  33. in_app: boolean;
  34. colno?: number;
  35. filename?: string;
  36. function?: string;
  37. instruction_addr?: string;
  38. lineno?: number;
  39. module?: string;
  40. package?: string;
  41. abs_path?: string;
  42. status?: SymbolicatorStatus;
  43. sym_addr?: string;
  44. symbol?: string;
  45. };
  46. type SentrySampledProfileTransaction = {
  47. name: string;
  48. trace_id: string;
  49. id: string;
  50. active_thread_id: number;
  51. };
  52. type SentrySampledProfile = {
  53. event_id: string;
  54. project_id: number;
  55. version: string;
  56. os: {
  57. name: string;
  58. version: string;
  59. build_number: string;
  60. };
  61. device: {
  62. architecture: string;
  63. is_emulator?: boolean;
  64. locale?: string;
  65. manufacturer?: string;
  66. model?: string;
  67. };
  68. runtime?: {
  69. name: string;
  70. version: string;
  71. };
  72. timestamp: string;
  73. release: Release | null;
  74. platform: string;
  75. environment?: string;
  76. debug_meta?: {
  77. images: Image[];
  78. };
  79. profile: {
  80. samples: SentrySampledProfileSample[];
  81. stacks: SentrySampledProfileStack[];
  82. frames: SentrySampledProfileFrame[];
  83. thread_metadata?: Record<string, {name?: string; priority?: number}>;
  84. queue_metadata?: Record<string, {label: string}>;
  85. };
  86. transaction: SentrySampledProfileTransaction;
  87. measurements?: Measurements;
  88. };
  89. ////////////////
  90. interface RawProfileBase {
  91. endValue: number;
  92. startValue: number;
  93. name: string;
  94. threadID: number;
  95. unit: string;
  96. spans?: Span[];
  97. threadID: number;
  98. }
  99. // Android traces follow this format
  100. interface EventedProfile extends RawProfileBase {
  101. events: ReadonlyArray<Event>;
  102. type: 'evented';
  103. }
  104. // iOS traces follow this format
  105. interface SampledProfile extends RawProfileBase {
  106. weights: number[];
  107. samples: number[][];
  108. samples_profiles?: 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. }