@oneuptime/common 10.0.39 → 10.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/Models/AnalyticsModels/Index.ts +4 -0
  2. package/Models/AnalyticsModels/Profile.ts +687 -0
  3. package/Models/AnalyticsModels/ProfileSample.ts +547 -0
  4. package/Models/DatabaseModels/Dashboard.ts +357 -0
  5. package/Models/DatabaseModels/DashboardDomain.ts +658 -0
  6. package/Models/DatabaseModels/Index.ts +2 -0
  7. package/Models/DatabaseModels/StatusPage.ts +41 -0
  8. package/Server/API/DashboardAPI.ts +408 -0
  9. package/Server/API/DashboardDomainAPI.ts +235 -0
  10. package/Server/API/StatusPageAPI.ts +36 -2
  11. package/Server/API/TelemetryAPI.ts +393 -0
  12. package/Server/EnvironmentConfig.ts +12 -0
  13. package/Server/Infrastructure/Postgres/SchemaMigrations/1774524742177-MigrationName.ts +97 -0
  14. package/Server/Infrastructure/Postgres/SchemaMigrations/1774524742178-MigrationName.ts +17 -0
  15. package/Server/Infrastructure/Postgres/SchemaMigrations/1774524742179-MigrationName.ts +50 -0
  16. package/Server/Infrastructure/Postgres/SchemaMigrations/1774559064919-MigrationName.ts +59 -0
  17. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
  18. package/Server/Middleware/UserAuthorization.ts +96 -1
  19. package/Server/Services/DashboardDomainService.ts +647 -0
  20. package/Server/Services/DashboardService.ts +174 -3
  21. package/Server/Services/IncidentService.ts +295 -50
  22. package/Server/Services/IncidentStateTimelineService.ts +1 -0
  23. package/Server/Services/Index.ts +6 -0
  24. package/Server/Services/MonitorService.ts +5 -0
  25. package/Server/Services/ProfileAggregationService.ts +559 -0
  26. package/Server/Services/ProfileSampleService.ts +11 -0
  27. package/Server/Services/ProfileService.ts +11 -0
  28. package/Server/Services/TelemetryUsageBillingService.ts +77 -3
  29. package/Server/Services/WorkspaceNotificationSummaryService.ts +15 -1
  30. package/Server/Types/Billing/MeteredPlan/AllMeteredPlans.ts +9 -0
  31. package/Server/Utils/Cookie.ts +48 -0
  32. package/Server/Utils/Monitor/Criteria/ProfileMonitorCriteria.ts +34 -0
  33. package/Server/Utils/Monitor/DataToProcess.ts +3 -1
  34. package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +299 -0
  35. package/Server/Utils/Profile/PprofEncoder.ts +225 -0
  36. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +53 -16
  37. package/Server/Utils/Workspace/Slack/Slack.ts +26 -6
  38. package/ServiceRoute.ts +2 -0
  39. package/Tests/UI/Components/ComponentsModal.test.tsx +19 -15
  40. package/Types/AnalyticsDatabase/AnalyticsTableName.ts +2 -0
  41. package/Types/CookieName.ts +1 -0
  42. package/Types/Dashboard/Chart/ChartType.ts +5 -0
  43. package/Types/Dashboard/DashboardComponentType.ts +4 -0
  44. package/Types/Dashboard/DashboardComponents/ComponentArgument.ts +10 -0
  45. package/Types/Dashboard/DashboardComponents/DashboardChartComponent.ts +1 -2
  46. package/Types/Dashboard/DashboardComponents/DashboardGaugeComponent.ts +17 -0
  47. package/Types/Dashboard/DashboardComponents/DashboardLogStreamComponent.ts +15 -0
  48. package/Types/Dashboard/DashboardComponents/DashboardTableComponent.ts +14 -0
  49. package/Types/Dashboard/DashboardComponents/DashboardTextComponent.ts +1 -0
  50. package/Types/Dashboard/DashboardComponents/DashboardTraceListComponent.ts +13 -0
  51. package/Types/Dashboard/DashboardComponents/DashboardValueComponent.ts +2 -0
  52. package/Types/Dashboard/DashboardTemplates.ts +964 -0
  53. package/Types/Dashboard/DashboardVariable.ts +23 -0
  54. package/Types/Dashboard/DashboardViewConfig.ts +59 -0
  55. package/Types/Dashboard/MasterPassword.ts +10 -0
  56. package/Types/Icon/IconProp.ts +1 -0
  57. package/Types/Incident/IncidentMetricType.ts +3 -0
  58. package/Types/MeteredPlan/ProductType.ts +1 -0
  59. package/Types/Metrics/MetricQueryConfigData.ts +3 -0
  60. package/Types/Monitor/CriteriaFilter.ts +3 -0
  61. package/Types/Monitor/KubernetesAlertTemplates.ts +78 -7
  62. package/Types/Monitor/MetricMonitor/MetricMonitorResponse.ts +20 -0
  63. package/Types/Monitor/MonitorStep.ts +25 -0
  64. package/Types/Monitor/MonitorStepProfileMonitor.ts +96 -0
  65. package/Types/Monitor/MonitorType.ts +11 -0
  66. package/Types/Monitor/ProfileMonitor/ProfileMonitorResponse.ts +12 -0
  67. package/Types/Permission.ts +87 -0
  68. package/Types/Telemetry/TelemetryType.ts +1 -0
  69. package/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryItem.ts +1 -0
  70. package/UI/Components/Button/Button.tsx +1 -1
  71. package/UI/Components/Card/Card.tsx +8 -4
  72. package/UI/Components/Charts/Area/AreaChart.tsx +4 -0
  73. package/UI/Components/Charts/Bar/BarChart.tsx +4 -0
  74. package/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.tsx +26 -0
  75. package/UI/Components/Charts/ChartLibrary/BarChart/BarChart.tsx +26 -0
  76. package/UI/Components/Charts/ChartLibrary/LineChart/LineChart.tsx +26 -0
  77. package/UI/Components/Charts/Line/LineChart.tsx +4 -0
  78. package/UI/Components/Charts/Types/ReferenceLineProps.ts +6 -0
  79. package/UI/Components/Icon/Icon.tsx +33 -0
  80. package/UI/Components/ModelTable/BaseModelTable.tsx +13 -10
  81. package/UI/Components/MoreMenu/MoreMenu.tsx +15 -2
  82. package/UI/Components/MoreMenu/MoreMenuItem.tsx +4 -4
  83. package/UI/Components/Workflow/Component.tsx +450 -209
  84. package/UI/Components/Workflow/ComponentPortViewer.tsx +57 -20
  85. package/UI/Components/Workflow/ComponentReturnValueViewer.tsx +65 -25
  86. package/UI/Components/Workflow/ComponentSettingsModal.tsx +202 -37
  87. package/UI/Components/Workflow/ComponentsModal.tsx +180 -93
  88. package/UI/Components/Workflow/Workflow.tsx +105 -9
  89. package/UI/Config.ts +9 -0
  90. package/Utils/Dashboard/Components/DashboardChartComponent.ts +53 -22
  91. package/Utils/Dashboard/Components/DashboardGaugeComponent.ts +124 -0
  92. package/Utils/Dashboard/Components/DashboardLogStreamComponent.ts +110 -0
  93. package/Utils/Dashboard/Components/DashboardTableComponent.ts +86 -0
  94. package/Utils/Dashboard/Components/DashboardTextComponent.ts +32 -7
  95. package/Utils/Dashboard/Components/DashboardTraceListComponent.ts +86 -0
  96. package/Utils/Dashboard/Components/DashboardValueComponent.ts +39 -3
  97. package/Utils/Dashboard/Components/Index.ts +28 -0
  98. package/Utils/ValueFormatter.ts +170 -0
  99. package/build/dist/Models/AnalyticsModels/Index.js +4 -0
  100. package/build/dist/Models/AnalyticsModels/Index.js.map +1 -1
  101. package/build/dist/Models/AnalyticsModels/Profile.js +621 -0
  102. package/build/dist/Models/AnalyticsModels/Profile.js.map +1 -0
  103. package/build/dist/Models/AnalyticsModels/ProfileSample.js +497 -0
  104. package/build/dist/Models/AnalyticsModels/ProfileSample.js.map +1 -0
  105. package/build/dist/Models/DatabaseModels/Dashboard.js +365 -0
  106. package/build/dist/Models/DatabaseModels/Dashboard.js.map +1 -1
  107. package/build/dist/Models/DatabaseModels/DashboardDomain.js +691 -0
  108. package/build/dist/Models/DatabaseModels/DashboardDomain.js.map +1 -0
  109. package/build/dist/Models/DatabaseModels/Index.js +2 -0
  110. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  111. package/build/dist/Models/DatabaseModels/StatusPage.js +42 -0
  112. package/build/dist/Models/DatabaseModels/StatusPage.js.map +1 -1
  113. package/build/dist/Server/API/DashboardAPI.js +293 -0
  114. package/build/dist/Server/API/DashboardAPI.js.map +1 -0
  115. package/build/dist/Server/API/DashboardDomainAPI.js +124 -0
  116. package/build/dist/Server/API/DashboardDomainAPI.js.map +1 -0
  117. package/build/dist/Server/API/StatusPageAPI.js +26 -2
  118. package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
  119. package/build/dist/Server/API/TelemetryAPI.js +222 -0
  120. package/build/dist/Server/API/TelemetryAPI.js.map +1 -1
  121. package/build/dist/Server/EnvironmentConfig.js +4 -0
  122. package/build/dist/Server/EnvironmentConfig.js.map +1 -1
  123. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774524742177-MigrationName.js +40 -0
  124. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774524742177-MigrationName.js.map +1 -0
  125. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774524742178-MigrationName.js +12 -0
  126. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774524742178-MigrationName.js.map +1 -0
  127. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774524742179-MigrationName.js +23 -0
  128. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774524742179-MigrationName.js.map +1 -0
  129. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774559064919-MigrationName.js +26 -0
  130. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774559064919-MigrationName.js.map +1 -0
  131. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +8 -0
  132. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  133. package/build/dist/Server/Middleware/UserAuthorization.js +41 -0
  134. package/build/dist/Server/Middleware/UserAuthorization.js.map +1 -1
  135. package/build/dist/Server/Services/DashboardDomainService.js +595 -0
  136. package/build/dist/Server/Services/DashboardDomainService.js.map +1 -0
  137. package/build/dist/Server/Services/DashboardService.js +117 -3
  138. package/build/dist/Server/Services/DashboardService.js.map +1 -1
  139. package/build/dist/Server/Services/IncidentService.js +231 -55
  140. package/build/dist/Server/Services/IncidentService.js.map +1 -1
  141. package/build/dist/Server/Services/IncidentStateTimelineService.js +1 -1
  142. package/build/dist/Server/Services/IncidentStateTimelineService.js.map +1 -1
  143. package/build/dist/Server/Services/Index.js +6 -0
  144. package/build/dist/Server/Services/Index.js.map +1 -1
  145. package/build/dist/Server/Services/MonitorService.js +5 -2
  146. package/build/dist/Server/Services/MonitorService.js.map +1 -1
  147. package/build/dist/Server/Services/ProfileAggregationService.js +356 -0
  148. package/build/dist/Server/Services/ProfileAggregationService.js.map +1 -0
  149. package/build/dist/Server/Services/ProfileSampleService.js +9 -0
  150. package/build/dist/Server/Services/ProfileSampleService.js.map +1 -0
  151. package/build/dist/Server/Services/ProfileService.js +9 -0
  152. package/build/dist/Server/Services/ProfileService.js.map +1 -0
  153. package/build/dist/Server/Services/TelemetryUsageBillingService.js +61 -4
  154. package/build/dist/Server/Services/TelemetryUsageBillingService.js.map +1 -1
  155. package/build/dist/Server/Services/WorkspaceNotificationSummaryService.js +13 -1
  156. package/build/dist/Server/Services/WorkspaceNotificationSummaryService.js.map +1 -1
  157. package/build/dist/Server/Types/Billing/MeteredPlan/AllMeteredPlans.js +8 -0
  158. package/build/dist/Server/Types/Billing/MeteredPlan/AllMeteredPlans.js.map +1 -1
  159. package/build/dist/Server/Utils/Cookie.js +36 -0
  160. package/build/dist/Server/Utils/Cookie.js.map +1 -1
  161. package/build/dist/Server/Utils/Monitor/Criteria/ProfileMonitorCriteria.js +34 -0
  162. package/build/dist/Server/Utils/Monitor/Criteria/ProfileMonitorCriteria.js.map +1 -0
  163. package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +173 -0
  164. package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
  165. package/build/dist/Server/Utils/Profile/PprofEncoder.js +129 -0
  166. package/build/dist/Server/Utils/Profile/PprofEncoder.js.map +1 -0
  167. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +36 -14
  168. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
  169. package/build/dist/Server/Utils/Workspace/Slack/Slack.js +23 -6
  170. package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
  171. package/build/dist/ServiceRoute.js +1 -0
  172. package/build/dist/ServiceRoute.js.map +1 -1
  173. package/build/dist/Tests/UI/Components/ComponentsModal.test.js +15 -15
  174. package/build/dist/Tests/UI/Components/ComponentsModal.test.js.map +1 -1
  175. package/build/dist/Types/AnalyticsDatabase/AnalyticsTableName.js +2 -0
  176. package/build/dist/Types/AnalyticsDatabase/AnalyticsTableName.js.map +1 -1
  177. package/build/dist/Types/CookieName.js +1 -0
  178. package/build/dist/Types/CookieName.js.map +1 -1
  179. package/build/dist/Types/Dashboard/Chart/ChartType.js +5 -0
  180. package/build/dist/Types/Dashboard/Chart/ChartType.js.map +1 -1
  181. package/build/dist/Types/Dashboard/DashboardComponentType.js +4 -0
  182. package/build/dist/Types/Dashboard/DashboardComponentType.js.map +1 -1
  183. package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js +1 -0
  184. package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js.map +1 -1
  185. package/build/dist/Types/Dashboard/DashboardComponents/DashboardGaugeComponent.js +2 -0
  186. package/build/dist/Types/Dashboard/DashboardComponents/DashboardGaugeComponent.js.map +1 -0
  187. package/build/dist/Types/Dashboard/DashboardComponents/DashboardLogStreamComponent.js +2 -0
  188. package/build/dist/Types/Dashboard/DashboardComponents/DashboardLogStreamComponent.js.map +1 -0
  189. package/build/dist/Types/Dashboard/DashboardComponents/DashboardTableComponent.js +2 -0
  190. package/build/dist/Types/Dashboard/DashboardComponents/DashboardTableComponent.js.map +1 -0
  191. package/build/dist/Types/Dashboard/DashboardComponents/DashboardTraceListComponent.js +2 -0
  192. package/build/dist/Types/Dashboard/DashboardComponents/DashboardTraceListComponent.js.map +1 -0
  193. package/build/dist/Types/Dashboard/DashboardTemplates.js +853 -0
  194. package/build/dist/Types/Dashboard/DashboardTemplates.js.map +1 -0
  195. package/build/dist/Types/Dashboard/DashboardVariable.js +7 -0
  196. package/build/dist/Types/Dashboard/DashboardVariable.js.map +1 -0
  197. package/build/dist/Types/Dashboard/DashboardViewConfig.js +50 -1
  198. package/build/dist/Types/Dashboard/DashboardViewConfig.js.map +1 -1
  199. package/build/dist/Types/Dashboard/MasterPassword.js +5 -0
  200. package/build/dist/Types/Dashboard/MasterPassword.js.map +1 -0
  201. package/build/dist/Types/Icon/IconProp.js +1 -0
  202. package/build/dist/Types/Icon/IconProp.js.map +1 -1
  203. package/build/dist/Types/Incident/IncidentMetricType.js +3 -0
  204. package/build/dist/Types/Incident/IncidentMetricType.js.map +1 -1
  205. package/build/dist/Types/MeteredPlan/ProductType.js +1 -0
  206. package/build/dist/Types/MeteredPlan/ProductType.js.map +1 -1
  207. package/build/dist/Types/Metrics/MetricQueryConfigData.js +1 -0
  208. package/build/dist/Types/Metrics/MetricQueryConfigData.js.map +1 -1
  209. package/build/dist/Types/Monitor/CriteriaFilter.js +2 -0
  210. package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
  211. package/build/dist/Types/Monitor/KubernetesAlertTemplates.js +58 -7
  212. package/build/dist/Types/Monitor/KubernetesAlertTemplates.js.map +1 -1
  213. package/build/dist/Types/Monitor/MonitorStep.js +15 -0
  214. package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
  215. package/build/dist/Types/Monitor/MonitorStepProfileMonitor.js +59 -0
  216. package/build/dist/Types/Monitor/MonitorStepProfileMonitor.js.map +1 -0
  217. package/build/dist/Types/Monitor/MonitorType.js +10 -0
  218. package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
  219. package/build/dist/Types/Monitor/ProfileMonitor/ProfileMonitorResponse.js +2 -0
  220. package/build/dist/Types/Monitor/ProfileMonitor/ProfileMonitorResponse.js.map +1 -0
  221. package/build/dist/Types/Permission.js +75 -0
  222. package/build/dist/Types/Permission.js.map +1 -1
  223. package/build/dist/Types/Telemetry/TelemetryType.js +1 -0
  224. package/build/dist/Types/Telemetry/TelemetryType.js.map +1 -1
  225. package/build/dist/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryItem.js +1 -0
  226. package/build/dist/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryItem.js.map +1 -1
  227. package/build/dist/UI/Components/Button/Button.js +1 -1
  228. package/build/dist/UI/Components/Button/Button.js.map +1 -1
  229. package/build/dist/UI/Components/Card/Card.js +4 -4
  230. package/build/dist/UI/Components/Card/Card.js.map +1 -1
  231. package/build/dist/UI/Components/Charts/Area/AreaChart.js +1 -1
  232. package/build/dist/UI/Components/Charts/Area/AreaChart.js.map +1 -1
  233. package/build/dist/UI/Components/Charts/Bar/BarChart.js +1 -1
  234. package/build/dist/UI/Components/Charts/Bar/BarChart.js.map +1 -1
  235. package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js +5 -2
  236. package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js.map +1 -1
  237. package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js +5 -2
  238. package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js.map +1 -1
  239. package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js +6 -3
  240. package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js.map +1 -1
  241. package/build/dist/UI/Components/Charts/Line/LineChart.js +1 -1
  242. package/build/dist/UI/Components/Charts/Line/LineChart.js.map +1 -1
  243. package/build/dist/UI/Components/Charts/Types/ReferenceLineProps.js +2 -0
  244. package/build/dist/UI/Components/Charts/Types/ReferenceLineProps.js.map +1 -0
  245. package/build/dist/UI/Components/Icon/Icon.js +11 -0
  246. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  247. package/build/dist/UI/Components/ModelTable/BaseModelTable.js +12 -9
  248. package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
  249. package/build/dist/UI/Components/MoreMenu/MoreMenu.js +8 -2
  250. package/build/dist/UI/Components/MoreMenu/MoreMenu.js.map +1 -1
  251. package/build/dist/UI/Components/MoreMenu/MoreMenuItem.js +4 -4
  252. package/build/dist/UI/Components/MoreMenu/MoreMenuItem.js.map +1 -1
  253. package/build/dist/UI/Components/Workflow/Component.js +311 -143
  254. package/build/dist/UI/Components/Workflow/Component.js.map +1 -1
  255. package/build/dist/UI/Components/Workflow/ComponentPortViewer.js +44 -18
  256. package/build/dist/UI/Components/Workflow/ComponentPortViewer.js.map +1 -1
  257. package/build/dist/UI/Components/Workflow/ComponentReturnValueViewer.js +48 -22
  258. package/build/dist/UI/Components/Workflow/ComponentReturnValueViewer.js.map +1 -1
  259. package/build/dist/UI/Components/Workflow/ComponentSettingsModal.js +127 -21
  260. package/build/dist/UI/Components/Workflow/ComponentSettingsModal.js.map +1 -1
  261. package/build/dist/UI/Components/Workflow/ComponentsModal.js +107 -52
  262. package/build/dist/UI/Components/Workflow/ComponentsModal.js.map +1 -1
  263. package/build/dist/UI/Components/Workflow/Workflow.js +87 -12
  264. package/build/dist/UI/Components/Workflow/Workflow.js.map +1 -1
  265. package/build/dist/UI/Config.js +3 -1
  266. package/build/dist/UI/Config.js.map +1 -1
  267. package/build/dist/Utils/Dashboard/Components/DashboardChartComponent.js +50 -21
  268. package/build/dist/Utils/Dashboard/Components/DashboardChartComponent.js.map +1 -1
  269. package/build/dist/Utils/Dashboard/Components/DashboardGaugeComponent.js +104 -0
  270. package/build/dist/Utils/Dashboard/Components/DashboardGaugeComponent.js.map +1 -0
  271. package/build/dist/Utils/Dashboard/Components/DashboardLogStreamComponent.js +91 -0
  272. package/build/dist/Utils/Dashboard/Components/DashboardLogStreamComponent.js.map +1 -0
  273. package/build/dist/Utils/Dashboard/Components/DashboardTableComponent.js +70 -0
  274. package/build/dist/Utils/Dashboard/Components/DashboardTableComponent.js.map +1 -0
  275. package/build/dist/Utils/Dashboard/Components/DashboardTextComponent.js +28 -7
  276. package/build/dist/Utils/Dashboard/Components/DashboardTextComponent.js.map +1 -1
  277. package/build/dist/Utils/Dashboard/Components/DashboardTraceListComponent.js +70 -0
  278. package/build/dist/Utils/Dashboard/Components/DashboardTraceListComponent.js.map +1 -0
  279. package/build/dist/Utils/Dashboard/Components/DashboardValueComponent.js +34 -3
  280. package/build/dist/Utils/Dashboard/Components/DashboardValueComponent.js.map +1 -1
  281. package/build/dist/Utils/Dashboard/Components/Index.js +16 -0
  282. package/build/dist/Utils/Dashboard/Components/Index.js.map +1 -1
  283. package/build/dist/Utils/ValueFormatter.js +132 -0
  284. package/build/dist/Utils/ValueFormatter.js.map +1 -0
  285. package/package.json +1 -1
