profiling.d.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. declare namespace Profiling {
  2. type Release = import('sentry/types').Release;
  3. type SentrySampledProfileSample = {
  4. stack_id: number;
  5. thread_id: string;
  6. elapsed_since_start_ns: string;
  7. queue_address?: string;
  8. };
  9. type SentrySampledProfileStack = number[];
  10. type SentrySampledProfileFrame = {
  11. function?: string;
  12. instruction_addr?: string;
  13. lineno?: number;
  14. colno?: number;
  15. filename?: string;
  16. };
  17. type SentrySampledProfileDebugMetaImage = {
  18. debug_id: string;
  19. image_addr: string;
  20. code_file: string;
  21. type: string;
  22. image_size: number;
  23. image_vmaddr: string;
  24. };
  25. type SentrySampledProfileTransaction = {
  26. name: string;
  27. trace_id: string;
  28. id: string;
  29. active_thread_id: string;
  30. relative_start_ns: string;
  31. relative_end_ns: string;
  32. };
  33. type SentrySampledProfile = {
  34. event_id: string;
  35. version: string;
  36. os: {
  37. name: string;
  38. version: string;
  39. build_number: string;
  40. };
  41. device: {
  42. architecture: string;
  43. is_emulator?: boolean;
  44. locale?: string;
  45. manufacturer?: string;
  46. model?: string;
  47. };
  48. runtime?: {
  49. name: string;
  50. version: string;
  51. };
  52. timestamp: string;
  53. release: string;
  54. platform: string;
  55. environment?: string;
  56. debug_meta?: {
  57. images: SentryProfileDebugMetaImage[];
  58. };
  59. profile: {
  60. samples: SentrySampledProfileSample[];
  61. stacks: SentrySampledProfileStack[];
  62. frames: SentrySampledProfileFrame[];
  63. thread_metadata?: Record<string, {name?: string; priority?: number}>;
  64. queue_metadata?: Record<string, {label: string}>;
  65. };
  66. transactions?: SentrySampledProfileTransaction[];
  67. };
  68. ////////////////
  69. interface RawProfileBase {
  70. endValue: number;
  71. startValue: number;
  72. name: string;
  73. threadID: number;
  74. unit: string;
  75. spans?: Span[];
  76. threadID: number;
  77. }
  78. // Android traces follow this format
  79. interface EventedProfile extends RawProfileBase {
  80. events: ReadonlyArray<Event>;
  81. type: 'evented';
  82. }
  83. // iOS traces follow this format
  84. interface SampledProfile extends RawProfileBase {
  85. weights: number[];
  86. samples: number[][];
  87. type: 'sampled';
  88. }
  89. interface NodeProfile extends Profiling.SampledProfile {
  90. frames: Profiling.FrameInfo[];
  91. }
  92. type Event = {at: number; frame: number; type: 'O' | 'C'};
  93. type Span = {
  94. duration_ms: number;
  95. name: string;
  96. queue_label: string;
  97. relative_start_ms: number;
  98. thread_id: number;
  99. children?: Span[];
  100. };
  101. type FrameInfo = {
  102. key: string | number;
  103. name: string;
  104. file?: string;
  105. path?: string;
  106. line?: number;
  107. column?: number;
  108. is_application?: boolean;
  109. image?: string;
  110. resource?: string;
  111. threadId?: number;
  112. inline?: boolean;
  113. // nodejs only
  114. columnNumber?: number;
  115. lineNumber?: number;
  116. scriptName?: string;
  117. scriptId?: number;
  118. };
  119. type ProfileTypes =
  120. | EventedProfile
  121. | SampledProfile
  122. | JSSelfProfiling.Trace
  123. | NodeProfile;
  124. type ImportedProfiles = {
  125. name: string;
  126. profileID: string;
  127. activeProfileIndex: number;
  128. profiles: ProfileTypes[];
  129. };
  130. // This extends speedscope's schema - we are keeping this as is, but we are likely to diverge as we add more
  131. // sentry related features to the flamegraphs. This should happen after the MVP integration
  132. type Schema = {
  133. profileID: string;
  134. profiles: ReadonlyArray<ProfileTypes>;
  135. projectID: number;
  136. shared: {
  137. frames: ReadonlyArray<Omit<FrameInfo, 'key'>>;
  138. };
  139. activeProfileIndex?: number;
  140. metadata: {
  141. androidAPILevel: number;
  142. deviceClassification: string;
  143. deviceLocale: string;
  144. deviceManufacturer: string;
  145. deviceModel: string;
  146. deviceOSName: string;
  147. deviceOSVersion: string;
  148. durationNS: number;
  149. environment: string;
  150. organizationID: number;
  151. platform: string;
  152. profileID: string;
  153. projectID: number;
  154. received: string;
  155. traceID: string;
  156. transactionID: string;
  157. release: Release | null;
  158. transactionName: string;
  159. };
  160. };
  161. }