profiling.d.ts 4.0 KB

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