@oneuptime/common 7.0.2990 → 7.0.3010

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 (197) hide show
  1. package/Models/AnalyticsModels/ExceptionInstance.ts +488 -0
  2. package/Models/AnalyticsModels/Index.ts +2 -0
  3. package/Models/AnalyticsModels/Span.ts +2 -2
  4. package/Models/DatabaseModels/Index.ts +4 -0
  5. package/Models/DatabaseModels/TelemetryException.ts +978 -0
  6. package/Server/API/StatusAPI.ts +63 -51
  7. package/Server/EnvironmentConfig.ts +3 -0
  8. package/Server/Infrastructure/Postgres/SchemaMigrations/1724610006927-MigrationName.ts +93 -0
  9. package/Server/Infrastructure/Postgres/SchemaMigrations/1724613666632-MigrationName.ts +60 -0
  10. package/Server/Infrastructure/Postgres/SchemaMigrations/1724659071843-MigrationName.ts +17 -0
  11. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +6 -0
  12. package/Server/Infrastructure/Queue.ts +36 -1
  13. package/Server/Infrastructure/QueueWorker.ts +2 -2
  14. package/Server/Services/DatabaseService.ts +4 -5
  15. package/Server/Services/ExceptionInstanceService.ts +11 -0
  16. package/Server/Services/Index.ts +5 -0
  17. package/Server/Services/StatusPageDomainService.ts +118 -59
  18. package/Server/Services/TelemetryExceptionService.ts +10 -0
  19. package/Server/Types/Database/Permissions/Index.ts +1 -1
  20. package/Server/Types/Database/UpdateByID.ts +1 -1
  21. package/Server/Utils/Greenlock/Greenlock.ts +331 -204
  22. package/Server/Utils/Logger.ts +8 -2
  23. package/Server/Utils/Telemetry.ts +109 -25
  24. package/Types/Code/CodeType.ts +1 -0
  25. package/Types/Database/PartialEntity.ts +14 -1
  26. package/Types/Date.ts +9 -1
  27. package/Types/Icon/IconProp.ts +2 -0
  28. package/Types/Permission.ts +39 -0
  29. package/UI/Components/ActionCard/ActionCard.tsx +66 -0
  30. package/UI/Components/Alerts/Alert.tsx +69 -60
  31. package/UI/Components/Card/Card.tsx +1 -0
  32. package/UI/Components/Charts/ChartGroup/ChartGroup.tsx +4 -17
  33. package/UI/Components/Charts/ChartLibrary/LineChart/LineChart.tsx +1005 -0
  34. package/UI/Components/Charts/ChartLibrary/Types/ChartDataPoint.ts +3 -0
  35. package/UI/Components/Charts/ChartLibrary/Utils/ChartColors.ts +117 -0
  36. package/UI/Components/Charts/ChartLibrary/Utils/Cx.ts +8 -0
  37. package/UI/Components/Charts/ChartLibrary/Utils/GetYAxisDomain.ts +15 -0
  38. package/UI/Components/Charts/ChartLibrary/Utils/HasOnlyOneValueForKey.ts +19 -0
  39. package/UI/Components/Charts/ChartLibrary/Utils/UseWindowOnResize.ts +17 -0
  40. package/UI/Components/Charts/Line/LineChart.tsx +58 -225
  41. package/UI/Components/Charts/Types/ChartCurve.ts +7 -0
  42. package/UI/Components/Charts/Types/DataPoint.ts +7 -0
  43. package/UI/Components/Charts/Types/SeriesPoint.ts +7 -0
  44. package/UI/Components/Charts/Types/SeriesPoints.ts +6 -0
  45. package/UI/Components/Charts/Types/XAxis/XAxis.ts +21 -0
  46. package/UI/Components/Charts/Types/XAxis/XAxisMaxMin.ts +3 -0
  47. package/UI/Components/Charts/Types/XAxis/XAxisPrecision.ts +26 -0
  48. package/UI/Components/Charts/Types/XAxis/XAxisType.ts +6 -0
  49. package/UI/Components/Charts/Types/XValue.ts +3 -0
  50. package/UI/Components/Charts/Types/YAxis/YAxis.ts +22 -0
  51. package/UI/Components/Charts/Types/YAxis/YAxisMaxMin.ts +3 -0
  52. package/UI/Components/Charts/Types/YAxis/YAxisType.ts +5 -0
  53. package/UI/Components/Charts/Types/YValue.ts +3 -0
  54. package/UI/Components/Charts/Utils/DataPoint.ts +188 -0
  55. package/UI/Components/Charts/Utils/XAxis.ts +267 -0
  56. package/UI/Components/Detail/Detail.tsx +6 -1
  57. package/UI/Components/GanttChart/Row/Row.tsx +4 -2
  58. package/UI/Components/GanttChart/Row/RowLabel.tsx +7 -3
  59. package/UI/Components/Icon/Icon.tsx +16 -0
  60. package/UI/Components/LogsViewer/LogsViewer.tsx +1 -1
  61. package/UI/Components/Types/FieldType.ts +1 -0
  62. package/UI/Config.ts +2 -0
  63. package/UI/Utils/Telemetry.ts +7 -2
  64. package/Utils/Crypto.ts +11 -0
  65. package/build/dist/Models/AnalyticsModels/ExceptionInstance.js +445 -0
  66. package/build/dist/Models/AnalyticsModels/ExceptionInstance.js.map +1 -0
  67. package/build/dist/Models/AnalyticsModels/Index.js +2 -0
  68. package/build/dist/Models/AnalyticsModels/Index.js.map +1 -1
  69. package/build/dist/Models/AnalyticsModels/Span.js +2 -2
  70. package/build/dist/Models/DatabaseModels/Index.js +2 -0
  71. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  72. package/build/dist/Models/DatabaseModels/TelemetryException.js +1010 -0
  73. package/build/dist/Models/DatabaseModels/TelemetryException.js.map +1 -0
  74. package/build/dist/Server/API/StatusAPI.js +52 -44
  75. package/build/dist/Server/API/StatusAPI.js.map +1 -1
  76. package/build/dist/Server/EnvironmentConfig.js +1 -0
  77. package/build/dist/Server/EnvironmentConfig.js.map +1 -1
  78. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724610006927-MigrationName.js +38 -0
  79. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724610006927-MigrationName.js.map +1 -0
  80. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724613666632-MigrationName.js +26 -0
  81. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724613666632-MigrationName.js.map +1 -0
  82. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724659071843-MigrationName.js +12 -0
  83. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724659071843-MigrationName.js.map +1 -0
  84. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +6 -0
  85. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  86. package/build/dist/Server/Infrastructure/Queue.js +20 -1
  87. package/build/dist/Server/Infrastructure/Queue.js.map +1 -1
  88. package/build/dist/Server/Infrastructure/QueueWorker.js +2 -2
  89. package/build/dist/Server/Infrastructure/QueueWorker.js.map +1 -1
  90. package/build/dist/Server/Services/DatabaseService.js.map +1 -1
  91. package/build/dist/Server/Services/ExceptionInstanceService.js +9 -0
  92. package/build/dist/Server/Services/ExceptionInstanceService.js.map +1 -0
  93. package/build/dist/Server/Services/Index.js +4 -0
  94. package/build/dist/Server/Services/Index.js.map +1 -1
  95. package/build/dist/Server/Services/StatusPageDomainService.js +101 -53
  96. package/build/dist/Server/Services/StatusPageDomainService.js.map +1 -1
  97. package/build/dist/Server/Services/TelemetryExceptionService.js +9 -0
  98. package/build/dist/Server/Services/TelemetryExceptionService.js.map +1 -0
  99. package/build/dist/Server/Types/Database/Permissions/Index.js.map +1 -1
  100. package/build/dist/Server/Utils/Greenlock/Greenlock.js +234 -157
  101. package/build/dist/Server/Utils/Greenlock/Greenlock.js.map +1 -1
  102. package/build/dist/Server/Utils/Logger.js +5 -1
  103. package/build/dist/Server/Utils/Logger.js.map +1 -1
  104. package/build/dist/Server/Utils/Telemetry.js +63 -22
  105. package/build/dist/Server/Utils/Telemetry.js.map +1 -1
  106. package/build/dist/Types/Code/CodeType.js +1 -0
  107. package/build/dist/Types/Code/CodeType.js.map +1 -1
  108. package/build/dist/Types/Database/PartialEntity.js +3 -0
  109. package/build/dist/Types/Database/PartialEntity.js.map +1 -1
  110. package/build/dist/Types/Date.js +7 -1
  111. package/build/dist/Types/Date.js.map +1 -1
  112. package/build/dist/Types/Icon/IconProp.js +2 -0
  113. package/build/dist/Types/Icon/IconProp.js.map +1 -1
  114. package/build/dist/Types/Permission.js +33 -0
  115. package/build/dist/Types/Permission.js.map +1 -1
  116. package/build/dist/UI/Components/ActionCard/ActionCard.js +27 -0
  117. package/build/dist/UI/Components/ActionCard/ActionCard.js.map +1 -0
  118. package/build/dist/UI/Components/Alerts/Alert.js +36 -45
  119. package/build/dist/UI/Components/Alerts/Alert.js.map +1 -1
  120. package/build/dist/UI/Components/Card/Card.js +1 -1
  121. package/build/dist/UI/Components/Card/Card.js.map +1 -1
  122. package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js +4 -9
  123. package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js.map +1 -1
  124. package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js +388 -0
  125. package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js.map +1 -0
  126. package/build/dist/UI/Components/Charts/ChartLibrary/Types/ChartDataPoint.js +2 -0
  127. package/build/dist/UI/Components/Charts/ChartLibrary/Types/ChartDataPoint.js.map +1 -0
  128. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/ChartColors.js +88 -0
  129. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/ChartColors.js.map +1 -0
  130. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/Cx.js +7 -0
  131. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/Cx.js.map +1 -0
  132. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/GetYAxisDomain.js +7 -0
  133. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/GetYAxisDomain.js.map +1 -0
  134. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/HasOnlyOneValueForKey.js +14 -0
  135. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/HasOnlyOneValueForKey.js.map +1 -0
  136. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/UseWindowOnResize.js +14 -0
  137. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/UseWindowOnResize.js.map +1 -0
  138. package/build/dist/UI/Components/Charts/Line/LineChart.js +30 -136
  139. package/build/dist/UI/Components/Charts/Line/LineChart.js.map +1 -1
  140. package/build/dist/UI/Components/Charts/Types/ChartCurve.js +8 -0
  141. package/build/dist/UI/Components/Charts/Types/ChartCurve.js.map +1 -0
  142. package/build/dist/UI/Components/Charts/Types/DataPoint.js +2 -0
  143. package/build/dist/UI/Components/Charts/Types/DataPoint.js.map +1 -0
  144. package/build/dist/UI/Components/Charts/Types/SeriesPoint.js +2 -0
  145. package/build/dist/UI/Components/Charts/Types/SeriesPoint.js.map +1 -0
  146. package/build/dist/UI/Components/Charts/Types/SeriesPoints.js +2 -0
  147. package/build/dist/UI/Components/Charts/Types/SeriesPoints.js.map +1 -0
  148. package/build/dist/UI/Components/Charts/Types/XAxis/XAxis.js +8 -0
  149. package/build/dist/UI/Components/Charts/Types/XAxis/XAxis.js.map +1 -0
  150. package/build/dist/UI/Components/Charts/Types/XAxis/XAxisMaxMin.js +2 -0
  151. package/build/dist/UI/Components/Charts/Types/XAxis/XAxisMaxMin.js.map +1 -0
  152. package/build/dist/UI/Components/Charts/Types/XAxis/XAxisPrecision.js +27 -0
  153. package/build/dist/UI/Components/Charts/Types/XAxis/XAxisPrecision.js.map +1 -0
  154. package/build/dist/UI/Components/Charts/Types/XAxis/XAxisType.js +7 -0
  155. package/build/dist/UI/Components/Charts/Types/XAxis/XAxisType.js.map +1 -0
  156. package/build/dist/UI/Components/Charts/Types/XValue.js +2 -0
  157. package/build/dist/UI/Components/Charts/Types/XValue.js.map +1 -0
  158. package/build/dist/UI/Components/Charts/Types/YAxis/YAxis.js +8 -0
  159. package/build/dist/UI/Components/Charts/Types/YAxis/YAxis.js.map +1 -0
  160. package/build/dist/UI/Components/Charts/Types/YAxis/YAxisMaxMin.js +2 -0
  161. package/build/dist/UI/Components/Charts/Types/YAxis/YAxisMaxMin.js.map +1 -0
  162. package/build/dist/UI/Components/Charts/Types/YAxis/YAxisType.js +6 -0
  163. package/build/dist/UI/Components/Charts/Types/YAxis/YAxisType.js.map +1 -0
  164. package/build/dist/UI/Components/Charts/Types/YValue.js +2 -0
  165. package/build/dist/UI/Components/Charts/Types/YValue.js.map +1 -0
  166. package/build/dist/UI/Components/Charts/Utils/DataPoint.js +109 -0
  167. package/build/dist/UI/Components/Charts/Utils/DataPoint.js.map +1 -0
  168. package/build/dist/UI/Components/Charts/Utils/XAxis.js +241 -0
  169. package/build/dist/UI/Components/Charts/Utils/XAxis.js.map +1 -0
  170. package/build/dist/UI/Components/Detail/Detail.js +5 -1
  171. package/build/dist/UI/Components/Detail/Detail.js.map +1 -1
  172. package/build/dist/UI/Components/GanttChart/Row/Row.js +2 -2
  173. package/build/dist/UI/Components/GanttChart/Row/Row.js.map +1 -1
  174. package/build/dist/UI/Components/GanttChart/Row/RowLabel.js +3 -3
  175. package/build/dist/UI/Components/GanttChart/Row/RowLabel.js.map +1 -1
  176. package/build/dist/UI/Components/Icon/Icon.js +6 -0
  177. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  178. package/build/dist/UI/Components/LogsViewer/LogsViewer.js +1 -1
  179. package/build/dist/UI/Components/LogsViewer/LogsViewer.js.map +1 -1
  180. package/build/dist/UI/Components/Types/FieldType.js +1 -0
  181. package/build/dist/UI/Components/Types/FieldType.js.map +1 -1
  182. package/build/dist/UI/Config.js +1 -0
  183. package/build/dist/UI/Config.js.map +1 -1
  184. package/build/dist/UI/Utils/Telemetry.js +6 -3
  185. package/build/dist/UI/Utils/Telemetry.js.map +1 -1
  186. package/build/dist/Utils/Crypto.js +10 -0
  187. package/build/dist/Utils/Crypto.js.map +1 -0
  188. package/package.json +15 -13
  189. package/UI/Components/Charts/Bar/Bar.tsx +0 -0
  190. package/UI/Components/Charts/Base/BaseChart.tsx +0 -0
  191. package/UI/Components/Charts/Tooltip/Tooltip.tsx +0 -84
  192. package/build/dist/UI/Components/Charts/Bar/Bar.js +0 -2
  193. package/build/dist/UI/Components/Charts/Bar/Bar.js.map +0 -1
  194. package/build/dist/UI/Components/Charts/Base/BaseChart.js +0 -2
  195. package/build/dist/UI/Components/Charts/Base/BaseChart.js.map +0 -1
  196. package/build/dist/UI/Components/Charts/Tooltip/Tooltip.js +0 -34
  197. package/build/dist/UI/Components/Charts/Tooltip/Tooltip.js.map +0 -1
