@oas-tools/oas-telemetry 0.7.1 → 0.8.0-alpha.0

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 (167) hide show
  1. package/.env.example +21 -2
  2. package/README.md +1 -2
  3. package/dist/cjs/config/bootConfig.cjs +19 -14
  4. package/dist/cjs/config/config.cjs +112 -125
  5. package/dist/cjs/config/config.types.cjs +1 -4
  6. package/dist/cjs/docs/openapi.yaml +158 -4
  7. package/dist/cjs/index.cjs +27 -30
  8. package/dist/cjs/routesManager.cjs +62 -70
  9. package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.cjs +202 -190
  10. package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.cjs +204 -99
  11. package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.cjs +152 -116
  12. package/dist/cjs/telemetry/custom-implementations/instrumentations/logsInstrumentation.cjs +92 -0
  13. package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/Chunk.cjs +159 -0
  14. package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/Series.cjs +168 -0
  15. package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/SeriesRegistry.cjs +389 -0
  16. package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/types.cjs +2 -0
  17. package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/utils.cjs +77 -0
  18. package/dist/cjs/telemetry/custom-implementations/processors/dynamicMultiLogProcessor.cjs +65 -63
  19. package/dist/cjs/telemetry/custom-implementations/processors/dynamicMultiSpanProcessor.cjs +63 -62
  20. package/dist/cjs/telemetry/custom-implementations/utils/circular.cjs +47 -47
  21. package/dist/cjs/telemetry/custom-implementations/utils/storagePath.cjs +39 -0
  22. package/dist/cjs/telemetry/custom-implementations/wrappers.cjs +141 -138
  23. package/dist/cjs/telemetry/initializeTelemetry.cjs +35 -91
  24. package/dist/cjs/telemetry/telemetryConfigurator.cjs +70 -72
  25. package/dist/cjs/telemetry/telemetryRegistry.cjs +45 -31
  26. package/dist/cjs/tlm-ai/agent.cjs +49 -64
  27. package/dist/cjs/tlm-ai/aiController.cjs +54 -76
  28. package/dist/cjs/tlm-ai/aiRoutes.cjs +17 -20
  29. package/dist/cjs/tlm-ai/aiService.cjs +91 -95
  30. package/dist/cjs/tlm-ai/tools.cjs +177 -174
  31. package/dist/cjs/tlm-auth/authController.cjs +80 -123
  32. package/dist/cjs/tlm-auth/authMiddleware.cjs +25 -30
  33. package/dist/cjs/tlm-auth/authRoutes.cjs +11 -14
  34. package/dist/cjs/tlm-log/logController.cjs +171 -116
  35. package/dist/cjs/tlm-log/logRoutes.cjs +20 -20
  36. package/dist/cjs/tlm-metric/metricsController.cjs +211 -121
  37. package/dist/cjs/tlm-metric/metricsRoutes.cjs +23 -20
  38. package/dist/cjs/tlm-plugin/pluginController.cjs +128 -140
  39. package/dist/cjs/tlm-plugin/pluginProcess.cjs +89 -94
  40. package/dist/cjs/tlm-plugin/pluginRoutes.cjs +11 -14
  41. package/dist/cjs/tlm-plugin/pluginService.cjs +73 -74
  42. package/dist/cjs/tlm-trace/traceController.cjs +169 -117
  43. package/dist/cjs/tlm-trace/traceRoutes.cjs +20 -20
  44. package/dist/cjs/tlm-ui/uiRoutes.cjs +63 -32
  45. package/dist/cjs/tlm-util/utilController.cjs +68 -70
  46. package/dist/cjs/tlm-util/utilRoutes.cjs +51 -63
  47. package/dist/cjs/types/index.cjs +2 -5
  48. package/dist/cjs/utils/logger.cjs +38 -43
  49. package/dist/cjs/utils/regexUtils.cjs +22 -22
  50. package/dist/esm/config/bootConfig.js +6 -0
  51. package/dist/esm/config/config.js +1 -2
  52. package/dist/esm/docs/openapi.yaml +158 -4
  53. package/dist/esm/index.js +9 -8
  54. package/dist/esm/routesManager.js +6 -10
  55. package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.js +47 -8
  56. package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.js +164 -48
  57. package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.js +69 -29
  58. package/dist/esm/telemetry/custom-implementations/instrumentations/logsInstrumentation.js +85 -0
  59. package/dist/esm/telemetry/custom-implementations/metrics/tsdb/Chunk.js +155 -0
  60. package/dist/esm/telemetry/custom-implementations/metrics/tsdb/Series.js +164 -0
  61. package/dist/esm/telemetry/custom-implementations/metrics/tsdb/SeriesRegistry.js +382 -0
  62. package/dist/esm/telemetry/custom-implementations/metrics/tsdb/types.js +1 -0
  63. package/dist/esm/telemetry/custom-implementations/metrics/tsdb/utils.js +74 -0
  64. package/dist/esm/telemetry/custom-implementations/processors/dynamicMultiLogProcessor.js +2 -1
  65. package/dist/esm/telemetry/custom-implementations/processors/dynamicMultiSpanProcessor.js +1 -1
  66. package/dist/esm/telemetry/custom-implementations/utils/storagePath.js +33 -0
  67. package/dist/esm/telemetry/custom-implementations/wrappers.js +5 -2
  68. package/dist/esm/telemetry/initializeTelemetry.js +27 -69
  69. package/dist/esm/telemetry/telemetryConfigurator.js +42 -40
  70. package/dist/esm/telemetry/telemetryRegistry.js +12 -1
  71. package/dist/esm/tlm-ai/agent.js +5 -3
  72. package/dist/esm/tlm-ai/aiController.js +3 -3
  73. package/dist/esm/tlm-ai/aiService.js +6 -2
  74. package/dist/esm/tlm-ai/tools.js +5 -9
  75. package/dist/esm/tlm-auth/authController.js +3 -2
  76. package/dist/esm/tlm-log/logController.js +84 -4
  77. package/dist/esm/tlm-log/logRoutes.js +5 -2
  78. package/dist/esm/tlm-metric/metricsController.js +172 -49
  79. package/dist/esm/tlm-metric/metricsRoutes.js +10 -4
  80. package/dist/esm/tlm-plugin/pluginController.js +6 -11
  81. package/dist/esm/tlm-plugin/pluginService.js +2 -4
  82. package/dist/esm/tlm-trace/traceController.js +102 -16
  83. package/dist/esm/tlm-trace/traceRoutes.js +5 -2
  84. package/dist/esm/tlm-ui/uiRoutes.js +5 -5
  85. package/dist/esm/tlm-util/utilController.js +3 -9
  86. package/dist/esm/tlm-util/utilRoutes.js +2 -2
  87. package/dist/types/config/bootConfig.d.ts +4 -0
  88. package/dist/types/config/config.d.ts +36 -7
  89. package/dist/types/config/config.types.d.ts +6 -0
  90. package/dist/types/index.d.ts +2 -3
  91. package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.d.ts +4 -1
  92. package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.d.ts +60 -15
  93. package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.d.ts +9 -4
  94. package/dist/types/telemetry/custom-implementations/instrumentations/logsInstrumentation.d.ts +23 -0
  95. package/dist/types/telemetry/custom-implementations/metrics/tsdb/Chunk.d.ts +49 -0
  96. package/dist/types/telemetry/custom-implementations/metrics/tsdb/Series.d.ts +67 -0
  97. package/dist/types/telemetry/custom-implementations/metrics/tsdb/SeriesRegistry.d.ts +69 -0
  98. package/dist/types/telemetry/custom-implementations/metrics/tsdb/types.d.ts +68 -0
  99. package/dist/types/telemetry/custom-implementations/metrics/tsdb/utils.d.ts +21 -0
  100. package/dist/types/telemetry/custom-implementations/processors/dynamicMultiLogProcessor.d.ts +2 -2
  101. package/dist/types/telemetry/custom-implementations/utils/storagePath.d.ts +12 -0
  102. package/dist/types/telemetry/custom-implementations/wrappers.d.ts +1 -1
  103. package/dist/types/telemetry/telemetryConfigurator.d.ts +1 -1
  104. package/dist/types/telemetry/telemetryRegistry.d.ts +8 -0
  105. package/dist/types/tlm-ai/agent.d.ts +1 -1
  106. package/dist/types/tlm-ai/aiService.d.ts +1 -1
  107. package/dist/types/tlm-log/logController.d.ts +2 -0
  108. package/dist/types/tlm-metric/metricsController.d.ts +16 -2
  109. package/dist/types/tlm-trace/traceController.d.ts +3 -1
  110. package/dist/types/types/index.d.ts +2 -2
  111. package/dist/ui/assets/{ApiDocsPage-C_VVPPHa.js → ApiDocsPage-BFUrXE5F.js} +2 -2
  112. package/dist/ui/assets/CollapsibleCard-STA1GVQO.js +1 -0
  113. package/dist/ui/assets/DevToolsPage-BRSfZqO_.js +1 -0
  114. package/dist/ui/assets/LandingPage-DzeDy7q7.js +6 -0
  115. package/dist/ui/assets/LogsPage-BeiFrV2X.js +1 -0
  116. package/dist/ui/assets/{NotFoundPage-B3quk3P1.js → NotFoundPage-fRNOatbM.js} +1 -1
  117. package/dist/ui/assets/PluginCreatePage-Ch_RXsdf.js +50 -0
  118. package/dist/ui/assets/PluginPage-Cl65ZZ_n.js +27 -0
  119. package/dist/ui/assets/TraceSpansPage-BoK4M5Hh.js +6 -0
  120. package/dist/ui/assets/VirtualizedListPanel-zcj0v7DL.js +16 -0
  121. package/dist/ui/assets/alert-BkNVKxJN.js +1133 -0
  122. package/dist/ui/assets/badge-CN7FeufU.js +1 -0
  123. package/dist/ui/assets/{chevron-down-CPsvsmqj.js → chevron-down-CG--ounh.js} +1 -1
  124. package/dist/ui/assets/{chevron-up-Df9jMo1X.js → chevron-up-B6tzMAOm.js} +1 -1
  125. package/dist/ui/assets/{circle-alert-DOPQPvU8.js → circle-alert-BDF8Tq9y.js} +1 -1
  126. package/dist/ui/assets/dialog-BrpWNk36.js +15 -0
  127. package/dist/ui/assets/index-6xOVKwKn.js +305 -0
  128. package/dist/ui/assets/index-D6f1KjWV.css +1 -0
  129. package/dist/ui/assets/index-D96rVSkR.js +1 -0
  130. package/dist/ui/assets/info-99kuqpbx.js +6 -0
  131. package/dist/ui/assets/{input-Dzvg_ZEZ.js → input-B-01QDg_.js} +1 -1
  132. package/dist/ui/assets/label-CQLeZjM1.js +1 -0
  133. package/dist/ui/assets/{loader-circle-CrvlRy5o.js → loader-circle-BoDGk-BO.js} +1 -1
  134. package/dist/ui/assets/{loginPage-qa4V-B70.js → loginPage-8F4EEd1B.js} +1 -1
  135. package/dist/ui/assets/metrics-page-D1GxaB_c.css +1 -0
  136. package/dist/ui/assets/metrics-page-DPtteXqY.js +31 -0
  137. package/dist/ui/assets/popover-DS_8DYYt.js +11 -0
  138. package/dist/ui/assets/select-DYjegiXi.js +6 -0
  139. package/dist/ui/assets/separator-DGsRxIrl.js +6 -0
  140. package/dist/ui/assets/severityOptions-DEOvJqC9.js +11 -0
  141. package/dist/ui/assets/square-pen-DPhgYz6O.js +6 -0
  142. package/dist/ui/assets/switch-Di9NJH2A.js +1 -0
  143. package/dist/ui/assets/trace-DJq1miYa.js +1 -0
  144. package/dist/ui/assets/upload-BiLTpCnX.js +11 -0
  145. package/dist/ui/assets/{utilService-DNyqzwj0.js → utilService-CNZOmadC.js} +1 -1
  146. package/dist/ui/assets/wand-sparkles-CPoBNFFg.js +6 -0
  147. package/dist/ui/index.html +2 -2
  148. package/package.json +44 -48
  149. package/dist/ui/assets/CollapsibleCard-B3KR_8mL.js +0 -1
  150. package/dist/ui/assets/DevToolsPage-OyZcDcmw.js +0 -1
  151. package/dist/ui/assets/LandingPage-CppFBA6K.js +0 -6
  152. package/dist/ui/assets/LogsPage-9Fq8GArS.js +0 -26
  153. package/dist/ui/assets/PluginCreatePage-X_aCH4t4.js +0 -50
  154. package/dist/ui/assets/PluginPage-DMDSihrZ.js +0 -27
  155. package/dist/ui/assets/alert-jQ9HCPIf.js +0 -1133
  156. package/dist/ui/assets/badge-CNq0-mH5.js +0 -1
  157. package/dist/ui/assets/card-DFAwwhN3.js +0 -1
  158. package/dist/ui/assets/index-BkD6DijD.js +0 -15
  159. package/dist/ui/assets/index-CERGVYZK.js +0 -292
  160. package/dist/ui/assets/index-CSIPf9qw.css +0 -1
  161. package/dist/ui/assets/label-DuVnkZ4q.js +0 -1
  162. package/dist/ui/assets/select-DhS8YUtJ.js +0 -1
  163. package/dist/ui/assets/separator-isK4chBP.js +0 -6
  164. package/dist/ui/assets/severityOptions-O38dSOfk.js +0 -11
  165. package/dist/ui/assets/switch-Z3mImG9n.js +0 -1
  166. package/dist/ui/assets/tabs-_77MUUQe.js +0 -16
  167. package/dist/ui/assets/upload-C1LT4Gkb.js +0 -16
@@ -1,70 +1,71 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.DynamicMultiSpanProcessor = void 0;
7
- var _logger = _interopRequireDefault(require("../../../utils/logger.cjs"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
+ const logger_js_1 = __importDefault(require("../../../utils/logger.cjs"));
9
8
  class DynamicMultiSpanProcessor {
10
- constructor(initialProcessors = []) {
11
- this._spanProcessors = [];
12
- this._spanProcessors = [...initialProcessors];
13
- }
14
- /**
15
- * Add a new SpanProcessor or an array of SpanProcessors at runtime.
16
- */
17
- addProcessors(processor) {
18
- if (Array.isArray(processor)) {
19
- this._spanProcessors.push(...processor);
20
- } else {
21
- this._spanProcessors.push(processor);
9
+ _spanProcessors = [];
10
+ constructor(initialProcessors = []) {
11
+ this._spanProcessors = [...initialProcessors];
22
12
  }
23
- }
24
- /**
25
- * Remove a specific SpanProcessor if needed.
26
- */
27
- removeProcessor(processor) {
28
- this._spanProcessors = this._spanProcessors.filter(p => p !== processor);
29
- }
30
- /**
31
- * Clear all processors.
32
- */
33
- clearProcessors() {
34
- this._spanProcessors = [];
35
- }
36
- /**
37
- * Called when a span is started.
38
- */
39
- onStart(span, context) {
40
- for (const processor of this._spanProcessors) {
41
- processor.onStart(span, context);
13
+ /**
14
+ * Add a new SpanProcessor or an array of SpanProcessors at runtime.
15
+ */
16
+ addProcessors(processor) {
17
+ if (Array.isArray(processor)) {
18
+ this._spanProcessors.push(...processor);
19
+ }
20
+ else {
21
+ this._spanProcessors.push(processor);
22
+ }
42
23
  }
43
- }
44
- /**
45
- * Called when a span ends.
46
- */
47
- onEnd(span) {
48
- for (const processor of this._spanProcessors) {
49
- processor.onEnd(span);
24
+ /**
25
+ * Remove a specific SpanProcessor if needed.
26
+ */
27
+ removeProcessor(processor) {
28
+ this._spanProcessors = this._spanProcessors.filter(p => p !== processor);
50
29
  }
51
- }
52
- /**
53
- * Force flush all processors.
54
- */
55
- async forceFlush() {
56
- const promises = this._spanProcessors.map(p => p.forceFlush());
57
- try {
58
- await Promise.all(promises);
59
- } catch (error) {
60
- _logger.default.error('Error during forceFlush:', error);
30
+ /**
31
+ * Clear all processors.
32
+ */
33
+ clearProcessors() {
34
+ this._spanProcessors = [];
35
+ }
36
+ /**
37
+ * Called when a span is started.
38
+ */
39
+ onStart(span, context) {
40
+ for (const processor of this._spanProcessors) {
41
+ processor.onStart(span, context);
42
+ }
43
+ }
44
+ /**
45
+ * Called when a span ends.
46
+ */
47
+ onEnd(span) {
48
+ for (const processor of this._spanProcessors) {
49
+ processor.onEnd(span);
50
+ }
51
+ }
52
+ /**
53
+ * Force flush all processors.
54
+ */
55
+ async forceFlush() {
56
+ const promises = this._spanProcessors.map(p => p.forceFlush());
57
+ try {
58
+ await Promise.all(promises);
59
+ }
60
+ catch (error) {
61
+ logger_js_1.default.error('Error during forceFlush:', error);
62
+ }
63
+ }
64
+ /**
65
+ * Shutdown all processors.
66
+ */
67
+ async shutdown() {
68
+ await Promise.all(this._spanProcessors.map(p => p.shutdown()));
61
69
  }
62
- }
63
- /**
64
- * Shutdown all processors.
65
- */
66
- async shutdown() {
67
- await Promise.all(this._spanProcessors.map(p => p.shutdown()));
68
- }
69
70
  }
70
- exports.DynamicMultiSpanProcessor = DynamicMultiSpanProcessor;
71
+ exports.DynamicMultiSpanProcessor = DynamicMultiSpanProcessor;
@@ -1,31 +1,28 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.applyNesting = applyNesting;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
7
3
  exports.removeCircularRefs = removeCircularRefs;
4
+ exports.applyNesting = applyNesting;
8
5
  function removeCircularRefs(obj) {
9
- // const seen = new WeakMap(); // Used to keep track of visited objects
10
- // Replacer function to handle circular references
11
- function replacer(key, value) {
12
- if (key === "_spanProcessor") {
13
- return "oas-telemetry skips this field to avoid circular reference";
6
+ // const seen = new WeakMap(); // Used to keep track of visited objects
7
+ // Replacer function to handle circular references
8
+ function replacer(key, value) {
9
+ if (key === "_spanProcessor") {
10
+ return "oas-telemetry skips this field to avoid circular reference";
11
+ }
12
+ // GENERIC CIRCULAR REFERENCE HANDLING
13
+ // if (typeof value === "object" && value !== null) {
14
+ // // If the object has been visited before, return the name prefixed with "CIRCULAR+"
15
+ // if (seen.has(value)) {
16
+ // return `CIRCULAR${key}`;
17
+ // }
18
+ // seen.set(value, key); // Mark the object as visited with its name
19
+ // }
20
+ return value;
14
21
  }
15
- // GENERIC CIRCULAR REFERENCE HANDLING
16
- // if (typeof value === "object" && value !== null) {
17
- // // If the object has been visited before, return the name prefixed with "CIRCULAR+"
18
- // if (seen.has(value)) {
19
- // return `CIRCULAR${key}`;
20
- // }
21
- // seen.set(value, key); // Mark the object as visited with its name
22
- // }
23
- return value;
24
- }
25
- // Convert the object to a string and then parse it back
26
- // This will trigger the replacer function to handle circular references
27
- const jsonString = JSON.stringify(obj, replacer);
28
- return JSON.parse(jsonString);
22
+ // Convert the object to a string and then parse it back
23
+ // This will trigger the replacer function to handle circular references
24
+ const jsonString = JSON.stringify(obj, replacer);
25
+ return JSON.parse(jsonString);
29
26
  }
30
27
  /**
31
28
  * Recursively converts dot-separated keys in an object to nested objects.
@@ -53,28 +50,31 @@ function removeCircularRefs(obj) {
53
50
  * }
54
51
  */
55
52
  function applyNesting(obj) {
56
- if (Array.isArray(obj)) {
57
- return obj.map(item => applyNesting(item));
58
- } else if (typeof obj === 'object' && obj !== null) {
59
- const result = {};
60
- for (const key in obj) {
61
- const value = applyNesting(obj[key]);
62
- const keys = key.split('.');
63
- let temp = result;
64
- for (let i = 0; i < keys.length; i++) {
65
- const currentKey = keys[i];
66
- if (i === keys.length - 1) {
67
- temp[currentKey] = value;
68
- } else {
69
- if (!temp[currentKey]) {
70
- temp[currentKey] = {};
71
- }
72
- temp = temp[currentKey];
53
+ if (Array.isArray(obj)) {
54
+ return obj.map(item => applyNesting(item));
55
+ }
56
+ else if (typeof obj === 'object' && obj !== null) {
57
+ const result = {};
58
+ for (const key in obj) {
59
+ const value = applyNesting(obj[key]);
60
+ const keys = key.split('.');
61
+ let temp = result;
62
+ for (let i = 0; i < keys.length; i++) {
63
+ const currentKey = keys[i];
64
+ if (i === keys.length - 1) {
65
+ temp[currentKey] = value;
66
+ }
67
+ else {
68
+ if (!temp[currentKey]) {
69
+ temp[currentKey] = {};
70
+ }
71
+ temp = temp[currentKey];
72
+ }
73
+ }
73
74
  }
74
- }
75
+ return result;
76
+ }
77
+ else {
78
+ return obj;
75
79
  }
76
- return result;
77
- } else {
78
- return obj;
79
- }
80
- }
80
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getStoragePath = getStoragePath;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const bootConfig_js_1 = require("../../../config/bootConfig.cjs");
10
+ /**
11
+ * Get storage path for disk-based persistence
12
+ * Returns null if storage is in-memory (when OASTLM_BOOT_STORAGE_PATH is empty or not set)
13
+ *
14
+ * Environment variables (BOOT - set at startup):
15
+ * - OASTLM_BOOT_STORAGE_PATH: empty or not set = in-memory, else = disk path
16
+ * Examples:
17
+ * - OASTLM_BOOT_STORAGE_PATH="" (or not set) -> in-memory
18
+ * - OASTLM_BOOT_STORAGE_PATH="data/telemetry" -> disk at ./data/telemetry
19
+ * - OASTLM_BOOT_STORAGE_PATH="/var/lib/telemetry" -> disk at /var/lib/telemetry
20
+ */
21
+ function getStoragePath(name) {
22
+ // If storage path is empty, use in-memory
23
+ if (!bootConfig_js_1.bootEnvVariables.OASTLM_BOOT_STORAGE_PATH) {
24
+ console.warn(`BOOT STORAGE: No storage path configured for ${name}. Using in-memory storage. To enable disk storage, set OASTLM_BOOT_STORAGE_PATH environment variable.`);
25
+ return null;
26
+ }
27
+ const filePath = path_1.default.join(bootConfig_js_1.bootEnvVariables.OASTLM_BOOT_STORAGE_PATH, `${name}.db`);
28
+ try {
29
+ const dir = path_1.default.dirname(filePath);
30
+ if (!fs_1.default.existsSync(dir)) {
31
+ fs_1.default.mkdirSync(dir, { recursive: true });
32
+ }
33
+ }
34
+ catch (error) {
35
+ console.warn(`Failed to create storage directory for ${name}`, error);
36
+ return null;
37
+ }
38
+ return filePath;
39
+ }
@@ -1,35 +1,35 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.EnablerSpanExporter = exports.EnablerMultiSpanExporter = exports.EnablerMultiLogExporter = exports.EnablerMetricReader = exports.EnablerLogExporter = exports.Enabler = void 0;
7
- var _resources = require("@opentelemetry/resources");
8
- var _logger = _interopRequireDefault(require("../../utils/logger.cjs"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.EnablerMetricReader = exports.EnablerMultiLogExporter = exports.EnablerMultiSpanExporter = exports.EnablerLogExporter = exports.EnablerSpanExporter = exports.Enabler = void 0;
7
+ const resources_1 = require("@opentelemetry/resources");
8
+ const logger_js_1 = __importDefault(require("../../utils/logger.cjs"));
10
9
  class Enabler {
11
- constructor(enabled) {
12
- this._enabled = true;
13
- if (typeof enabled === 'boolean') {
14
- this._enabled = enabled;
15
- }
16
- }
17
- setEnabledValue(value) {
18
- this._enabled = value;
19
- }
20
- enable() {
21
- this._enabled = true;
22
- }
23
- disable() {
24
- this._enabled = false;
25
- }
26
- isEnabled() {
27
- return this._enabled;
28
- }
29
- toggle() {
30
- this._enabled = !this._enabled;
31
- }
10
+ _enabled = true;
11
+ constructor(enabled) {
12
+ if (typeof enabled === 'boolean') {
13
+ this._enabled = enabled;
14
+ }
15
+ }
16
+ setEnabledValue(value) {
17
+ this._enabled = value;
18
+ }
19
+ enable() {
20
+ this._enabled = true;
21
+ }
22
+ disable() {
23
+ this._enabled = false;
24
+ }
25
+ isEnabled() {
26
+ return this._enabled;
27
+ }
28
+ toggle() {
29
+ this._enabled = !this._enabled;
30
+ }
32
31
  }
32
+ exports.Enabler = Enabler;
33
33
  /*
34
34
  * Classes for enabler exporters, allowing enable/disable toggling of exporters at runtime.
35
35
  *
@@ -46,130 +46,133 @@ class Enabler {
46
46
  * disabled, the reader's `collect` method is not called at all, saving additional resources compared to disabling the exporter.
47
47
  *
48
48
  */
49
- exports.Enabler = Enabler;
50
49
  class EnablerSpanExporter extends Enabler {
51
- constructor(exporter) {
52
- super();
53
- this.exporter = exporter;
54
- }
55
- export(spans, resultCallback) {
56
- if (this.isEnabled()) {
57
- this.exporter.export(spans, resultCallback);
58
- }
59
- }
60
- shutdown() {
61
- return this.exporter.shutdown();
62
- }
63
- forceFlush() {
64
- if (typeof this.exporter.forceFlush === 'function') {
65
- return this.exporter.forceFlush();
66
- }
67
- return Promise.resolve();
68
- }
50
+ exporter;
51
+ constructor(exporter) {
52
+ super();
53
+ this.exporter = exporter;
54
+ }
55
+ export(spans, resultCallback) {
56
+ if (this.isEnabled()) {
57
+ this.exporter.export(spans, resultCallback);
58
+ }
59
+ }
60
+ shutdown() {
61
+ return this.exporter.shutdown();
62
+ }
63
+ forceFlush() {
64
+ if (typeof this.exporter.forceFlush === 'function') {
65
+ return this.exporter.forceFlush();
66
+ }
67
+ return Promise.resolve();
68
+ }
69
69
  }
70
70
  exports.EnablerSpanExporter = EnablerSpanExporter;
71
71
  class EnablerLogExporter extends Enabler {
72
- constructor(exporter) {
73
- super();
74
- this.exporter = exporter;
75
- }
76
- export(logs, resultCallback) {
77
- if (this.isEnabled()) {
78
- this.exporter.export(logs, resultCallback);
79
- }
80
- }
81
- shutdown() {
82
- return this.exporter.shutdown();
83
- }
72
+ exporter;
73
+ constructor(exporter) {
74
+ super();
75
+ this.exporter = exporter;
76
+ }
77
+ export(logs, resultCallback) {
78
+ if (this.isEnabled()) {
79
+ this.exporter.export(logs, resultCallback);
80
+ }
81
+ }
82
+ shutdown() {
83
+ return this.exporter.shutdown();
84
+ }
84
85
  }
85
86
  exports.EnablerLogExporter = EnablerLogExporter;
86
87
  class EnablerMultiExporter extends Enabler {
87
- constructor(exporters) {
88
- super();
89
- this._exporters = [];
90
- if (exporters && Array.isArray(exporters)) {
91
- this._exporters = exporters;
92
- }
93
- }
94
- addExporters(exporter) {
95
- if (!this._exporters) {
96
- this._exporters = [];
97
- }
98
- if (Array.isArray(exporter)) {
99
- this._exporters.push(...exporter);
100
- } else {
101
- this._exporters.push(exporter);
102
- }
103
- }
88
+ _exporters = [];
89
+ constructor(exporters) {
90
+ super();
91
+ if (exporters && Array.isArray(exporters)) {
92
+ this._exporters = exporters;
93
+ }
94
+ }
95
+ addExporters(exporter) {
96
+ if (!this._exporters) {
97
+ this._exporters = [];
98
+ }
99
+ if (Array.isArray(exporter)) {
100
+ this._exporters.push(...exporter);
101
+ }
102
+ else {
103
+ this._exporters.push(exporter);
104
+ }
105
+ }
104
106
  }
105
107
  class EnablerMultiSpanExporter extends EnablerMultiExporter {
106
- export(spans, resultCallback) {
107
- _logger.default.debug(`EnablerMultiSpanExporter.export called with ${spans.length} spans, exporters: ${this._exporters?.length ?? 0}, enabled: ${this.isEnabled()}`);
108
- if (this.isEnabled() && this._exporters) {
109
- this._exporters.forEach(exporter => exporter.export(spans, resultCallback));
110
- }
111
- }
112
- async shutdown() {
113
- if (this._exporters) {
114
- await Promise.all(this._exporters.map(exporter => exporter.shutdown()));
115
- }
116
- return;
117
- }
108
+ export(spans, resultCallback) {
109
+ logger_js_1.default.debug(`EnablerMultiSpanExporter.export called with ${spans.length} spans, exporters: ${this._exporters?.length ?? 0}, enabled: ${this.isEnabled()}`);
110
+ if (this.isEnabled() && this._exporters) {
111
+ this._exporters.forEach((exporter) => exporter.export(spans, resultCallback));
112
+ }
113
+ }
114
+ async shutdown() {
115
+ if (this._exporters) {
116
+ await Promise.all(this._exporters.map((exporter) => exporter.shutdown()));
117
+ }
118
+ return;
119
+ }
118
120
  }
119
121
  exports.EnablerMultiSpanExporter = EnablerMultiSpanExporter;
120
122
  class EnablerMultiLogExporter extends EnablerMultiExporter {
121
- export(logs, resultCallback) {
122
- if (this.isEnabled() && this._exporters) {
123
- this._exporters.forEach(exporter => exporter.export(logs, resultCallback));
123
+ export(logs, resultCallback) {
124
+ if (this.isEnabled() && this._exporters) {
125
+ this._exporters.forEach((exporter) => exporter.export(logs, resultCallback));
126
+ }
124
127
  }
125
- }
126
- async shutdown() {
127
- if (this._exporters) {
128
- await Promise.all(this._exporters.map(exporter => exporter.shutdown()));
128
+ async shutdown() {
129
+ if (this._exporters) {
130
+ await Promise.all(this._exporters.map((exporter) => exporter.shutdown()));
131
+ }
132
+ return;
129
133
  }
130
- return;
131
- }
132
134
  }
133
135
  exports.EnablerMultiLogExporter = EnablerMultiLogExporter;
134
136
  class EnablerMetricReader extends Enabler {
135
- constructor(reader) {
136
- super();
137
- this.reader = reader;
138
- }
139
- forceFlush(options) {
140
- if (this.isEnabled()) {
141
- return this.reader.forceFlush(options);
142
- }
143
- return Promise.resolve();
144
- }
145
- setMetricProducer(metricProducer) {
146
- if (this.isEnabled()) {
147
- this.reader.setMetricProducer(metricProducer);
148
- }
149
- }
150
- selectAggregation(instrumentType) {
151
- return this.reader.selectAggregation(instrumentType);
152
- }
153
- selectAggregationTemporality(instrumentType) {
154
- return this.reader.selectAggregationTemporality(instrumentType);
155
- }
156
- selectCardinalityLimit(instrumentType) {
157
- return this.reader.selectCardinalityLimit(instrumentType);
158
- }
159
- async collect(options) {
160
- if (this.isEnabled()) {
161
- return await this.reader.collect(options);
162
- }
163
- return {
164
- resourceMetrics: {
165
- resource: (0, _resources.resourceFromAttributes)({}),
166
- scopeMetrics: []
167
- },
168
- errors: []
169
- };
170
- }
171
- shutdown(options) {
172
- return this.reader.shutdown(options);
173
- }
137
+ reader;
138
+ constructor(reader) {
139
+ super();
140
+ this.reader = reader;
141
+ }
142
+ forceFlush(options) {
143
+ if (this.isEnabled()) {
144
+ return this.reader.forceFlush(options);
145
+ }
146
+ return Promise.resolve();
147
+ }
148
+ setMetricProducer(metricProducer) {
149
+ if (this.isEnabled()) {
150
+ this.reader.setMetricProducer(metricProducer);
151
+ }
152
+ }
153
+ selectAggregation(instrumentType) {
154
+ return this.reader.selectAggregation(instrumentType);
155
+ }
156
+ selectAggregationTemporality(instrumentType) {
157
+ return this.reader.selectAggregationTemporality(instrumentType);
158
+ }
159
+ selectCardinalityLimit(instrumentType) {
160
+ return this.reader.selectCardinalityLimit(instrumentType);
161
+ }
162
+ async collect(options) {
163
+ if (this.isEnabled()) {
164
+ return await this.reader.collect(options);
165
+ }
166
+ return {
167
+ resourceMetrics: {
168
+ resource: (0, resources_1.resourceFromAttributes)({}),
169
+ scopeMetrics: [],
170
+ },
171
+ errors: [],
172
+ };
173
+ }
174
+ shutdown(options) {
175
+ return this.reader.shutdown(options);
176
+ }
174
177
  }
175
- exports.EnablerMetricReader = EnablerMetricReader;
178
+ exports.EnablerMetricReader = EnablerMetricReader;