profiling.d.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. type Event = {at: number; frame: number; type: 'O' | 'C'};
  90. type Span = {
  91. duration_ms: number;
  92. name: string;
  93. queue_label: string;
  94. relative_start_ms: number;
  95. thread_id: number;
  96. children?: Span[];
  97. };
  98. type FrameInfo = {
  99. key: string | number;
  100. name: string;
  101. file?: string;
  102. path?: string;
  103. line?: number;
  104. column?: number;
  105. is_application?: boolean;
  106. image?: string;
  107. resource?: string;
  108. threadId?: number;
  109. inline?: boolean;
  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. release: Release | null;
  155. transactionName: string;
  156. };
  157. };
  158. }