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

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 (194) hide show
  1. package/.env.example +17 -3
  2. package/README.md +1 -2
  3. package/dist/cjs/config/bootConfig.cjs +16 -14
  4. package/dist/cjs/config/config.cjs +120 -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/DiskLogExporter.cjs +121 -0
  10. package/dist/cjs/telemetry/custom-implementations/exporters/DiskMetricExporter.cjs +101 -0
  11. package/dist/cjs/telemetry/custom-implementations/exporters/DiskTraceExporter.cjs +103 -0
  12. package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.cjs +194 -190
  13. package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.cjs +147 -99
  14. package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.cjs +143 -116
  15. package/dist/cjs/telemetry/custom-implementations/exporters/MultiMetricExporter.cjs +57 -0
  16. package/dist/cjs/telemetry/custom-implementations/instrumentations/logsInstrumentation.cjs +92 -0
  17. package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/Chunk.cjs +159 -0
  18. package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/Series.cjs +168 -0
  19. package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/SeriesRegistry.cjs +392 -0
  20. package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/types.cjs +2 -0
  21. package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/utils.cjs +77 -0
  22. package/dist/cjs/telemetry/custom-implementations/processors/dynamicMultiLogProcessor.cjs +65 -63
  23. package/dist/cjs/telemetry/custom-implementations/processors/dynamicMultiSpanProcessor.cjs +63 -62
  24. package/dist/cjs/telemetry/custom-implementations/utils/circular.cjs +47 -47
  25. package/dist/cjs/telemetry/custom-implementations/wrappers.cjs +209 -138
  26. package/dist/cjs/telemetry/initializeTelemetry.cjs +35 -91
  27. package/dist/cjs/telemetry/persistence/DiskImporter.cjs +85 -0
  28. package/dist/cjs/telemetry/persistence/DiskUtils.cjs +61 -0
  29. package/dist/cjs/telemetry/persistence/DiskWriter.cjs +66 -0
  30. package/dist/cjs/telemetry/telemetryConfigurator.cjs +139 -72
  31. package/dist/cjs/telemetry/telemetryRegistry.cjs +45 -31
  32. package/dist/cjs/tlm-ai/agent.cjs +49 -64
  33. package/dist/cjs/tlm-ai/aiController.cjs +54 -76
  34. package/dist/cjs/tlm-ai/aiRoutes.cjs +17 -20
  35. package/dist/cjs/tlm-ai/aiService.cjs +91 -95
  36. package/dist/cjs/tlm-ai/tools.cjs +177 -174
  37. package/dist/cjs/tlm-auth/authController.cjs +80 -123
  38. package/dist/cjs/tlm-auth/authMiddleware.cjs +25 -30
  39. package/dist/cjs/tlm-auth/authRoutes.cjs +11 -14
  40. package/dist/cjs/tlm-log/logController.cjs +135 -116
  41. package/dist/cjs/tlm-log/logRoutes.cjs +19 -20
  42. package/dist/cjs/tlm-log/logService.cjs +29 -0
  43. package/dist/cjs/tlm-metric/metricsController.cjs +154 -122
  44. package/dist/cjs/tlm-metric/metricsRoutes.cjs +22 -20
  45. package/dist/cjs/tlm-metric/metricsService.cjs +26 -0
  46. package/dist/cjs/tlm-plugin/pluginController.cjs +128 -140
  47. package/dist/cjs/tlm-plugin/pluginProcess.cjs +89 -94
  48. package/dist/cjs/tlm-plugin/pluginRoutes.cjs +11 -14
  49. package/dist/cjs/tlm-plugin/pluginService.cjs +73 -74
  50. package/dist/cjs/tlm-trace/traceController.cjs +140 -123
  51. package/dist/cjs/tlm-trace/traceRoutes.cjs +19 -20
  52. package/dist/cjs/tlm-trace/traceService.cjs +29 -0
  53. package/dist/cjs/tlm-ui/uiRoutes.cjs +63 -32
  54. package/dist/cjs/tlm-util/utilController.cjs +68 -70
  55. package/dist/cjs/tlm-util/utilRoutes.cjs +51 -63
  56. package/dist/cjs/types/index.cjs +2 -5
  57. package/dist/cjs/utils/logger.cjs +38 -43
  58. package/dist/cjs/utils/regexUtils.cjs +22 -22
  59. package/dist/esm/config/bootConfig.js +5 -2
  60. package/dist/esm/config/config.js +9 -2
  61. package/dist/esm/docs/openapi.yaml +158 -4
  62. package/dist/esm/index.js +9 -8
  63. package/dist/esm/routesManager.js +6 -10
  64. package/dist/esm/telemetry/custom-implementations/exporters/DiskLogExporter.js +114 -0
  65. package/dist/esm/telemetry/custom-implementations/exporters/DiskMetricExporter.js +94 -0
  66. package/dist/esm/telemetry/custom-implementations/exporters/DiskTraceExporter.js +96 -0
  67. package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.js +38 -7
  68. package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.js +107 -48
  69. package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.js +60 -29
  70. package/dist/esm/telemetry/custom-implementations/exporters/MultiMetricExporter.js +53 -0
  71. package/dist/esm/telemetry/custom-implementations/instrumentations/logsInstrumentation.js +85 -0
  72. package/dist/esm/telemetry/custom-implementations/metrics/tsdb/Chunk.js +155 -0
  73. package/dist/esm/telemetry/custom-implementations/metrics/tsdb/Series.js +164 -0
  74. package/dist/esm/telemetry/custom-implementations/metrics/tsdb/SeriesRegistry.js +385 -0
  75. package/dist/esm/telemetry/custom-implementations/metrics/tsdb/types.js +1 -0
  76. package/dist/esm/telemetry/custom-implementations/metrics/tsdb/utils.js +74 -0
  77. package/dist/esm/telemetry/custom-implementations/processors/dynamicMultiLogProcessor.js +2 -1
  78. package/dist/esm/telemetry/custom-implementations/processors/dynamicMultiSpanProcessor.js +1 -1
  79. package/dist/esm/telemetry/custom-implementations/wrappers.js +77 -6
  80. package/dist/esm/telemetry/initializeTelemetry.js +27 -69
  81. package/dist/esm/telemetry/persistence/DiskImporter.js +78 -0
  82. package/dist/esm/telemetry/persistence/DiskUtils.js +51 -0
  83. package/dist/esm/telemetry/persistence/DiskWriter.js +59 -0
  84. package/dist/esm/telemetry/telemetryConfigurator.js +110 -39
  85. package/dist/esm/telemetry/telemetryRegistry.js +12 -1
  86. package/dist/esm/tlm-ai/agent.js +5 -3
  87. package/dist/esm/tlm-ai/aiController.js +3 -3
  88. package/dist/esm/tlm-ai/aiService.js +6 -2
  89. package/dist/esm/tlm-ai/tools.js +5 -9
  90. package/dist/esm/tlm-auth/authController.js +3 -2
  91. package/dist/esm/tlm-log/logController.js +62 -18
  92. package/dist/esm/tlm-log/logRoutes.js +3 -1
  93. package/dist/esm/tlm-log/logService.js +25 -0
  94. package/dist/esm/tlm-metric/metricsController.js +116 -50
  95. package/dist/esm/tlm-metric/metricsRoutes.js +8 -3
  96. package/dist/esm/tlm-metric/metricsService.js +22 -0
  97. package/dist/esm/tlm-plugin/pluginController.js +6 -11
  98. package/dist/esm/tlm-plugin/pluginService.js +2 -4
  99. package/dist/esm/tlm-trace/traceController.js +87 -36
  100. package/dist/esm/tlm-trace/traceRoutes.js +3 -1
  101. package/dist/esm/tlm-trace/traceService.js +25 -0
  102. package/dist/esm/tlm-ui/uiRoutes.js +5 -5
  103. package/dist/esm/tlm-util/utilController.js +3 -9
  104. package/dist/esm/tlm-util/utilRoutes.js +2 -2
  105. package/dist/types/config/bootConfig.d.ts +3 -0
  106. package/dist/types/config/config.d.ts +48 -7
  107. package/dist/types/config/config.types.d.ts +7 -0
  108. package/dist/types/index.d.ts +2 -3
  109. package/dist/types/telemetry/custom-implementations/exporters/DiskLogExporter.d.ts +24 -0
  110. package/dist/types/telemetry/custom-implementations/exporters/DiskMetricExporter.d.ts +23 -0
  111. package/dist/types/telemetry/custom-implementations/exporters/DiskTraceExporter.d.ts +23 -0
  112. package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.d.ts +3 -1
  113. package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.d.ts +56 -15
  114. package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.d.ts +8 -4
  115. package/dist/types/telemetry/custom-implementations/exporters/MultiMetricExporter.d.ts +9 -0
  116. package/dist/types/telemetry/custom-implementations/instrumentations/logsInstrumentation.d.ts +23 -0
  117. package/dist/types/telemetry/custom-implementations/metrics/tsdb/Chunk.d.ts +49 -0
  118. package/dist/types/telemetry/custom-implementations/metrics/tsdb/Series.d.ts +67 -0
  119. package/dist/types/telemetry/custom-implementations/metrics/tsdb/SeriesRegistry.d.ts +69 -0
  120. package/dist/types/telemetry/custom-implementations/metrics/tsdb/types.d.ts +68 -0
  121. package/dist/types/telemetry/custom-implementations/metrics/tsdb/utils.d.ts +21 -0
  122. package/dist/types/telemetry/custom-implementations/processors/dynamicMultiLogProcessor.d.ts +2 -2
  123. package/dist/types/telemetry/custom-implementations/wrappers.d.ts +2 -1
  124. package/dist/types/telemetry/persistence/DiskImporter.d.ts +17 -0
  125. package/dist/types/telemetry/persistence/DiskUtils.d.ts +11 -0
  126. package/dist/types/telemetry/persistence/DiskWriter.d.ts +21 -0
  127. package/dist/types/telemetry/telemetryConfigurator.d.ts +1 -1
  128. package/dist/types/telemetry/telemetryRegistry.d.ts +8 -0
  129. package/dist/types/tlm-ai/agent.d.ts +1 -1
  130. package/dist/types/tlm-ai/aiService.d.ts +1 -1
  131. package/dist/types/tlm-log/logController.d.ts +2 -0
  132. package/dist/types/tlm-log/logService.d.ts +4 -0
  133. package/dist/types/tlm-metric/metricsController.d.ts +11 -2
  134. package/dist/types/tlm-metric/metricsService.d.ts +6 -0
  135. package/dist/types/tlm-trace/traceController.d.ts +9 -7
  136. package/dist/types/tlm-trace/traceService.d.ts +4 -0
  137. package/dist/types/types/index.d.ts +2 -2
  138. package/dist/ui/assets/{ApiDocsPage-C_VVPPHa.js → ApiDocsPage-DTCgVbW2.js} +2 -2
  139. package/dist/ui/assets/CollapsibleCard-lWgfsaAn.js +1 -0
  140. package/dist/ui/assets/DevToolsPage-DEhf8CBy.js +1 -0
  141. package/dist/ui/assets/LandingPage-CfEHCDxY.js +6 -0
  142. package/dist/ui/assets/LogsPage-DFDKRuGH.js +1 -0
  143. package/dist/ui/assets/{NotFoundPage-B3quk3P1.js → NotFoundPage-DCy0DcV7.js} +1 -1
  144. package/dist/ui/assets/PluginCreatePage-BawZ5_-h.js +50 -0
  145. package/dist/ui/assets/PluginPage-D3FmgU7d.js +27 -0
  146. package/dist/ui/assets/TraceSpansPage-D0_L45Rb.js +6 -0
  147. package/dist/ui/assets/VirtualizedListPanel-q605n9He.js +16 -0
  148. package/dist/ui/assets/alert-DBAFshSi.js +1133 -0
  149. package/dist/ui/assets/badge-DGNBtnxU.js +1 -0
  150. package/dist/ui/assets/{chevron-down-CPsvsmqj.js → chevron-down-CFEqYzGC.js} +1 -1
  151. package/dist/ui/assets/{chevron-up-Df9jMo1X.js → chevron-up-lDnFwAJq.js} +1 -1
  152. package/dist/ui/assets/{circle-alert-DOPQPvU8.js → circle-alert-BpYUuRs7.js} +1 -1
  153. package/dist/ui/assets/dialog-1dRyI6SC.js +15 -0
  154. package/dist/ui/assets/index-C7RfU6hR.js +1 -0
  155. package/dist/ui/assets/index-C9dDYIpd.js +305 -0
  156. package/dist/ui/assets/index-D6f1KjWV.css +1 -0
  157. package/dist/ui/assets/info-CuJQWoBU.js +6 -0
  158. package/dist/ui/assets/{input-Dzvg_ZEZ.js → input-BLXaar0X.js} +1 -1
  159. package/dist/ui/assets/label-DfAcltsl.js +1 -0
  160. package/dist/ui/assets/{loader-circle-CrvlRy5o.js → loader-circle-B7oLyPsi.js} +1 -1
  161. package/dist/ui/assets/{loginPage-qa4V-B70.js → loginPage-DswZvOJ-.js} +1 -1
  162. package/dist/ui/assets/metrics-page-BhtXrfUW.js +31 -0
  163. package/dist/ui/assets/metrics-page-D1GxaB_c.css +1 -0
  164. package/dist/ui/assets/popover-IDker85U.js +11 -0
  165. package/dist/ui/assets/select-B8y5IidE.js +6 -0
  166. package/dist/ui/assets/separator-B6EzrxYY.js +6 -0
  167. package/dist/ui/assets/severityOptions-DtCsaAZK.js +11 -0
  168. package/dist/ui/assets/square-pen-D_oecB1x.js +6 -0
  169. package/dist/ui/assets/switch-Dqo0XkRD.js +1 -0
  170. package/dist/ui/assets/trace-DJq1miYa.js +1 -0
  171. package/dist/ui/assets/upload-prIohEdY.js +11 -0
  172. package/dist/ui/assets/{utilService-DNyqzwj0.js → utilService-C8TJKLqs.js} +1 -1
  173. package/dist/ui/assets/wand-sparkles-OgXuzsSx.js +6 -0
  174. package/dist/ui/index.html +2 -2
  175. package/package.json +44 -49
  176. package/dist/ui/assets/CollapsibleCard-B3KR_8mL.js +0 -1
  177. package/dist/ui/assets/DevToolsPage-OyZcDcmw.js +0 -1
  178. package/dist/ui/assets/LandingPage-CppFBA6K.js +0 -6
  179. package/dist/ui/assets/LogsPage-9Fq8GArS.js +0 -26
  180. package/dist/ui/assets/PluginCreatePage-X_aCH4t4.js +0 -50
  181. package/dist/ui/assets/PluginPage-DMDSihrZ.js +0 -27
  182. package/dist/ui/assets/alert-jQ9HCPIf.js +0 -1133
  183. package/dist/ui/assets/badge-CNq0-mH5.js +0 -1
  184. package/dist/ui/assets/card-DFAwwhN3.js +0 -1
  185. package/dist/ui/assets/index-BkD6DijD.js +0 -15
  186. package/dist/ui/assets/index-CERGVYZK.js +0 -292
  187. package/dist/ui/assets/index-CSIPf9qw.css +0 -1
  188. package/dist/ui/assets/label-DuVnkZ4q.js +0 -1
  189. package/dist/ui/assets/select-DhS8YUtJ.js +0 -1
  190. package/dist/ui/assets/separator-isK4chBP.js +0 -6
  191. package/dist/ui/assets/severityOptions-O38dSOfk.js +0 -11
  192. package/dist/ui/assets/switch-Z3mImG9n.js +0 -1
  193. package/dist/ui/assets/tabs-_77MUUQe.js +0 -16
  194. package/dist/ui/assets/upload-C1LT4Gkb.js +0 -16
package/.env.example CHANGED
@@ -10,19 +10,33 @@ OASTLM_BOOT_ENV=
10
10
  OASTLM_BOOT_MODULE_DISABLED=
11
11
  # Logging level for the boot process | Possible values: "DEBUG", "INFO", "WARNING", "ERROR", "NONE" | Default: "INFO"
12
12
  OASTLM_BOOT_LOG_LEVEL=
13
- # The name of your application or service | Default: "SERVICE-<random-uuid>"
13
+ # The name of your application or service | Default: "unkown service"
14
14
  OASTLM_BOOT_SERVICE_NAME=
15
+ # Base URL path for telemetry endpoints (must be set at boot time, cannot be changed at runtime) | Default: "/oas-telemetry"
16
+ OASTLM_BOOT_BASE_URL=
17
+
18
+ # BOOT-AUTO-INSTRUMENTATION CONFIGURATION --------------------------------
19
+ # These variables control the auto-instrumentation registration at boot time.
20
+ # ----------------------------------------------------------------------
21
+ # Disable Node.js instrumentation auto-registration | Possible values: "true", "false" | Default: "false"
22
+ OASTLM_BOOT_AUTOINSTRUMENTATIONS_NODE_DISABLED=
23
+ # Disable logs instrumentation auto-registration | Possible values: "true", "false" | Default: "false"
24
+ OASTLM_BOOT_AUTOINSTRUMENTATIONS_LOGS_DISABLED=
15
25
 
16
26
 
17
27
  # CONFIGURATION --------------------------------------------------------
18
28
  # These variables are used to override the configuration when oasTelemetry(config) is called.
19
29
  # ----------------------------------------------------------------------
20
30
 
21
- # Base URL for telemetry | Default: "/telemetry"
22
- OASTLM_CONFIG_GENERAL_BASE_URL=
23
31
  # Specification file name | Default: null
24
32
  OASTLM_CONFIG_GENERAL_SPEC_FILE_NAME=
25
33
 
34
+ # Storage path: empty string = in-memory, else = disk storage at specified path | Default: empty string (in-memory)
35
+ OASTLM_CONFIG_STORAGE_PATH=
36
+ # Optional override for startup disk import behavior
37
+ # Priority: OASTLM_CONFIG_STORAGE_LOAD_FROM_START > userConfig.storage.loadFromStart > defaultConfig
38
+ OASTLM_CONFIG_STORAGE_LOAD_FROM_START=
39
+
26
40
 
27
41
  # Enable authentication | Possible values: "true", "false" | Default: "false"
28
42
  OASTLM_CONFIG_AUTH_ENABLED=
package/README.md CHANGED
@@ -92,7 +92,6 @@ You can also customize the telemetry configuration by passing options to the mid
92
92
  ```js
93
93
  export const customTelemetryConfig = {
94
94
  general: {
95
- baseUrl: "/custom-telemetry",
96
95
  specFileName: "oas.json",
97
96
  spec: null,
98
97
  },
@@ -162,7 +161,7 @@ app.use(oasTelemetry(customTelemetryConfig));
162
161
 
163
162
  ## Telemetry UI
164
163
 
165
- You can access the telemetry UI at the endpoint `/telemetry` (or `/custom-telemetry` if you set the `baseURL` option). This UI provides a user-friendly interface to interact with the telemetry data collected by the middleware.
164
+ You can access the telemetry UI at the endpoint `/oas-telemetry` (or at a custom path if you set the `OASTLM_BOOT_BASE_URL` environment variable). This UI provides a user-friendly interface to interact with the telemetry data collected by the middleware.
166
165
 
167
166
  ## Rest API Endpoints Overview
168
167
 
@@ -1,20 +1,22 @@
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.bootEnvVariables = void 0;
7
- var _dotenv = _interopRequireDefault(require("dotenv"));
8
- var _crypto = require("crypto");
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
+ const dotenv_1 = __importDefault(require("dotenv"));
10
8
  if (process.env.NODE_ENV !== 'test') {
11
- _dotenv.default.config();
9
+ dotenv_1.default.config();
12
10
  }
13
11
  // This variables can NOT be configured via oasTelemetry(config)
14
12
  // They are used at the import of the library
15
- const bootEnvVariables = exports.bootEnvVariables = {
16
- OASTLM_BOOT_ENV: process.env.OASTLM_BOOT_ENV || process.env.NODE_ENV || 'production',
17
- OASTLM_BOOT_MODULE_DISABLED: process.env.OASTLM_BOOT_MODULE_DISABLED === 'true',
18
- OASTLM_BOOT_LOG_LEVEL: process.env.OASTLM_BOOT_LOG_LEVEL || 'INFO',
19
- OASTLM_BOOT_SERVICE_NAME: process.env.OASTLM_BOOT_SERVICE_NAME || `SERVICE-${(0, _crypto.randomUUID)().slice(0, 8).toUpperCase()}`
20
- };
13
+ exports.bootEnvVariables = {
14
+ OASTLM_BOOT_ENV: process.env.OASTLM_BOOT_ENV || process.env.NODE_ENV || 'production',
15
+ OASTLM_BOOT_MODULE_DISABLED: process.env.OASTLM_BOOT_MODULE_DISABLED === 'true',
16
+ OASTLM_BOOT_LOG_LEVEL: process.env.OASTLM_BOOT_LOG_LEVEL || 'INFO',
17
+ OASTLM_BOOT_SERVICE_NAME: process.env.OASTLM_BOOT_SERVICE_NAME || 'unkown service',
18
+ OASTLM_BOOT_BASE_URL: process.env.OASTLM_BOOT_BASE_URL || '/oas-telemetry',
19
+ OASTLM_BOOT_AUTOINSTRUMENTATIONS_NODE_DISABLED: process.env.OASTLM_BOOT_AUTOINSTRUMENTATIONS_NODE_DISABLED == 'true',
20
+ OASTLM_BOOT_AUTOINSTRUMENTATIONS_LOGS_DISABLED: process.env.OASTLM_BOOT_AUTOINSTRUMENTATIONS_LOGS_DISABLED == 'true',
21
+ };
22
+ // REMEMBER TO UPDATE THE .env.example FILE WITH ANY NEW BOOT VARIABLE ADDED HERE.
@@ -1,147 +1,142 @@
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.getConfig = exports.defaultConfig = void 0;
7
- var _lodash = _interopRequireDefault(require("lodash.merge"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
+ const lodash_merge_1 = __importDefault(require("lodash.merge"));
9
8
  // Environment-level config (highest priority)
10
9
  // If NOT defined, it should return UNDEFINED so it dose not override the userConfig or defaultConfig.
11
10
  // Thats why we use getParsedEnvVar with no default value.
12
11
  const loadEnv = () => {
13
- return {
14
- general: {
15
- baseUrl: getParsedEnvVar("OASTLM_CONFIG_GENERAL_BASE_URL"),
16
- specFileName: getParsedEnvVar("OASTLM_CONFIG_GENERAL_SPEC_FILE_NAME")
17
- // spec Not settable via env
18
- },
19
- auth: {
20
- enabled: getParsedEnvVar("OASTLM_CONFIG_AUTH_ENABLED", v => v === "true"),
21
- password: getParsedEnvVar("OASTLM_CONFIG_AUTH_PASSWORD"),
22
- jwtSecret: getParsedEnvVar("OASTLM_CONFIG_AUTH_JWT_SECRET"),
23
- accessTokenMaxAge: getParsedEnvVar("OASTLM_CONFIG_AUTH_ACCESS_TOKEN_MAX_AGE", v => parseInt(v, 10)),
24
- refreshTokenMaxAge: getParsedEnvVar("OASTLM_CONFIG_AUTH_REFRESH_TOKEN_MAX_AGE", v => parseInt(v, 10))
25
- },
26
- traces: {
27
- memoryExporter: {
28
- enabled: getParsedEnvVar("OASTLM_CONFIG_TRACES_MEMORY_EXPORTER_ENABLED", v => v === "true"),
29
- retentionTimeSeconds: getParsedEnvVar("OASTLM_CONFIG_TRACES_MEMORY_EXPORTER_RETENTION_TIME_SECONDS", v => parseInt(v, 10))
30
- // filters NOT settable via env
31
- }
32
- },
33
- metrics: {
34
- mainMetricReaderOptions: {
35
- exportIntervalMillis: getParsedEnvVar("OASTLM_CONFIG_METRICS_MAIN_READER_EXPORT_INTERVAL", v => parseInt(v, 10))
36
- // metricProducers NOT settable via env
37
- },
38
- memoryExporter: {
39
- enabled: getParsedEnvVar("OASTLM_CONFIG_METRICS_MEMORY_EXPORTER_ENABLED", v => v === "true"),
40
- retentionTimeSeconds: getParsedEnvVar("OASTLM_CONFIG_METRICS_MEMORY_EXPORTER_RETENTION_TIME_SECONDS", v => parseInt(v, 10))
41
- // filters NOT settable via env
42
- }
43
- },
44
- logs: {
45
- memoryExporter: {
46
- enabled: getParsedEnvVar("OASTLM_CONFIG_LOGS_MEMORY_EXPORTER_ENABLED", v => v === "true"),
47
- retentionTimeSeconds: getParsedEnvVar("OASTLM_CONFIG_LOGS_MEMORY_EXPORTER_RETENTION_TIME_SECONDS", v => parseInt(v, 10))
48
- // filters NOT settable via env
49
- }
50
- },
51
- ai: {
52
- openAIKey: getParsedEnvVar("OASTLM_CONFIG_AI_OPENAI_KEY"),
53
- openAIModel: getParsedEnvVar("OASTLM_CONFIG_AI_OPENAI_MODEL", v => v || "gpt-3.5-turbo"),
54
- extraContextPrompts: getParsedEnvVar("OASTLM_CONFIG_AI_EXTRA_CONTEXT_PROMPTS", v => v ? v.split(',') : [])
55
- }
56
- };
12
+ return {
13
+ general: {
14
+ specFileName: getParsedEnvVar("OASTLM_CONFIG_GENERAL_SPEC_FILE_NAME"),
15
+ // spec Not settable via env
16
+ },
17
+ storage: {
18
+ path: getParsedEnvVar("OASTLM_CONFIG_STORAGE_PATH"),
19
+ loadFromStart: getParsedEnvVar("OASTLM_CONFIG_STORAGE_LOAD_FROM_START", (v) => v === "true"),
20
+ },
21
+ auth: {
22
+ enabled: getParsedEnvVar("OASTLM_CONFIG_AUTH_ENABLED", (v) => v === "true"),
23
+ password: getParsedEnvVar("OASTLM_CONFIG_AUTH_PASSWORD"),
24
+ jwtSecret: getParsedEnvVar("OASTLM_CONFIG_AUTH_JWT_SECRET"),
25
+ accessTokenMaxAge: getParsedEnvVar("OASTLM_CONFIG_AUTH_ACCESS_TOKEN_MAX_AGE", (v) => parseInt(v, 10)),
26
+ refreshTokenMaxAge: getParsedEnvVar("OASTLM_CONFIG_AUTH_REFRESH_TOKEN_MAX_AGE", (v) => parseInt(v, 10)),
27
+ },
28
+ traces: {
29
+ memoryExporter: {
30
+ enabled: getParsedEnvVar("OASTLM_CONFIG_TRACES_MEMORY_EXPORTER_ENABLED", (v) => v === "true"),
31
+ retentionTimeSeconds: getParsedEnvVar("OASTLM_CONFIG_TRACES_MEMORY_EXPORTER_RETENTION_TIME_SECONDS", (v) => parseInt(v, 10)),
32
+ // filters NOT settable via env
33
+ }
34
+ },
35
+ metrics: {
36
+ mainMetricReaderOptions: {
37
+ exportIntervalMillis: getParsedEnvVar("OASTLM_CONFIG_METRICS_MAIN_READER_EXPORT_INTERVAL", (v) => parseInt(v, 10)),
38
+ // metricProducers NOT settable via env
39
+ },
40
+ memoryExporter: {
41
+ enabled: getParsedEnvVar("OASTLM_CONFIG_METRICS_MEMORY_EXPORTER_ENABLED", (v) => v === "true"),
42
+ retentionTimeSeconds: getParsedEnvVar("OASTLM_CONFIG_METRICS_MEMORY_EXPORTER_RETENTION_TIME_SECONDS", (v) => parseInt(v, 10)),
43
+ // filters NOT settable via env
44
+ }
45
+ },
46
+ logs: {
47
+ memoryExporter: {
48
+ enabled: getParsedEnvVar("OASTLM_CONFIG_LOGS_MEMORY_EXPORTER_ENABLED", (v) => v === "true"),
49
+ retentionTimeSeconds: getParsedEnvVar("OASTLM_CONFIG_LOGS_MEMORY_EXPORTER_RETENTION_TIME_SECONDS", (v) => parseInt(v, 10)),
50
+ // filters NOT settable via env
51
+ },
52
+ },
53
+ ai: {
54
+ openAIKey: getParsedEnvVar("OASTLM_CONFIG_AI_OPENAI_KEY"),
55
+ openAIModel: getParsedEnvVar("OASTLM_CONFIG_AI_OPENAI_MODEL", (v) => v || "gpt-3.5-turbo"),
56
+ extraContextPrompts: getParsedEnvVar("OASTLM_CONFIG_AI_EXTRA_CONTEXT_PROMPTS", (v) => v ? v.split(',') : []),
57
+ },
58
+ };
57
59
  };
58
60
  // This defines de OasTlmConfig type, which is used throughout the library.
59
61
  // Please ensure that all possible types are included here, not only the defaults.
60
62
  // e.g. .ai.openAIKey: null as string | null, default is null, but can be set to a string.
61
63
  // NOTE: Some BOOT environment variables (e.g., OASTLM_BOOT_MODULE_DISABLED) are accessed before this config is loaded.
62
64
  // This means certain settings may affect application startup behavior outside of this configuration system.
63
- const defaultConfig = exports.defaultConfig = {
64
- general: {
65
- baseUrl: "/telemetry",
66
- specFileName: null,
67
- // e.g. "oas.json" or null if not provided
68
- spec: null,
69
- // e.g. JSON.stringify(oasSpec) or null if not provided,
70
- uiPath: "/oas-telemetry-ui" // path to the UI, e.g. "/oas-telemetry-ui" WARN: This must match the UI package's App.tsx "oas-telemetry-ui" path
71
- },
72
- auth: {
73
- enabled: false,
74
- password: "oas-telemetry-password",
75
- jwtSecret: "oas-telemetry-secret",
76
- accessTokenMaxAge: 1000 * 60 * 5,
77
- // 5 minutes
78
- refreshTokenMaxAge: 1000 * 60 * 60 * 24 * 7 // 7 days
79
- },
80
- ai: {
81
- openAIKey: null,
82
- openAIModel: "gpt-3.5-turbo",
83
- extraContextPrompts: [] // e.g. ["Provide detailed explanations", "Use simple language"]
84
- },
85
- traces: {
86
- extraExporters: [],
87
- // e.g. [new ConsoleSpanExporter()]
88
- extraProcessors: [],
89
- // e.g. [new SimpleSpanProcessor(new ConsoleSpanExporter())]
90
- mainProcessorOptions: {
91
- config: undefined
65
+ exports.defaultConfig = {
66
+ general: {
67
+ specFileName: null, // e.g. "oas.json" or null if not provided
68
+ spec: null, // e.g. JSON.stringify(oasSpec) or null if not provided,
69
+ uiPath: "/oas-telemetry-ui", // path to the UI, e.g. "/oas-telemetry-ui" WARN: This must match the UI package's App.tsx "oas-telemetry-ui" path
92
70
  },
93
- memoryExporter: {
94
- enabled: true,
95
- // auto start exporting.
96
- retentionTimeSeconds: 60 * 60 // 1 hour
71
+ storage: {
72
+ path: null, // Optional disk persistence directory.
73
+ loadFromStart: true, // If true, import persisted telemetry into memory at startup.
97
74
  },
98
- filters: [] // future feature, currently not used
99
- },
100
- metrics: {
101
- mainMetricReaderOptions: {
102
- exportIntervalMillis: 1000 * 60,
103
- // 60 seconds
104
- metricProducers: [] // experimental by OpenTelemetry, not used by OAS-TLM yet
75
+ auth: {
76
+ enabled: false,
77
+ password: "oas-telemetry-password",
78
+ jwtSecret: "oas-telemetry-secret",
79
+ accessTokenMaxAge: 1000 * 60 * 5, // 5 minutes
80
+ refreshTokenMaxAge: 1000 * 60 * 60 * 24 * 7, // 7 days
105
81
  },
106
- extraReaders: [],
107
- // e.g. [new PrometheusExporter()]
108
- extraViews: [],
109
- // e.g. [new MetricView({ name: 'my_metric', labels: ['env'] })]
110
- memoryExporter: {
111
- enabled: true,
112
- retentionTimeSeconds: 60 * 60 // 1 hour
82
+ ai: {
83
+ openAIKey: null,
84
+ openAIModel: "gpt-3.5-turbo",
85
+ extraContextPrompts: [], // e.g. ["Provide detailed explanations", "Use simple language"]
113
86
  },
114
- filters: [] // future feature, currently not used
115
- },
116
- logs: {
117
- extraExporters: [],
118
- // e.g. [new ConsoleLogRecordExporter()]
119
- extraProcessors: [],
120
- // e.g. [new SimpleLogRecordProcessor(new ConsoleLogRecordExporter())]
121
- memoryExporter: {
122
- enabled: true,
123
- retentionTimeSeconds: 60 * 60 // 1 hour
87
+ traces: {
88
+ extraExporters: [], // e.g. [new ConsoleSpanExporter()]
89
+ extraProcessors: [], // e.g. [new SimpleSpanProcessor(new ConsoleSpanExporter())]
90
+ mainProcessorOptions: {
91
+ config: undefined
92
+ },
93
+ memoryExporter: {
94
+ enabled: true, // auto start exporting.
95
+ retentionTimeSeconds: 60 * 60, // 1 hour
96
+ },
97
+ filters: [], // future feature, currently not used
124
98
  },
125
- filters: [] // future feature, currently not used
126
- },
127
- plugins: {
128
- enabled: true,
129
- // future feature
130
- extraPlugins: [] // future feature
131
- }
99
+ metrics: {
100
+ mainMetricReaderOptions: {
101
+ exportIntervalMillis: 1000 * 60, // 60 seconds
102
+ metricProducers: [], // experimental by OpenTelemetry, not used by OAS-TLM yet
103
+ },
104
+ extraReaders: [], // e.g. [new PrometheusExporter()]
105
+ extraViews: [], // e.g. [new MetricView({ name: 'my_metric', labels: ['env'] })]
106
+ memoryExporter: {
107
+ enabled: true,
108
+ retentionTimeSeconds: 60 * 60, // 1 hour
109
+ },
110
+ filters: [], // future feature, currently not used
111
+ },
112
+ logs: {
113
+ extraExporters: [], // e.g. [new ConsoleLogRecordExporter()]
114
+ extraProcessors: [], // e.g. [new SimpleLogRecordProcessor(new ConsoleLogRecordExporter())]
115
+ memoryExporter: {
116
+ enabled: true,
117
+ retentionTimeSeconds: 60 * 60, // 1 hour
118
+ },
119
+ filters: [], // future feature, currently not used
120
+ },
121
+ plugins: {
122
+ enabled: true, // future feature
123
+ extraPlugins: [], // future feature
124
+ },
125
+ instrumentations: [],
132
126
  };
133
127
  // Helper to get an environment variable with optional transform
134
128
  const getParsedEnvVar = (envKey, transform) => {
135
- const rawValue = process.env[envKey];
136
- // Treat undefined and "" in env as undefined (skip)
137
- if (rawValue === undefined || rawValue === "") return undefined;
138
- if (typeof transform === 'function') {
139
- return transform(rawValue);
140
- }
141
- return rawValue;
129
+ const rawValue = process.env[envKey];
130
+ // Treat undefined and "" in env as undefined (skip)
131
+ if (rawValue === undefined || rawValue === "")
132
+ return undefined;
133
+ if (typeof transform === 'function') {
134
+ return transform(rawValue);
135
+ }
136
+ return rawValue;
142
137
  };
143
- const getConfig = (userConfig, fallbackConfig = defaultConfig, envConfig = loadEnv()) => {
144
- // environment variables OVERRIDE userConfig OVERRIDE fallbackConfig
145
- return (0, _lodash.default)({}, fallbackConfig, userConfig, envConfig);
138
+ const getConfig = (userConfig, fallbackConfig = exports.defaultConfig, envConfig = loadEnv()) => {
139
+ // environment variables OVERRIDE userConfig OVERRIDE fallbackConfig
140
+ return (0, lodash_merge_1.default)({}, fallbackConfig, userConfig, envConfig);
146
141
  };
147
- exports.getConfig = getConfig;
142
+ exports.getConfig = getConfig;
@@ -1,5 +1,2 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -31,8 +31,8 @@ servers:
31
31
  port:
32
32
  default: "3000"
33
33
  basePath:
34
- default: telemetry
35
- description: Base path for all endpoints. Can be customized, e.g. "myCustomTelemetryPath"
34
+ default: oas-telemetry
35
+ description: Base path for all endpoints. Configured via OASTLM_BOOT_BASE_URL environment variable
36
36
 
37
37
  tags:
38
38
  - name: traces
@@ -326,6 +326,44 @@ paths:
326
326
  type: string
327
327
  example: Invalid retention time. Must be a positive number.
328
328
 
329
+ /traces/export:
330
+ get:
331
+ tags:
332
+ - traces
333
+ summary: Export collected traces
334
+ description: Export all collected traces in line-delimited JSON format
335
+ responses:
336
+ '200':
337
+ description: Traces exported successfully
338
+ content:
339
+ application/json:
340
+ schema:
341
+ type: string
342
+
343
+ /traces/import:
344
+ post:
345
+ tags:
346
+ - traces
347
+ summary: Import traces
348
+ description: Import traces from line-delimited JSON format
349
+ requestBody:
350
+ required: true
351
+ content:
352
+ application/json:
353
+ schema:
354
+ type: string
355
+ responses:
356
+ '200':
357
+ description: Traces imported successfully
358
+ content:
359
+ application/json:
360
+ schema:
361
+ type: object
362
+ properties:
363
+ message:
364
+ type: string
365
+ example: Traces imported successfully
366
+
329
367
  /metrics:
330
368
  get:
331
369
  summary: Get collected metrics
@@ -548,6 +586,69 @@ paths:
548
586
  type: string
549
587
  example: Invalid retention time. Must be a positive number.
550
588
 
589
+ /metrics/export:
590
+ get:
591
+ tags:
592
+ - metrics
593
+ summary: Export collected metrics
594
+ description: Export all collected metrics in line-delimited JSON format
595
+ responses:
596
+ '200':
597
+ description: Metrics exported successfully
598
+ content:
599
+ application/json:
600
+ schema:
601
+ type: string
602
+
603
+ /metrics/import:
604
+ post:
605
+ tags:
606
+ - metrics
607
+ summary: Import metrics
608
+ description: Import metrics from line-delimited JSON format
609
+ requestBody:
610
+ required: true
611
+ content:
612
+ application/json:
613
+ schema:
614
+ type: string
615
+ responses:
616
+ '200':
617
+ description: Metrics imported successfully
618
+ content:
619
+ application/json:
620
+ schema:
621
+ type: object
622
+ properties:
623
+ message:
624
+ type: string
625
+ example: Metrics imported successfully
626
+
627
+ /metrics/stats:
628
+ get:
629
+ tags:
630
+ - metrics
631
+ summary: Get metrics statistics
632
+ description: Get statistics about collected metrics
633
+ responses:
634
+ '200':
635
+ description: Metrics statistics retrieved successfully
636
+ content:
637
+ application/json:
638
+ schema:
639
+ type: object
640
+ properties:
641
+ totalMetrics:
642
+ type: number
643
+ example: 42
644
+ activeMetrics:
645
+ type: number
646
+ example: 35
647
+ retentionTime:
648
+ type: number
649
+ description: Retention time in seconds
650
+ example: 3600
651
+
551
652
  /logs:
552
653
  get:
553
654
  summary: Get collected logs
@@ -683,6 +784,44 @@ paths:
683
784
  type: string
684
785
  example: Invalid regex in query
685
786
 
787
+ /logs/export:
788
+ get:
789
+ tags:
790
+ - logs
791
+ summary: Export collected logs
792
+ description: Export all collected logs in line-delimited JSON format
793
+ responses:
794
+ '200':
795
+ description: Logs exported successfully
796
+ content:
797
+ application/json:
798
+ schema:
799
+ type: string
800
+
801
+ /logs/import:
802
+ post:
803
+ tags:
804
+ - logs
805
+ summary: Import logs
806
+ description: Import logs from line-delimited JSON format
807
+ requestBody:
808
+ required: true
809
+ content:
810
+ application/json:
811
+ schema:
812
+ type: string
813
+ responses:
814
+ '200':
815
+ description: Logs imported successfully
816
+ content:
817
+ application/json:
818
+ schema:
819
+ type: object
820
+ properties:
821
+ message:
822
+ type: string
823
+ example: Logs imported successfully
824
+
686
825
  /utils/spec:
687
826
  get:
688
827
  summary: Get OpenAPI spec in JSON
@@ -842,14 +981,14 @@ paths:
842
981
  type: string
843
982
  example: Started generating mock logs
844
983
 
845
- /utils/generate-wait/{seconds}:
984
+ /utils/generate-wait:
846
985
  get:
847
986
  summary: Wait for the specified seconds
848
987
  tags:
849
988
  - utils
850
989
  parameters:
851
990
  - name: seconds
852
- in: path
991
+ in: query
853
992
  required: false
854
993
  schema:
855
994
  type: integer
@@ -867,6 +1006,21 @@ paths:
867
1006
  type: number
868
1007
  example: 2
869
1008
 
1009
+ /utils/oas-telemetry-spec:
1010
+ get:
1011
+ summary: Get OAS-Telemetry specification
1012
+ tags:
1013
+ - utils
1014
+ description: Retrieve the OpenAPI specification for OAS-Telemetry
1015
+ responses:
1016
+ '200':
1017
+ description: OK
1018
+ content:
1019
+ application/json:
1020
+ schema:
1021
+ type: object
1022
+ description: OpenAPI specification
1023
+
870
1024
  /health:
871
1025
  get:
872
1026
  summary: Health check
@@ -1,38 +1,35 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = oasTelemetry;
7
- var _bootConfig = require("./config/bootConfig.cjs");
8
- require("./telemetry/initializeTelemetry.cjs");
9
- var _logger = _interopRequireDefault(require("./utils/logger.cjs"));
10
- var _config = require("./config/config.cjs");
11
- var _express = require("express");
12
- var _routesManager = require("./routesManager.cjs");
13
- var _telemetryConfigurator = require("./telemetry/telemetryConfigurator.cjs");
14
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
- // Load environment variables before any other imports
16
- // Initialize OpenTelemetry instrumentation
17
-
18
- // WARN: If changed the API, also change in packages/lib/src/types/cjs-index.d.ts (used for CJS compilation)
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.oasTelemetry = oasTelemetry;
7
+ require("./config/bootConfig.cjs"); // Load environment variables before any other imports
8
+ require("./telemetry/initializeTelemetry.cjs"); // Initialize OpenTelemetry instrumentation
9
+ const logger_js_1 = __importDefault(require("./utils/logger.cjs"));
10
+ const config_js_1 = require("./config/config.cjs");
11
+ const express_1 = require("express");
12
+ const routesManager_js_1 = require("./routesManager.cjs");
13
+ const telemetryConfigurator_js_1 = require("./telemetry/telemetryConfigurator.cjs");
14
+ const telemetryRegistry_js_1 = require("./telemetry/telemetryRegistry.cjs");
15
+ const bootConfig_js_1 = require("./config/bootConfig.cjs");
19
16
  /**
20
17
  * Returns the OAS-Telemetry middleware.
21
18
  * All parameters are optional. However, either `spec` or `specFileName` must be provided to enable endpoint filtering.
22
19
  */
23
20
  function oasTelemetry(oasTlmInputConfig) {
24
- const router = (0, _express.Router)();
25
- // This environment variable cannot be set via the config object,
26
- // as it is required to disable OpenTelemetry SDK initialization,
27
- // which occurs during the first import at the top of this file.
28
- if (_bootConfig.bootEnvVariables.OASTLM_BOOT_MODULE_DISABLED) {
21
+ if ((0, telemetryRegistry_js_1.isTelemetryConfigured)()) {
22
+ return (0, telemetryRegistry_js_1.getTelemetryRouter)();
23
+ }
24
+ const router = (0, express_1.Router)();
25
+ if (bootConfig_js_1.bootEnvVariables.OASTLM_BOOT_MODULE_DISABLED) {
26
+ (0, telemetryRegistry_js_1.setTelemetryRouter)(router);
27
+ return router;
28
+ }
29
+ const oasTlmConfig = (0, config_js_1.getConfig)(oasTlmInputConfig);
30
+ logger_js_1.default.info("BaseUrl: ", bootConfig_js_1.bootEnvVariables.OASTLM_BOOT_BASE_URL);
31
+ (0, telemetryConfigurator_js_1.configureTelemetry)(oasTlmConfig);
32
+ (0, routesManager_js_1.configureRoutes)(router, oasTlmConfig);
33
+ (0, telemetryRegistry_js_1.setTelemetryRouter)(router);
29
34
  return router;
30
- }
31
- const oasTlmConfig = (0, _config.getConfig)(oasTlmInputConfig);
32
- _logger.default.info("BaseUrl: ", oasTlmConfig.general.baseUrl);
33
- if (!oasTlmConfig.general.spec && !oasTlmConfig.general.specFileName) _logger.default.warn("No spec provided, endpoint filtering will not be available. Please provide either `spec` or `specFileName` in the configuration.");
34
- (0, _telemetryConfigurator.configureTelemetry)(oasTlmConfig);
35
- (0, _routesManager.configureRoutes)(router, oasTlmConfig);
36
- return router;
37
35
  }
38
- module.exports = exports.default;