@@ -0,0 +1,559 @@
1
+ import { SQL, Statement } from "../Utils/AnalyticsDatabase/Statement";
2
+ import ProfileSampleDatabaseService from "./ProfileSampleService";
3
+ import TableColumnType from "../../Types/AnalyticsDatabase/TableColumnType";
4
+ import { JSONObject } from "../../Types/JSON";
5
+ import ObjectID from "../../Types/ObjectID";
6
+ import Includes from "../../Types/BaseDatabase/Includes";
7
+ import AnalyticsTableName from "../../Types/AnalyticsDatabase/AnalyticsTableName";
8
+ import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
9
+ import { DbJSONResponse, Results } from "./AnalyticsDatabaseService";
10
+
11
+ // --- Interfaces ---
12
+
13
+ export interface ProfileFlamegraphNode {
14
+ functionName: string;
15
+ fileName: string;
16
+ lineNumber: number;
17
+ selfValue: number;
18
+ totalValue: number;
19
+ children: ProfileFlamegraphNode[];
20
+ frameType: string;
21
+ }
22
+
23
+ export interface FlamegraphRequest {
24
+ projectId: ObjectID;
25
+ profileId?: string;
26
+ startTime?: Date;
27
+ endTime?: Date;
28
+ serviceIds?: Array<ObjectID>;
29
+ profileType?: string;
30
+ }
31
+
32
+ export interface FunctionListItem {
33
+ functionName: string;
34
+ fileName: string;
35
+ selfValue: number;
36
+ totalValue: number;
37
+ sampleCount: number;
38
+ frameType: string;
39
+ }
40
+
41
+ export interface FunctionListRequest {
42
+ projectId: ObjectID;
43
+ startTime: Date;
44
+ endTime: Date;
45
+ serviceIds?: Array<ObjectID>;
46
+ profileType?: string;
47
+ limit?: number;
48
+ sortBy?: "selfValue" | "totalValue" | "sampleCount";
49
+ }
50
+
51
+ export interface DiffFlamegraphRequest {
52
+ projectId: ObjectID;
53
+ baselineStartTime: Date;
54
+ baselineEndTime: Date;
55
+ comparisonStartTime: Date;
56
+ comparisonEndTime: Date;
57
+ serviceIds?: Array<ObjectID>;
58
+ profileType?: string;
59
+ }
60
+
61
+ export interface DiffFlamegraphNode {
62
+ functionName: string;
63
+ fileName: string;
64
+ lineNumber: number;
65
+ baselineValue: number;
66
+ comparisonValue: number;
67
+ delta: number;
68
+ deltaPercent: number;
69
+ selfBaselineValue: number;
70
+ selfComparisonValue: number;
71
+ selfDelta: number;
72
+ children: DiffFlamegraphNode[];
73
+ frameType: string;
74
+ }
75
+
76
+ interface ParsedFrame {
77
+ functionName: string;
78
+ fileName: string;
79
+ lineNumber: number;
80
+ }
81
+
82
+ // --- Service ---
83
+
84
+ export class ProfileAggregationService {
85
+ private static readonly TABLE_NAME: string = AnalyticsTableName.ProfileSample;
86
+ private static readonly DEFAULT_FUNCTION_LIST_LIMIT: number = 50;
87
+ private static readonly MAX_SAMPLE_FETCH: number = 50000;
88
+
89
+ /**
90
+ * Build a flamegraph tree from ProfileSample records.
91
+ *
92
+ * Each sample has a `stacktrace` array where each element follows the
93
+ * format "functionName@fileName:lineNumber". The array is ordered
94
+ * bottom-up (index 0 = root, last index = leaf).
95
+ *
96
+ * We aggregate samples that share common stack prefixes into a tree of
97
+ * ProfileFlamegraphNode objects.
98
+ */
99
+ @CaptureSpan()
100
+ public static async getFlamegraph(
101
+ request: FlamegraphRequest,
102
+ ): Promise<ProfileFlamegraphNode> {
103
+ const statement: Statement =
104
+ ProfileAggregationService.buildFlamegraphQuery(request);
105
+
106
+ const dbResult: Results =
107
+ await ProfileSampleDatabaseService.executeQuery(statement);
108
+ const response: DbJSONResponse = await dbResult.json<{
109
+ data?: Array<JSONObject>;
110
+ }>();
111
+
112
+ const rows: Array<JSONObject> = response.data || [];
113
+
114
+ // Build the tree from samples
115
+ const root: ProfileFlamegraphNode = {
116
+ functionName: "(root)",
117
+ fileName: "",
118
+ lineNumber: 0,
119
+ selfValue: 0,
120
+ totalValue: 0,
121
+ children: [],
122
+ frameType: "",
123
+ };
124
+
125
+ for (const row of rows) {
126
+ const stacktrace: Array<string> =
127
+ (row["stacktrace"] as Array<string>) || [];
128
+ const frameTypes: Array<string> =
129
+ (row["frameTypes"] as Array<string>) || [];
130
+ const value: number = Number(row["value"] || 0);
131
+
132
+ if (stacktrace.length === 0) {
133
+ continue;
134
+ }
135
+
136
+ // Walk down the tree, creating nodes as needed
137
+ let currentNode: ProfileFlamegraphNode = root;
138
+ currentNode.totalValue += value;
139
+
140
+ for (let i: number = 0; i < stacktrace.length; i++) {
141
+ const frame: ParsedFrame = ProfileAggregationService.parseFrame(
142
+ stacktrace[i]!,
143
+ );
144
+ const frameType: string = frameTypes[i] || "";
145
+
146
+ // Find or create child
147
+ let childNode: ProfileFlamegraphNode | undefined =
148
+ currentNode.children.find((child: ProfileFlamegraphNode): boolean => {
149
+ return (
150
+ child.functionName === frame.functionName &&
151
+ child.fileName === frame.fileName &&
152
+ child.lineNumber === frame.lineNumber
153
+ );
154
+ });
155
+
156
+ if (!childNode) {
157
+ childNode = {
158
+ functionName: frame.functionName,
159
+ fileName: frame.fileName,
160
+ lineNumber: frame.lineNumber,
161
+ selfValue: 0,
162
+ totalValue: 0,
163
+ children: [],
164
+ frameType: frameType,
165
+ };
166
+ currentNode.children.push(childNode);
167
+ }
168
+
169
+ childNode.totalValue += value;
170
+
171
+ // If this is the leaf frame, add to selfValue
172
+ if (i === stacktrace.length - 1) {
173
+ childNode.selfValue += value;
174
+ }
175
+
176
+ currentNode = childNode;
177
+ }
178
+ }
179
+
180
+ return root;
181
+ }
182
+
183
+ /**
184
+ * Return the top functions aggregated across samples, sorted by the
185
+ * requested metric (selfValue, totalValue, or sampleCount).
186
+ */
187
+ @CaptureSpan()
188
+ public static async getFunctionList(
189
+ request: FunctionListRequest,
190
+ ): Promise<Array<FunctionListItem>> {
191
+ const statement: Statement =
192
+ ProfileAggregationService.buildFunctionListQuery(request);
193
+
194
+ const dbResult: Results =
195
+ await ProfileSampleDatabaseService.executeQuery(statement);
196
+ const response: DbJSONResponse = await dbResult.json<{
197
+ data?: Array<JSONObject>;
198
+ }>();
199
+
200
+ const rows: Array<JSONObject> = response.data || [];
201
+
202
+ // Aggregate per-function stats in-memory from the raw samples
203
+ const functionMap: Map<
204
+ string,
205
+ {
206
+ functionName: string;
207
+ fileName: string;
208
+ selfValue: number;
209
+ totalValue: number;
210
+ sampleCount: number;
211
+ frameType: string;
212
+ }
213
+ > = new Map();
214
+
215
+ for (const row of rows) {
216
+ const stacktrace: Array<string> =
217
+ (row["stacktrace"] as Array<string>) || [];
218
+ const frameTypes: Array<string> =
219
+ (row["frameTypes"] as Array<string>) || [];
220
+ const value: number = Number(row["value"] || 0);
221
+
222
+ if (stacktrace.length === 0) {
223
+ continue;
224
+ }
225
+
226
+ const seenInThisSample: Set<string> = new Set();
227
+
228
+ for (let i: number = 0; i < stacktrace.length; i++) {
229
+ const frame: ParsedFrame = ProfileAggregationService.parseFrame(
230
+ stacktrace[i]!,
231
+ );
232
+ const frameType: string = frameTypes[i] || "";
233
+ const key: string = `${frame.functionName}@${frame.fileName}:${frame.lineNumber}`;
234
+ const isLeaf: boolean = i === stacktrace.length - 1;
235
+
236
+ let entry: FunctionListItem | undefined = functionMap.get(key);
237
+
238
+ if (!entry) {
239
+ entry = {
240
+ functionName: frame.functionName,
241
+ fileName: frame.fileName,
242
+ selfValue: 0,
243
+ totalValue: 0,
244
+ sampleCount: 0,
245
+ frameType: frameType,
246
+ };
247
+ functionMap.set(key, entry);
248
+ }
249
+
250
+ // totalValue: count the value once per unique function per sample
251
+ if (!seenInThisSample.has(key)) {
252
+ entry.totalValue += value;
253
+ entry.sampleCount += 1;
254
+ seenInThisSample.add(key);
255
+ }
256
+
257
+ // selfValue: only the leaf frame
258
+ if (isLeaf) {
259
+ entry.selfValue += value;
260
+ }
261
+ }
262
+ }
263
+
264
+ // Sort
265
+ const sortBy: string = request.sortBy || "selfValue";
266
+ const items: Array<FunctionListItem> = Array.from(functionMap.values());
267
+
268
+ items.sort((a: FunctionListItem, b: FunctionListItem) => {
269
+ if (sortBy === "totalValue") {
270
+ return b.totalValue - a.totalValue;
271
+ }
272
+
273
+ if (sortBy === "sampleCount") {
274
+ return b.sampleCount - a.sampleCount;
275
+ }
276
+
277
+ return b.selfValue - a.selfValue;
278
+ });
279
+
280
+ const limit: number =
281
+ request.limit ?? ProfileAggregationService.DEFAULT_FUNCTION_LIST_LIMIT;
282
+
283
+ return items.slice(0, limit);
284
+ }
285
+
286
+ /**
287
+ * Build a diff flamegraph comparing two time ranges.
288
+ * Returns a tree where each node has baseline/comparison values and deltas.
289
+ */
290
+ @CaptureSpan()
291
+ public static async getDiffFlamegraph(
292
+ request: DiffFlamegraphRequest,
293
+ ): Promise<DiffFlamegraphNode> {
294
+ const baselineTree: ProfileFlamegraphNode =
295
+ await ProfileAggregationService.getFlamegraph({
296
+ projectId: request.projectId,
297
+ startTime: request.baselineStartTime,
298
+ endTime: request.baselineEndTime,
299
+ ...(request.serviceIds !== undefined && {
300
+ serviceIds: request.serviceIds,
301
+ }),
302
+ ...(request.profileType !== undefined && {
303
+ profileType: request.profileType,
304
+ }),
305
+ });
306
+
307
+ const comparisonTree: ProfileFlamegraphNode =
308
+ await ProfileAggregationService.getFlamegraph({
309
+ projectId: request.projectId,
310
+ startTime: request.comparisonStartTime,
311
+ endTime: request.comparisonEndTime,
312
+ ...(request.serviceIds !== undefined && {
313
+ serviceIds: request.serviceIds,
314
+ }),
315
+ ...(request.profileType !== undefined && {
316
+ profileType: request.profileType,
317
+ }),
318
+ });
319
+
320
+ return ProfileAggregationService.mergeDiffTrees(
321
+ baselineTree,
322
+ comparisonTree,
323
+ );
324
+ }
325
+
326
+ private static mergeDiffTrees(
327
+ baseline: ProfileFlamegraphNode | null,
328
+ comparison: ProfileFlamegraphNode | null,
329
+ ): DiffFlamegraphNode {
330
+ const baselineValue: number = baseline?.totalValue || 0;
331
+ const comparisonValue: number = comparison?.totalValue || 0;
332
+ const delta: number = comparisonValue - baselineValue;
333
+ const deltaPercent: number =
334
+ baselineValue > 0
335
+ ? (delta / baselineValue) * 100
336
+ : comparisonValue > 0
337
+ ? 100
338
+ : 0;
339
+
340
+ const node: DiffFlamegraphNode = {
341
+ functionName:
342
+ baseline?.functionName || comparison?.functionName || "(root)",
343
+ fileName: baseline?.fileName || comparison?.fileName || "",
344
+ lineNumber: baseline?.lineNumber || comparison?.lineNumber || 0,
345
+ baselineValue,
346
+ comparisonValue,
347
+ delta,
348
+ deltaPercent,
349
+ selfBaselineValue: baseline?.selfValue || 0,
350
+ selfComparisonValue: comparison?.selfValue || 0,
351
+ selfDelta: (comparison?.selfValue || 0) - (baseline?.selfValue || 0),
352
+ children: [],
353
+ frameType: baseline?.frameType || comparison?.frameType || "",
354
+ };
355
+
356
+ // Merge children by matching on functionName + fileName + lineNumber
357
+ const baselineChildren: Map<string, ProfileFlamegraphNode> = new Map();
358
+ const comparisonChildren: Map<string, ProfileFlamegraphNode> = new Map();
359
+
360
+ if (baseline) {
361
+ for (const child of baseline.children) {
362
+ const key: string = `${child.functionName}@${child.fileName}:${child.lineNumber}`;
363
+ baselineChildren.set(key, child);
364
+ }
365
+ }
366
+
367
+ if (comparison) {
368
+ for (const child of comparison.children) {
369
+ const key: string = `${child.functionName}@${child.fileName}:${child.lineNumber}`;
370
+ comparisonChildren.set(key, child);
371
+ }
372
+ }
373
+
374
+ // All unique child keys
375
+ const allKeys: Set<string> = new Set([
376
+ ...baselineChildren.keys(),
377
+ ...comparisonChildren.keys(),
378
+ ]);
379
+
380
+ for (const key of allKeys) {
381
+ const baselineChild: ProfileFlamegraphNode | null =
382
+ baselineChildren.get(key) || null;
383
+ const comparisonChild: ProfileFlamegraphNode | null =
384
+ comparisonChildren.get(key) || null;
385
+
386
+ node.children.push(
387
+ ProfileAggregationService.mergeDiffTrees(
388
+ baselineChild,
389
+ comparisonChild,
390
+ ),
391
+ );
392
+ }
393
+
394
+ // Sort children by comparison value descending
395
+ node.children.sort((a: DiffFlamegraphNode, b: DiffFlamegraphNode) => {
396
+ return b.comparisonValue - a.comparisonValue;
397
+ });
398
+
399
+ return node;
400
+ }
401
+
402
+ // --- Query builders ---
403
+
404
+ private static buildFlamegraphQuery(request: FlamegraphRequest): Statement {
405
+ const statement: Statement = SQL`
406
+ SELECT
407
+ stacktrace,
408
+ frameTypes,
409
+ value
410
+ FROM ${ProfileAggregationService.TABLE_NAME}
411
+ WHERE projectId = ${{
412
+ type: TableColumnType.ObjectID,
413
+ value: request.projectId,
414
+ }}
415
+ `;
416
+
417
+ if (request.profileId) {
418
+ statement.append(
419
+ SQL` AND profileId = ${{
420
+ type: TableColumnType.Text,
421
+ value: request.profileId,
422
+ }}`,
423
+ );
424
+ }
425
+
426
+ if (request.startTime) {
427
+ statement.append(
428
+ SQL` AND time >= ${{
429
+ type: TableColumnType.Date,
430
+ value: request.startTime,
431
+ }}`,
432
+ );
433
+ }
434
+
435
+ if (request.endTime) {
436
+ statement.append(
437
+ SQL` AND time <= ${{
438
+ type: TableColumnType.Date,
439
+ value: request.endTime,
440
+ }}`,
441
+ );
442
+ }
443
+
444
+ ProfileAggregationService.appendCommonFilters(statement, request);
445
+
446
+ statement.append(
447
+ SQL` LIMIT ${{
448
+ type: TableColumnType.Number,
449
+ value: ProfileAggregationService.MAX_SAMPLE_FETCH,
450
+ }}`,
451
+ );
452
+
453
+ return statement;
454
+ }
455
+
456
+ private static buildFunctionListQuery(
457
+ request: FunctionListRequest,
458
+ ): Statement {
459
+ const statement: Statement = SQL`
460
+ SELECT
461
+ stacktrace,
462
+ frameTypes,
463
+ value
464
+ FROM ${ProfileAggregationService.TABLE_NAME}
465
+ WHERE projectId = ${{
466
+ type: TableColumnType.ObjectID,
467
+ value: request.projectId,
468
+ }}
469
+ AND time >= ${{
470
+ type: TableColumnType.Date,
471
+ value: request.startTime,
472
+ }}
473
+ AND time <= ${{
474
+ type: TableColumnType.Date,
475
+ value: request.endTime,
476
+ }}
477
+ `;
478
+
479
+ ProfileAggregationService.appendCommonFilters(statement, request);
480
+
481
+ statement.append(
482
+ SQL` LIMIT ${{
483
+ type: TableColumnType.Number,
484
+ value: ProfileAggregationService.MAX_SAMPLE_FETCH,
485
+ }}`,
486
+ );
487
+
488
+ return statement;
489
+ }
490
+
491
+ private static appendCommonFilters(
492
+ statement: Statement,
493
+ request: Pick<FlamegraphRequest, "serviceIds" | "profileType">,
494
+ ): void {
495
+ if (request.serviceIds && request.serviceIds.length > 0) {
496
+ statement.append(
497
+ SQL` AND serviceId IN (${{
498
+ type: TableColumnType.ObjectID,
499
+ value: new Includes(
500
+ request.serviceIds.map((id: ObjectID) => {
501
+ return id.toString();
502
+ }),
503
+ ),
504
+ }})`,
505
+ );
506
+ }
507
+
508
+ if (request.profileType) {
509
+ statement.append(
510
+ SQL` AND profileType = ${{
511
+ type: TableColumnType.Text,
512
+ value: request.profileType,
513
+ }}`,
514
+ );
515
+ }
516
+ }
517
+
518
+ /**
519
+ * Parse a frame string in the format "functionName@fileName:lineNumber".
520
+ * Falls back gracefully if the format is unexpected.
521
+ */
522
+ private static parseFrame(frame: string): ParsedFrame {
523
+ // Expected format: "functionName@fileName:lineNumber"
524
+ const atIndex: number = frame.indexOf("@");
525
+
526
+ if (atIndex === -1) {
527
+ return {
528
+ functionName: frame,
529
+ fileName: "",
530
+ lineNumber: 0,
531
+ };
532
+ }
533
+
534
+ const functionName: string = frame.substring(0, atIndex);
535
+ const rest: string = frame.substring(atIndex + 1);
536
+
537
+ const lastColonIndex: number = rest.lastIndexOf(":");
538
+
539
+ if (lastColonIndex === -1) {
540
+ return {
541
+ functionName,
542
+ fileName: rest,
543
+ lineNumber: 0,
544
+ };
545
+ }
546
+
547
+ const fileName: string = rest.substring(0, lastColonIndex);
548
+ const lineNumberStr: string = rest.substring(lastColonIndex + 1);
549
+ const lineNumber: number = parseInt(lineNumberStr, 10) || 0;
550
+
551
+ return {
552
+ functionName,
553
+ fileName,
554
+ lineNumber,
555
+ };
556
+ }
557
+ }
558
+
559
+ export default ProfileAggregationService;
@@ -0,0 +1,11 @@
1
+ import ClickhouseDatabase from "../Infrastructure/ClickhouseDatabase";
2
+ import AnalyticsDatabaseService from "./AnalyticsDatabaseService";
3
+ import ProfileSample from "../../Models/AnalyticsModels/ProfileSample";
4
+
5
+ export class ProfileSampleService extends AnalyticsDatabaseService<ProfileSample> {
6
+ public constructor(clickhouseDatabase?: ClickhouseDatabase | undefined) {
7
+ super({ modelType: ProfileSample, database: clickhouseDatabase });
8
+ }
9
+ }
10
+
11
+ export default new ProfileSampleService();
@@ -0,0 +1,11 @@
1
+ import ClickhouseDatabase from "../Infrastructure/ClickhouseDatabase";
2
+ import AnalyticsDatabaseService from "./AnalyticsDatabaseService";
3
+ import Profile from "../../Models/AnalyticsModels/Profile";
4
+
5
+ export class ProfileService extends AnalyticsDatabaseService<Profile> {
6
+ public constructor(clickhouseDatabase?: ClickhouseDatabase | undefined) {
7
+ super({ modelType: Profile, database: clickhouseDatabase });
8
+ }
9
+ }
10
+
11
+ export default new ProfileService();