@@ -1,4 +1,9 @@
1
- import OpenTelemetryAPI, { Meter } from "@opentelemetry/api";
1
+ import OpenTelemetryAPI, {
2
+ // diag,
3
+ // DiagConsoleLogger,
4
+ // DiagLogLevel,
5
+ Meter,
6
+ } from "@opentelemetry/api";
2
7
  import { Logger, logs } from "@opentelemetry/api-logs";
3
8
  import {
4
9
  Counter,
@@ -13,7 +18,10 @@ import { CompressionAlgorithm } from "@opentelemetry/otlp-exporter-base";
13
18
  import { Resource } from "@opentelemetry/resources";
14
19
  import {
15
20
  BatchLogRecordProcessor,
21
+ ConsoleLogRecordExporter,
16
22
  LoggerProvider,
23
+ LogRecordProcessor,
24
+ SimpleLogRecordProcessor,
17
25
  } from "@opentelemetry/sdk-logs";
18
26
  import {
19
27
  MeterProvider,
@@ -21,18 +29,37 @@ import {
21
29
  } from "@opentelemetry/sdk-metrics";
22
30
  import * as opentelemetry from "@opentelemetry/sdk-node";
23
31
  import { SpanExporter } from "@opentelemetry/sdk-trace-node";
24
- import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions";
32
+ import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
25
33
  import URL from "Common/Types/API/URL";
26
34
  import Dictionary from "Common/Types/Dictionary";
35
+ import { DisableTelemetry } from "../EnvironmentConfig";
36
+ import logger from "./Logger";
27
37
 
28
38
  // Enable this line to see debug logs
29
39
  // diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
30
40
 
41
+ export type Span = opentelemetry.api.Span;
42
+ export type SpanStatus = opentelemetry.api.SpanStatus;
43
+ export type SpanException = opentelemetry.api.Exception;
44
+ export type SpanOptions = opentelemetry.api.SpanOptions;
45
+ export type TelemetryLogger = Logger;
46
+ export type TelemetryAttributes = opentelemetry.api.Attributes;
47
+ export type TelemetryCounter = Counter<opentelemetry.api.Attributes>;
48
+
49
+ export enum SpanStatusCode {
50
+ UNSET = 0,
51
+ OK = 1,
52
+ ERROR = 2,
53
+ }
54
+
31
55
  export default class Telemetry {
32
56
  public static sdk: opentelemetry.NodeSDK | null = null;
33
57
  public static logger: Logger | null = null;
34
58
  public static meter: Meter | null = null;
35
59
  public static meterProvider: MeterProvider | null = null;
60
+ public static loggerProvider: LoggerProvider | null = null;
61
+ public static metricReader: PeriodicExportingMetricReader | undefined;
62
+ public static serviceName: string | null = null;
36
63
 
37
64
  public static getHeaders(): Dictionary<string> {
38
65
  if (!process.env["OPENTELEMETRY_EXPORTER_OTLP_HEADERS"]) {
@@ -96,11 +123,19 @@ export default class Telemetry {
96
123
 
97
124
  public static getResource(data: { serviceName: string }): Resource {
98
125
  return new Resource({
99
- [SemanticResourceAttributes.SERVICE_NAME]: data.serviceName,
126
+ [ATTR_SERVICE_NAME]: data.serviceName,
100
127
  });
101
128
  }
102
129
 
103
- public static init(data: { serviceName: string }): opentelemetry.NodeSDK {
130
+ public static init(data: {
131
+ serviceName: string;
132
+ }): opentelemetry.NodeSDK | null {
133
+ this.serviceName = data.serviceName;
134
+
135
+ if (DisableTelemetry) {
136
+ return null;
137
+ }
138
+
104
139
  if (!this.sdk) {
105
140
  const headers: Dictionary<string> = this.getHeaders();
106
141
 
@@ -108,8 +143,6 @@ export default class Telemetry {
108
143
 
109
144
  let traceExporter: SpanExporter | undefined = undefined;
110
145
 
111
- let metricReader: PeriodicExportingMetricReader | undefined = undefined;
112
-
113
146
  if (this.getOltpTracesEndpoint() && hasHeaders) {
114
147
  traceExporter = new OTLPTraceExporter({
115
148
  url: this.getOltpTracesEndpoint()!.toString(),
@@ -119,7 +152,7 @@ export default class Telemetry {
119
152
  }
120
153
 
121
154
  if (this.getOltpMetricsEndpoint() && hasHeaders) {
122
- metricReader = new PeriodicExportingMetricReader({
155
+ this.metricReader = new PeriodicExportingMetricReader({
123
156
  exporter: new OTLPMetricExporter({
124
157
  url: this.getOltpMetricsEndpoint()!.toString(),
125
158
  headers: headers,
@@ -128,12 +161,16 @@ export default class Telemetry {
128
161
  });
129
162
  }
130
163
 
131
- const loggerProvider: LoggerProvider = new LoggerProvider({
164
+ this.loggerProvider = new LoggerProvider({
132
165
  resource: this.getResource({
133
166
  serviceName: data.serviceName,
134
167
  }),
135
168
  });
136
169
 
170
+ let logRecordProcessor: LogRecordProcessor = new SimpleLogRecordProcessor(
171
+ new ConsoleLogRecordExporter(),
172
+ );
173
+
137
174
  if (this.getOltpLogsEndpoint() && hasHeaders) {
138
175
  const logExporter: OTLPLogExporter = new OTLPLogExporter({
139
176
  url: this.getOltpLogsEndpoint()!.toString(),
@@ -141,39 +178,43 @@ export default class Telemetry {
141
178
  compression: CompressionAlgorithm.GZIP,
142
179
  });
143
180
 
144
- loggerProvider.addLogRecordProcessor(
145
- new BatchLogRecordProcessor(logExporter),
146
- );
181
+ logRecordProcessor = new BatchLogRecordProcessor(logExporter);
147
182
  }
148
183
 
149
- logs.setGlobalLoggerProvider(loggerProvider);
184
+ this.loggerProvider.addLogRecordProcessor(logRecordProcessor);
185
+
186
+ logs.setGlobalLoggerProvider(this.loggerProvider);
150
187
 
151
188
  const nodeSdkConfiguration: Partial<opentelemetry.NodeSDKConfiguration> =
152
189
  {
153
190
  idGenerator: new AWSXRayIdGenerator(),
154
- instrumentations: hasHeaders
155
- ? [
156
- // Add instrumentations here
157
- ]
158
- : [],
191
+ instrumentations: [],
159
192
  resource: this.getResource({
160
193
  serviceName: data.serviceName,
161
194
  }),
162
- logRecordProcessor: loggerProvider as any,
195
+ autoDetectResources: true,
163
196
  };
164
197
 
165
198
  if (traceExporter) {
166
199
  nodeSdkConfiguration.traceExporter = traceExporter;
167
200
  }
168
201
 
169
- if (metricReader) {
170
- nodeSdkConfiguration.metricReader = metricReader as any;
202
+ // We will skip this becasue we're attachng this metric reader to the meter provider later.
203
+ // if (this.metricReader) {
204
+ // nodeSdkConfiguration.metricReader = this.metricReader;
205
+ // }
206
+
207
+ if (logRecordProcessor) {
208
+ nodeSdkConfiguration.logRecordProcessor = logRecordProcessor;
171
209
  }
172
210
 
173
211
  const sdk: opentelemetry.NodeSDK = new opentelemetry.NodeSDK(
174
212
  nodeSdkConfiguration,
175
213
  );
176
214
 
215
+ this.getMeterProvider();
216
+ this.getMeter();
217
+
177
218
  process.on("SIGTERM", () => {
178
219
  sdk.shutdown().finally(() => {
179
220
  return process.exit(0);
@@ -188,17 +229,23 @@ export default class Telemetry {
188
229
  return this.sdk;
189
230
  }
190
231
 
191
- public static getLogger(): Logger {
192
- if (!this.logger) {
193
- this.logger = logs.getLogger("default");
232
+ public static getLogger(): Logger | null {
233
+ if (!this.loggerProvider) {
234
+ return null;
194
235
  }
195
236
 
196
- return this.logger;
237
+ return this.loggerProvider.getLogger("default");
197
238
  }
198
239
 
199
240
  public static getMeterProvider(): MeterProvider {
200
241
  if (!this.meterProvider) {
201
- this.meterProvider = new MeterProvider();
242
+ this.meterProvider = new MeterProvider({
243
+ resource: this.getResource({
244
+ serviceName: this.serviceName || "default",
245
+ }),
246
+ readers: this.metricReader ? [this.metricReader] : [],
247
+ });
248
+
202
249
  OpenTelemetryAPI.metrics.setGlobalMeterProvider(this.meterProvider);
203
250
  }
204
251
 
@@ -279,4 +326,41 @@ export default class Telemetry {
279
326
 
280
327
  return histogram;
281
328
  }
329
+
330
+ public static getTracer(): opentelemetry.api.Tracer {
331
+ const tracer: opentelemetry.api.Tracer =
332
+ OpenTelemetryAPI.trace.getTracer("default");
333
+ return tracer;
334
+ }
335
+
336
+ public static startActiveSpan<T>(data: {
337
+ name: string;
338
+ options?: SpanOptions | undefined;
339
+ fn: (span: Span) => T;
340
+ }): T {
341
+ const { name } = data;
342
+
343
+ return this.getTracer().startActiveSpan(name, data.options || {}, data.fn);
344
+ }
345
+
346
+ public static recordExceptionMarkSpanAsErrorAndEndSpan(data: {
347
+ span: Span;
348
+ exception: unknown;
349
+ }): void {
350
+ const { span, exception } = data;
351
+
352
+ // log the exception as well
353
+ logger.error(exception);
354
+
355
+ span.recordException(exception as SpanException);
356
+ span.setStatus({
357
+ code: SpanStatusCode.ERROR,
358
+ });
359
+
360
+ this.endSpan(span);
361
+ }
362
+
363
+ public static endSpan(span: Span): void {
364
+ span.end();
365
+ }
282
366
  }
@@ -5,6 +5,7 @@ enum CodeType {
5
5
  JSON = "json",
6
6
  Markdown = "markdown",
7
7
  SQL = "sql",
8
+ Text = "text",
8
9
  // TODO add more mime types.
9
10
  }
10
11
 
@@ -1,3 +1,16 @@
1
- import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity";
1
+ /**
2
+ * Make all properties in T optional. Deep version.
3
+ */
4
+
5
+ type QueryDeepPartialEntity<T> = {
6
+ [P in keyof T]?:
7
+ | (T[P] extends Array<infer U>
8
+ ? Array<QueryDeepPartialEntity<U>>
9
+ : T[P] extends ReadonlyArray<infer U>
10
+ ? ReadonlyArray<QueryDeepPartialEntity<U>>
11
+ : QueryDeepPartialEntity<T[P]>)
12
+ | (() => string)
13
+ | null;
14
+ };
2
15
 
3
16
  export default QueryDeepPartialEntity;
package/Types/Date.ts CHANGED
@@ -9,10 +9,18 @@ import Timezone from "./Timezone";
9
9
  export const Moment: typeof moment = moment;
10
10
 
11
11
  export default class OneUptimeDate {
12
- public getNanoSecondsFromSeconds(seconds: number): number {
12
+ public static convertMinutesToMilliseconds(minutes: number): number {
13
+ return minutes * 60 * 1000;
14
+ }
15
+
16
+ public static getNanoSecondsFromSeconds(seconds: number): number {
13
17
  return seconds * 1000 * 1000 * 1000;
14
18
  }
15
19
 
20
+ public static now(): Date {
21
+ return this.getCurrentDate();
22
+ }
23
+
16
24
  public static getDateFromYYYYMMDD(
17
25
  year: string,
18
26
  month: string,
@@ -1,5 +1,6 @@
1
1
  enum IconProp {
2
2
  Equals = "Equals",
3
+ Archive = "Archive",
3
4
  File = "File",
4
5
  Automation = "Automation",
5
6
  Workflow = "Workflow",
@@ -15,6 +16,7 @@ enum IconProp {
15
16
  CursorArrowRays = "CursorArrowRays",
16
17
  ArrowUpDown = "ArrowUpDown",
17
18
  Cube = "Cube",
19
+ Unarchive = "Unarchive",
18
20
  Swatch = "Swatch",
19
21
  Squares = "Squares",
20
22
  RectangleStack = "RectangleStack",
@@ -53,6 +53,12 @@ enum Permission {
53
53
  EditTelemetryServiceLog = "EditTelemetryServiceLog",
54
54
  ReadTelemetryServiceLog = "ReadTelemetryServiceLog",
55
55
 
56
+ // Exceptions
57
+ CreateTelemetryException = "CreateTelemetryException",
58
+ DeleteTelemetryException = "DeleteTelemetryException",
59
+ EditTelemetryException = "EditTelemetryException",
60
+ ReadTelemetryException = "ReadTelemetryException",
61
+
56
62
  // Spans
57
63
  CreateTelemetryServiceTraces = "CreateTelemetryServiceTraces",
58
64
  DeleteTelemetryServiceTraces = "DeleteTelemetryServiceTraces",
@@ -2445,6 +2451,39 @@ export class PermissionHelper {
2445
2451
  isAccessControlPermission: false,
2446
2452
  },
2447
2453
 
2454
+ {
2455
+ permission: Permission.CreateTelemetryException,
2456
+ title: "Create Telemetry Service Exception",
2457
+ description:
2458
+ "This permission can create Telemetry Service Exception this project.",
2459
+ isAssignableToTenant: true,
2460
+ isAccessControlPermission: false,
2461
+ },
2462
+ {
2463
+ permission: Permission.DeleteTelemetryException,
2464
+ title: "Delete Telemetry Service Exception",
2465
+ description:
2466
+ "This permission can delete Telemetry Service Exception of this project.",
2467
+ isAssignableToTenant: true,
2468
+ isAccessControlPermission: false,
2469
+ },
2470
+ {
2471
+ permission: Permission.EditTelemetryException,
2472
+ title: "Edit Telemetry Service Exception",
2473
+ description:
2474
+ "This permission can edit Telemetry Service Exception of this project.",
2475
+ isAssignableToTenant: true,
2476
+ isAccessControlPermission: false,
2477
+ },
2478
+ {
2479
+ permission: Permission.ReadTelemetryException,
2480
+ title: "Read Telemetry Service Exception",
2481
+ description:
2482
+ "This permission can read Telemetry Service Exception of this project.",
2483
+ isAssignableToTenant: true,
2484
+ isAccessControlPermission: false,
2485
+ },
2486
+
2448
2487
  {
2449
2488
  permission: Permission.CreateCopilotCodeRepository,
2450
2489
  title: "Create Code Repository",
@@ -0,0 +1,66 @@
1
+ import { ButtonStyleType } from "../Button/Button";
2
+ import Card from "../Card/Card";
3
+ import ConfirmModal from "../Modal/ConfirmModal";
4
+ import IconProp from "Common/Types/Icon/IconProp";
5
+ import React, { ReactElement, useState } from "react";
6
+
7
+ export interface ConfirmAction {
8
+ actionName: string;
9
+ actionIcon: IconProp;
10
+ onConfirmAction: () => void;
11
+ actionButtonStyle?: ButtonStyleType;
12
+ isLoading?: boolean;
13
+ }
14
+
15
+ export interface ComponentProps {
16
+ title: string;
17
+ description: string;
18
+ actions: Array<ConfirmAction>;
19
+ }
20
+
21
+ const ActionCard: (props: ComponentProps) => ReactElement = (
22
+ props: ComponentProps,
23
+ ): ReactElement => {
24
+ const [currentAction, setCurrentAction] = useState<ConfirmAction | undefined>(
25
+ undefined,
26
+ );
27
+
28
+ return (
29
+ <>
30
+ <Card
31
+ title={props.title}
32
+ description={props.description}
33
+ buttons={props.actions.map((action: ConfirmAction) => {
34
+ return {
35
+ title: action.actionName,
36
+ buttonStyle: action.actionButtonStyle || ButtonStyleType.NORMAL,
37
+ onClick: () => {
38
+ setCurrentAction(action);
39
+ },
40
+ icon: action.actionIcon,
41
+ isLoading: action.isLoading,
42
+ };
43
+ })}
44
+ />
45
+
46
+ {currentAction ? (
47
+ <ConfirmModal
48
+ description={`Are you sure you want to ${currentAction.actionName}?`}
49
+ title={`Confirm ${currentAction.actionName}`}
50
+ onSubmit={() => {
51
+ currentAction.onConfirmAction();
52
+ setCurrentAction(undefined);
53
+ }}
54
+ submitButtonText={`Confirm`}
55
+ onClose={() => {
56
+ setCurrentAction(undefined);
57
+ }}
58
+ />
59
+ ) : (
60
+ <></>
61
+ )}
62
+ </>
63
+ );
64
+ };
65
+
66
+ export default ActionCard;
@@ -16,13 +16,13 @@ export enum AlertSize {
16
16
  }
17
17
 
18
18
  export interface ComponentProps {
19
- strongTitle?: undefined | string;
20
- title?: undefined | string;
21
- onClose?: undefined | (() => void);
22
- type?: undefined | AlertType;
23
- onClick?: (() => void) | undefined;
19
+ strongTitle?: string;
20
+ title?: string;
21
+ onClose?: () => void;
22
+ type?: AlertType;
23
+ onClick?: () => void;
24
24
  doNotShowIcon?: boolean | undefined;
25
- dataTestId?: string;
25
+ dataTestId?: string | undefined;
26
26
  textClassName?: string | undefined;
27
27
  className?: string | undefined;
28
28
  color?: Color | undefined;
@@ -33,93 +33,102 @@ export interface ComponentProps {
33
33
  const Alert: FunctionComponent<ComponentProps> = (
34
34
  props: ComponentProps,
35
35
  ): ReactElement => {
36
- let type: AlertType = AlertType.INFO;
36
+ const type: AlertType = props.type || AlertType.INFO;
37
37
 
38
- if (props.type) {
39
- type = props.type;
40
- }
38
+ const typeClassNames: {
39
+ [key in AlertType]: {
40
+ text: string;
41
+ bg: string;
42
+ hover: string;
43
+ };
44
+ } = {
45
+ [AlertType.DANGER]: {
46
+ text: "text-red-200",
47
+ bg: "bg-red-700",
48
+ hover: "hover:bg-red-600",
49
+ },
50
+ [AlertType.INFO]: {
51
+ text: "text-gray-200",
52
+ bg: "bg-gray-700",
53
+ hover: "hover:bg-gray-600",
54
+ },
55
+ [AlertType.WARNING]: {
56
+ text: "text-yellow-200",
57
+ bg: "bg-gray-700",
58
+ hover: "hover:bg-yellow-600",
59
+ },
60
+ [AlertType.SUCCESS]: {
61
+ text: "text-green-200",
62
+ bg: "bg-gray-700",
63
+ hover: "hover:bg-green-600",
64
+ },
65
+ };
41
66
 
42
- let className: string = "text-gray";
43
- let bgClassName: string = "bg-gray";
44
-
45
- if (AlertType.DANGER === type) {
46
- className = "text-red";
47
- bgClassName = "bg-red";
48
- } else if (AlertType.INFO === type) {
49
- className = "text-gray";
50
- bgClassName = "bg-gray";
51
- } else if (AlertType.WARNING === type) {
52
- className = "text-yellow";
53
- bgClassName = "bg-gray";
54
- } else if (AlertType.SUCCESS === type) {
55
- className = "text-green";
56
- bgClassName = "bg-gray";
57
- }
67
+ const {
68
+ text: textClassName,
69
+ bg: bgClassName,
70
+ hover: hoverClassName,
71
+ } = typeClassNames[type];
58
72
 
59
73
  return (
60
74
  <div
61
75
  id={props.id}
62
- className={`rounded-md ${bgClassName}-700 p-4`}
76
+ className={`alert rounded-md ${bgClassName} p-4 ${props.className}`}
63
77
  data-testid={props.dataTestId}
64
- onClick={() => {
65
- props.onClick && props.onClick();
66
- }}
78
+ onClick={props.onClick}
67
79
  role="alert"
68
- style={
69
- props.color
70
- ? {
71
- backgroundColor: props.color?.toString(),
72
- }
73
- : {}
74
- }
80
+ style={props.color ? { backgroundColor: props.color.toString() } : {}}
75
81
  >
76
- <div className="flex ">
82
+ <div className="alert-content flex">
77
83
  {!props.doNotShowIcon && (
78
- <div className="flex-shrink-0">
79
- {AlertType.DANGER === type && (
80
- <Icon icon={IconProp.Alert} className="h-5 w-5 text-red-200" />
84
+ <div className="alert-icon flex-shrink-0">
85
+ {type === AlertType.DANGER && (
86
+ <Icon
87
+ icon={IconProp.Alert}
88
+ className={`h-5 w-5 ${textClassName}`}
89
+ />
81
90
  )}
82
- {AlertType.WARNING === type && (
83
- <Icon icon={IconProp.Alert} className="h-5 w-5 text-yellow-200" />
91
+ {type === AlertType.WARNING && (
92
+ <Icon
93
+ icon={IconProp.Alert}
94
+ className={`h-5 w-5 ${textClassName}`}
95
+ />
84
96
  )}
85
- {AlertType.SUCCESS === type && (
97
+ {type === AlertType.SUCCESS && (
86
98
  <Icon
87
99
  icon={IconProp.CheckCircle}
88
- className="h-5 w-5 text-green-400"
100
+ className={`h-5 w-5 ${textClassName}`}
89
101
  />
90
102
  )}
91
- {AlertType.INFO === type && (
92
- <Icon icon={IconProp.Info} className="h-5 w-5 text-gray-200" />
103
+ {type === AlertType.INFO && (
104
+ <Icon
105
+ icon={IconProp.Info}
106
+ className={`h-5 w-5 ${textClassName}`}
107
+ />
93
108
  )}
94
109
  </div>
95
110
  )}
96
111
  <div
97
- className={`ml-3 mr-3 flex-1 md:flex md:justify-between ${props.className}`}
112
+ className={`alert-text ml-3 mr-3 flex-1 md:flex md:justify-between ${props.textClassName}`}
98
113
  >
99
114
  <div
100
- className={
101
- props.textClassName ||
102
- `text-sm flex justify-between ${className}-200`
103
- }
115
+ className={`alert-message text-sm flex justify-between ${textClassName}`}
104
116
  >
105
117
  <div>
106
118
  <span className="font-medium">
107
119
  {props.strongTitle}{" "}
108
- {props.title && props.strongTitle ? "-" : ""}{" "}
120
+ {props.title && props.strongTitle ? "-" : ""}
109
121
  </span>
110
122
  {props.title}
111
123
  </div>
112
124
  {props.textOnRight && <div>{props.textOnRight}</div>}
113
125
  </div>
114
-
115
126
  {props.onClose && (
116
- <p className="mt-3 text-sm md:mt-0 md:ml-6">
127
+ <p className="alert-close mt-3 text-sm md:mt-0 md:ml-6">
117
128
  <button
118
- onClick={() => {
119
- props.onClose && props.onClose();
120
- }}
121
- role={"alert-close-button"}
122
- className={`whitespace-nowrap font-medium ${className}-200 hover:${className}-50`}
129
+ onClick={props.onClose}
130
+ role="alert-close-button"
131
+ className={`whitespace-nowrap font-medium ${textClassName} hover:${hoverClassName}`}
123
132
  >
124
133
  Close
125
134
  <span aria-hidden="true"> &rarr;</span>
@@ -83,6 +83,7 @@ const Card: FunctionComponent<ComponentProps> = (
83
83
  icon={button.icon}
84
84
  shortcutKey={button.shortcutKey}
85
85
  dataTestId="card-button"
86
+ isLoading={button.isLoading}
86
87
  />
87
88
  </div>
88
89
  );
@@ -1,5 +1,6 @@
1
+ import Text from "../../../../Types/Text";
1
2
  import LineChart, { ComponentProps as LineChartProps } from "../Line/LineChart";
2
- import React, { FunctionComponent, ReactElement, useState } from "react";
3
+ import React, { FunctionComponent, ReactElement } from "react";
3
4
 
4
5
  export enum ChartType {
5
6
  LINE = "line",
@@ -13,7 +14,6 @@ export interface Chart {
13
14
  description?: string | undefined;
14
15
  type: ChartType;
15
16
  props: LineChartProps;
16
- sync: boolean;
17
17
  }
18
18
 
19
19
  export interface ComponentProps {
@@ -23,9 +23,7 @@ export interface ComponentProps {
23
23
  const ChartGroup: FunctionComponent<ComponentProps> = (
24
24
  props: ComponentProps,
25
25
  ): ReactElement => {
26
- const [syncValue, setSyncValue] = useState<
27
- number | string | Date | undefined
28
- >(undefined);
26
+ const syncId: string = Text.generateRandomText(10);
29
27
 
30
28
  return (
31
29
  <div className="lg:grid grid-cols-1 gap-5">
@@ -49,18 +47,7 @@ const ChartGroup: FunctionComponent<ComponentProps> = (
49
47
  {chart.description}
50
48
  </p>
51
49
  )}
52
- <LineChart
53
- key={index}
54
- {...chart.props}
55
- xAxisMarker={{
56
- value: chart.sync ? syncValue : undefined,
57
- }}
58
- onHoverXAxis={(value: string | number | Date) => {
59
- if (chart.sync) {
60
- setSyncValue(value);
61
- }
62
- }}
63
- />
50
+ <LineChart key={index} {...chart.props} syncId={syncId} />
64
51
  </div>
65
52
  );
66
53
  default: