@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.
- package/.env.example +21 -2
- package/README.md +1 -2
- package/dist/cjs/config/bootConfig.cjs +19 -14
- package/dist/cjs/config/config.cjs +112 -125
- package/dist/cjs/config/config.types.cjs +1 -4
- package/dist/cjs/docs/openapi.yaml +158 -4
- package/dist/cjs/index.cjs +27 -30
- package/dist/cjs/routesManager.cjs +62 -70
- package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.cjs +202 -190
- package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.cjs +204 -99
- package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.cjs +152 -116
- package/dist/cjs/telemetry/custom-implementations/instrumentations/logsInstrumentation.cjs +92 -0
- package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/Chunk.cjs +159 -0
- package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/Series.cjs +168 -0
- package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/SeriesRegistry.cjs +389 -0
- package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/types.cjs +2 -0
- package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/utils.cjs +77 -0
- package/dist/cjs/telemetry/custom-implementations/processors/dynamicMultiLogProcessor.cjs +65 -63
- package/dist/cjs/telemetry/custom-implementations/processors/dynamicMultiSpanProcessor.cjs +63 -62
- package/dist/cjs/telemetry/custom-implementations/utils/circular.cjs +47 -47
- package/dist/cjs/telemetry/custom-implementations/utils/storagePath.cjs +39 -0
- package/dist/cjs/telemetry/custom-implementations/wrappers.cjs +141 -138
- package/dist/cjs/telemetry/initializeTelemetry.cjs +35 -91
- package/dist/cjs/telemetry/telemetryConfigurator.cjs +70 -72
- package/dist/cjs/telemetry/telemetryRegistry.cjs +45 -31
- package/dist/cjs/tlm-ai/agent.cjs +49 -64
- package/dist/cjs/tlm-ai/aiController.cjs +54 -76
- package/dist/cjs/tlm-ai/aiRoutes.cjs +17 -20
- package/dist/cjs/tlm-ai/aiService.cjs +91 -95
- package/dist/cjs/tlm-ai/tools.cjs +177 -174
- package/dist/cjs/tlm-auth/authController.cjs +80 -123
- package/dist/cjs/tlm-auth/authMiddleware.cjs +25 -30
- package/dist/cjs/tlm-auth/authRoutes.cjs +11 -14
- package/dist/cjs/tlm-log/logController.cjs +171 -116
- package/dist/cjs/tlm-log/logRoutes.cjs +20 -20
- package/dist/cjs/tlm-metric/metricsController.cjs +211 -121
- package/dist/cjs/tlm-metric/metricsRoutes.cjs +23 -20
- package/dist/cjs/tlm-plugin/pluginController.cjs +128 -140
- package/dist/cjs/tlm-plugin/pluginProcess.cjs +89 -94
- package/dist/cjs/tlm-plugin/pluginRoutes.cjs +11 -14
- package/dist/cjs/tlm-plugin/pluginService.cjs +73 -74
- package/dist/cjs/tlm-trace/traceController.cjs +169 -117
- package/dist/cjs/tlm-trace/traceRoutes.cjs +20 -20
- package/dist/cjs/tlm-ui/uiRoutes.cjs +63 -32
- package/dist/cjs/tlm-util/utilController.cjs +68 -70
- package/dist/cjs/tlm-util/utilRoutes.cjs +51 -63
- package/dist/cjs/types/index.cjs +2 -5
- package/dist/cjs/utils/logger.cjs +38 -43
- package/dist/cjs/utils/regexUtils.cjs +22 -22
- package/dist/esm/config/bootConfig.js +6 -0
- package/dist/esm/config/config.js +1 -2
- package/dist/esm/docs/openapi.yaml +158 -4
- package/dist/esm/index.js +9 -8
- package/dist/esm/routesManager.js +6 -10
- package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.js +47 -8
- package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.js +164 -48
- package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.js +69 -29
- package/dist/esm/telemetry/custom-implementations/instrumentations/logsInstrumentation.js +85 -0
- package/dist/esm/telemetry/custom-implementations/metrics/tsdb/Chunk.js +155 -0
- package/dist/esm/telemetry/custom-implementations/metrics/tsdb/Series.js +164 -0
- package/dist/esm/telemetry/custom-implementations/metrics/tsdb/SeriesRegistry.js +382 -0
- package/dist/esm/telemetry/custom-implementations/metrics/tsdb/types.js +1 -0
- package/dist/esm/telemetry/custom-implementations/metrics/tsdb/utils.js +74 -0
- package/dist/esm/telemetry/custom-implementations/processors/dynamicMultiLogProcessor.js +2 -1
- package/dist/esm/telemetry/custom-implementations/processors/dynamicMultiSpanProcessor.js +1 -1
- package/dist/esm/telemetry/custom-implementations/utils/storagePath.js +33 -0
- package/dist/esm/telemetry/custom-implementations/wrappers.js +5 -2
- package/dist/esm/telemetry/initializeTelemetry.js +27 -69
- package/dist/esm/telemetry/telemetryConfigurator.js +42 -40
- package/dist/esm/telemetry/telemetryRegistry.js +12 -1
- package/dist/esm/tlm-ai/agent.js +5 -3
- package/dist/esm/tlm-ai/aiController.js +3 -3
- package/dist/esm/tlm-ai/aiService.js +6 -2
- package/dist/esm/tlm-ai/tools.js +5 -9
- package/dist/esm/tlm-auth/authController.js +3 -2
- package/dist/esm/tlm-log/logController.js +84 -4
- package/dist/esm/tlm-log/logRoutes.js +5 -2
- package/dist/esm/tlm-metric/metricsController.js +172 -49
- package/dist/esm/tlm-metric/metricsRoutes.js +10 -4
- package/dist/esm/tlm-plugin/pluginController.js +6 -11
- package/dist/esm/tlm-plugin/pluginService.js +2 -4
- package/dist/esm/tlm-trace/traceController.js +102 -16
- package/dist/esm/tlm-trace/traceRoutes.js +5 -2
- package/dist/esm/tlm-ui/uiRoutes.js +5 -5
- package/dist/esm/tlm-util/utilController.js +3 -9
- package/dist/esm/tlm-util/utilRoutes.js +2 -2
- package/dist/types/config/bootConfig.d.ts +4 -0
- package/dist/types/config/config.d.ts +36 -7
- package/dist/types/config/config.types.d.ts +6 -0
- package/dist/types/index.d.ts +2 -3
- package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.d.ts +4 -1
- package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.d.ts +60 -15
- package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.d.ts +9 -4
- package/dist/types/telemetry/custom-implementations/instrumentations/logsInstrumentation.d.ts +23 -0
- package/dist/types/telemetry/custom-implementations/metrics/tsdb/Chunk.d.ts +49 -0
- package/dist/types/telemetry/custom-implementations/metrics/tsdb/Series.d.ts +67 -0
- package/dist/types/telemetry/custom-implementations/metrics/tsdb/SeriesRegistry.d.ts +69 -0
- package/dist/types/telemetry/custom-implementations/metrics/tsdb/types.d.ts +68 -0
- package/dist/types/telemetry/custom-implementations/metrics/tsdb/utils.d.ts +21 -0
- package/dist/types/telemetry/custom-implementations/processors/dynamicMultiLogProcessor.d.ts +2 -2
- package/dist/types/telemetry/custom-implementations/utils/storagePath.d.ts +12 -0
- package/dist/types/telemetry/custom-implementations/wrappers.d.ts +1 -1
- package/dist/types/telemetry/telemetryConfigurator.d.ts +1 -1
- package/dist/types/telemetry/telemetryRegistry.d.ts +8 -0
- package/dist/types/tlm-ai/agent.d.ts +1 -1
- package/dist/types/tlm-ai/aiService.d.ts +1 -1
- package/dist/types/tlm-log/logController.d.ts +2 -0
- package/dist/types/tlm-metric/metricsController.d.ts +16 -2
- package/dist/types/tlm-trace/traceController.d.ts +3 -1
- package/dist/types/types/index.d.ts +2 -2
- package/dist/ui/assets/{ApiDocsPage-C_VVPPHa.js → ApiDocsPage-BFUrXE5F.js} +2 -2
- package/dist/ui/assets/CollapsibleCard-STA1GVQO.js +1 -0
- package/dist/ui/assets/DevToolsPage-BRSfZqO_.js +1 -0
- package/dist/ui/assets/LandingPage-DzeDy7q7.js +6 -0
- package/dist/ui/assets/LogsPage-BeiFrV2X.js +1 -0
- package/dist/ui/assets/{NotFoundPage-B3quk3P1.js → NotFoundPage-fRNOatbM.js} +1 -1
- package/dist/ui/assets/PluginCreatePage-Ch_RXsdf.js +50 -0
- package/dist/ui/assets/PluginPage-Cl65ZZ_n.js +27 -0
- package/dist/ui/assets/TraceSpansPage-BoK4M5Hh.js +6 -0
- package/dist/ui/assets/VirtualizedListPanel-zcj0v7DL.js +16 -0
- package/dist/ui/assets/alert-BkNVKxJN.js +1133 -0
- package/dist/ui/assets/badge-CN7FeufU.js +1 -0
- package/dist/ui/assets/{chevron-down-CPsvsmqj.js → chevron-down-CG--ounh.js} +1 -1
- package/dist/ui/assets/{chevron-up-Df9jMo1X.js → chevron-up-B6tzMAOm.js} +1 -1
- package/dist/ui/assets/{circle-alert-DOPQPvU8.js → circle-alert-BDF8Tq9y.js} +1 -1
- package/dist/ui/assets/dialog-BrpWNk36.js +15 -0
- package/dist/ui/assets/index-6xOVKwKn.js +305 -0
- package/dist/ui/assets/index-D6f1KjWV.css +1 -0
- package/dist/ui/assets/index-D96rVSkR.js +1 -0
- package/dist/ui/assets/info-99kuqpbx.js +6 -0
- package/dist/ui/assets/{input-Dzvg_ZEZ.js → input-B-01QDg_.js} +1 -1
- package/dist/ui/assets/label-CQLeZjM1.js +1 -0
- package/dist/ui/assets/{loader-circle-CrvlRy5o.js → loader-circle-BoDGk-BO.js} +1 -1
- package/dist/ui/assets/{loginPage-qa4V-B70.js → loginPage-8F4EEd1B.js} +1 -1
- package/dist/ui/assets/metrics-page-D1GxaB_c.css +1 -0
- package/dist/ui/assets/metrics-page-DPtteXqY.js +31 -0
- package/dist/ui/assets/popover-DS_8DYYt.js +11 -0
- package/dist/ui/assets/select-DYjegiXi.js +6 -0
- package/dist/ui/assets/separator-DGsRxIrl.js +6 -0
- package/dist/ui/assets/severityOptions-DEOvJqC9.js +11 -0
- package/dist/ui/assets/square-pen-DPhgYz6O.js +6 -0
- package/dist/ui/assets/switch-Di9NJH2A.js +1 -0
- package/dist/ui/assets/trace-DJq1miYa.js +1 -0
- package/dist/ui/assets/upload-BiLTpCnX.js +11 -0
- package/dist/ui/assets/{utilService-DNyqzwj0.js → utilService-CNZOmadC.js} +1 -1
- package/dist/ui/assets/wand-sparkles-CPoBNFFg.js +6 -0
- package/dist/ui/index.html +2 -2
- package/package.json +44 -48
- package/dist/ui/assets/CollapsibleCard-B3KR_8mL.js +0 -1
- package/dist/ui/assets/DevToolsPage-OyZcDcmw.js +0 -1
- package/dist/ui/assets/LandingPage-CppFBA6K.js +0 -6
- package/dist/ui/assets/LogsPage-9Fq8GArS.js +0 -26
- package/dist/ui/assets/PluginCreatePage-X_aCH4t4.js +0 -50
- package/dist/ui/assets/PluginPage-DMDSihrZ.js +0 -27
- package/dist/ui/assets/alert-jQ9HCPIf.js +0 -1133
- package/dist/ui/assets/badge-CNq0-mH5.js +0 -1
- package/dist/ui/assets/card-DFAwwhN3.js +0 -1
- package/dist/ui/assets/index-BkD6DijD.js +0 -15
- package/dist/ui/assets/index-CERGVYZK.js +0 -292
- package/dist/ui/assets/index-CSIPf9qw.css +0 -1
- package/dist/ui/assets/label-DuVnkZ4q.js +0 -1
- package/dist/ui/assets/select-DhS8YUtJ.js +0 -1
- package/dist/ui/assets/separator-isK4chBP.js +0 -6
- package/dist/ui/assets/severityOptions-O38dSOfk.js +0 -11
- package/dist/ui/assets/switch-Z3mImG9n.js +0 -1
- package/dist/ui/assets/tabs-_77MUUQe.js +0 -16
- package/dist/ui/assets/upload-C1LT4Gkb.js +0 -16
package/.env.example
CHANGED
|
@@ -12,14 +12,33 @@ OASTLM_BOOT_MODULE_DISABLED=
|
|
|
12
12
|
OASTLM_BOOT_LOG_LEVEL=
|
|
13
13
|
# The name of your application or service | Default: "SERVICE-<random-uuid>"
|
|
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=
|
|
25
|
+
|
|
26
|
+
# BOOT-STORAGE CONFIGURATION ------------------------------------------------
|
|
27
|
+
# Storage configuration for telemetry data (set at startup, cannot be changed at runtime).
|
|
28
|
+
# If empty or not set: telemetry stored IN-MEMORY (default, lost on restart)
|
|
29
|
+
# If set: telemetry persisted to DISK at specified path
|
|
30
|
+
# Examples:
|
|
31
|
+
# OASTLM_BOOT_STORAGE_PATH= # empty = in-memory
|
|
32
|
+
# OASTLM_BOOT_STORAGE_PATH=data/telemetry # disk storage
|
|
33
|
+
# OASTLM_BOOT_STORAGE_PATH=/var/lib/telemetry # absolute path
|
|
34
|
+
# Default: empty (in-memory)
|
|
35
|
+
OASTLM_BOOT_STORAGE_PATH=
|
|
15
36
|
|
|
16
37
|
|
|
17
38
|
# CONFIGURATION --------------------------------------------------------
|
|
18
39
|
# These variables are used to override the configuration when oasTelemetry(config) is called.
|
|
19
40
|
# ----------------------------------------------------------------------
|
|
20
41
|
|
|
21
|
-
# Base URL for telemetry | Default: "/telemetry"
|
|
22
|
-
OASTLM_CONFIG_GENERAL_BASE_URL=
|
|
23
42
|
# Specification file name | Default: null
|
|
24
43
|
OASTLM_CONFIG_GENERAL_SPEC_FILE_NAME=
|
|
25
44
|
|
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
|
|
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,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
8
|
+
const crypto_1 = require("crypto");
|
|
10
9
|
if (process.env.NODE_ENV !== 'test') {
|
|
11
|
-
|
|
10
|
+
dotenv_1.default.config();
|
|
12
11
|
}
|
|
13
12
|
// This variables can NOT be configured via oasTelemetry(config)
|
|
14
13
|
// They are used at the import of the library
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
exports.bootEnvVariables = {
|
|
15
|
+
OASTLM_BOOT_ENV: process.env.OASTLM_BOOT_ENV || process.env.NODE_ENV || 'production',
|
|
16
|
+
OASTLM_BOOT_MODULE_DISABLED: process.env.OASTLM_BOOT_MODULE_DISABLED === 'true',
|
|
17
|
+
OASTLM_BOOT_LOG_LEVEL: process.env.OASTLM_BOOT_LOG_LEVEL || 'INFO',
|
|
18
|
+
OASTLM_BOOT_SERVICE_NAME: process.env.OASTLM_BOOT_SERVICE_NAME || `SERVICE-${(0, crypto_1.randomUUID)().slice(0, 8).toUpperCase()}`,
|
|
19
|
+
OASTLM_BOOT_BASE_URL: process.env.OASTLM_BOOT_BASE_URL || '/oas-telemetry',
|
|
20
|
+
OASTLM_BOOT_AUTOINSTRUMENTATIONS_NODE_DISABLED: process.env.OASTLM_BOOT_AUTOINSTRUMENTATIONS_NODE_DISABLED == 'true',
|
|
21
|
+
OASTLM_BOOT_AUTOINSTRUMENTATIONS_LOGS_DISABLED: process.env.OASTLM_BOOT_AUTOINSTRUMENTATIONS_LOGS_DISABLED == 'true',
|
|
22
|
+
// Storage path: empty string = in-memory, else = disk storage at specified path
|
|
23
|
+
OASTLM_BOOT_STORAGE_PATH: process.env.OASTLM_BOOT_STORAGE_PATH || '',
|
|
24
|
+
};
|
|
25
|
+
// REMEMBER TO UPDATE THE .env.example FILE WITH ANY NEW BOOT VARIABLE ADDED HERE.
|
|
@@ -1,147 +1,134 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
};
|
|
12
|
+
return {
|
|
13
|
+
general: {
|
|
14
|
+
specFileName: getParsedEnvVar("OASTLM_CONFIG_GENERAL_SPEC_FILE_NAME"),
|
|
15
|
+
// spec Not settable via env
|
|
16
|
+
},
|
|
17
|
+
auth: {
|
|
18
|
+
enabled: getParsedEnvVar("OASTLM_CONFIG_AUTH_ENABLED", (v) => v === "true"),
|
|
19
|
+
password: getParsedEnvVar("OASTLM_CONFIG_AUTH_PASSWORD"),
|
|
20
|
+
jwtSecret: getParsedEnvVar("OASTLM_CONFIG_AUTH_JWT_SECRET"),
|
|
21
|
+
accessTokenMaxAge: getParsedEnvVar("OASTLM_CONFIG_AUTH_ACCESS_TOKEN_MAX_AGE", (v) => parseInt(v, 10)),
|
|
22
|
+
refreshTokenMaxAge: getParsedEnvVar("OASTLM_CONFIG_AUTH_REFRESH_TOKEN_MAX_AGE", (v) => parseInt(v, 10)),
|
|
23
|
+
},
|
|
24
|
+
traces: {
|
|
25
|
+
memoryExporter: {
|
|
26
|
+
enabled: getParsedEnvVar("OASTLM_CONFIG_TRACES_MEMORY_EXPORTER_ENABLED", (v) => v === "true"),
|
|
27
|
+
retentionTimeSeconds: getParsedEnvVar("OASTLM_CONFIG_TRACES_MEMORY_EXPORTER_RETENTION_TIME_SECONDS", (v) => parseInt(v, 10)),
|
|
28
|
+
// filters NOT settable via env
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
metrics: {
|
|
32
|
+
mainMetricReaderOptions: {
|
|
33
|
+
exportIntervalMillis: getParsedEnvVar("OASTLM_CONFIG_METRICS_MAIN_READER_EXPORT_INTERVAL", (v) => parseInt(v, 10)),
|
|
34
|
+
// metricProducers NOT settable via env
|
|
35
|
+
},
|
|
36
|
+
memoryExporter: {
|
|
37
|
+
enabled: getParsedEnvVar("OASTLM_CONFIG_METRICS_MEMORY_EXPORTER_ENABLED", (v) => v === "true"),
|
|
38
|
+
retentionTimeSeconds: getParsedEnvVar("OASTLM_CONFIG_METRICS_MEMORY_EXPORTER_RETENTION_TIME_SECONDS", (v) => parseInt(v, 10)),
|
|
39
|
+
// filters NOT settable via env
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
logs: {
|
|
43
|
+
memoryExporter: {
|
|
44
|
+
enabled: getParsedEnvVar("OASTLM_CONFIG_LOGS_MEMORY_EXPORTER_ENABLED", (v) => v === "true"),
|
|
45
|
+
retentionTimeSeconds: getParsedEnvVar("OASTLM_CONFIG_LOGS_MEMORY_EXPORTER_RETENTION_TIME_SECONDS", (v) => parseInt(v, 10)),
|
|
46
|
+
// filters NOT settable via env
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
ai: {
|
|
50
|
+
openAIKey: getParsedEnvVar("OASTLM_CONFIG_AI_OPENAI_KEY"),
|
|
51
|
+
openAIModel: getParsedEnvVar("OASTLM_CONFIG_AI_OPENAI_MODEL", (v) => v || "gpt-3.5-turbo"),
|
|
52
|
+
extraContextPrompts: getParsedEnvVar("OASTLM_CONFIG_AI_EXTRA_CONTEXT_PROMPTS", (v) => v ? v.split(',') : []),
|
|
53
|
+
},
|
|
54
|
+
};
|
|
57
55
|
};
|
|
58
56
|
// This defines de OasTlmConfig type, which is used throughout the library.
|
|
59
57
|
// Please ensure that all possible types are included here, not only the defaults.
|
|
60
58
|
// e.g. .ai.openAIKey: null as string | null, default is null, but can be set to a string.
|
|
61
59
|
// NOTE: Some BOOT environment variables (e.g., OASTLM_BOOT_MODULE_DISABLED) are accessed before this config is loaded.
|
|
62
60
|
// This means certain settings may affect application startup behavior outside of this configuration system.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
|
61
|
+
exports.defaultConfig = {
|
|
62
|
+
general: {
|
|
63
|
+
specFileName: null, // e.g. "oas.json" or null if not provided
|
|
64
|
+
spec: null, // e.g. JSON.stringify(oasSpec) or null if not provided,
|
|
65
|
+
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
66
|
},
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
67
|
+
auth: {
|
|
68
|
+
enabled: false,
|
|
69
|
+
password: "oas-telemetry-password",
|
|
70
|
+
jwtSecret: "oas-telemetry-secret",
|
|
71
|
+
accessTokenMaxAge: 1000 * 60 * 5, // 5 minutes
|
|
72
|
+
refreshTokenMaxAge: 1000 * 60 * 60 * 24 * 7, // 7 days
|
|
97
73
|
},
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
exportIntervalMillis: 1000 * 60,
|
|
103
|
-
// 60 seconds
|
|
104
|
-
metricProducers: [] // experimental by OpenTelemetry, not used by OAS-TLM yet
|
|
74
|
+
ai: {
|
|
75
|
+
openAIKey: null,
|
|
76
|
+
openAIModel: "gpt-3.5-turbo",
|
|
77
|
+
extraContextPrompts: [], // e.g. ["Provide detailed explanations", "Use simple language"]
|
|
105
78
|
},
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
79
|
+
traces: {
|
|
80
|
+
extraExporters: [], // e.g. [new ConsoleSpanExporter()]
|
|
81
|
+
extraProcessors: [], // e.g. [new SimpleSpanProcessor(new ConsoleSpanExporter())]
|
|
82
|
+
mainProcessorOptions: {
|
|
83
|
+
config: undefined
|
|
84
|
+
},
|
|
85
|
+
memoryExporter: {
|
|
86
|
+
enabled: true, // auto start exporting.
|
|
87
|
+
retentionTimeSeconds: 60 * 60, // 1 hour
|
|
88
|
+
},
|
|
89
|
+
filters: [], // future feature, currently not used
|
|
113
90
|
},
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
91
|
+
metrics: {
|
|
92
|
+
mainMetricReaderOptions: {
|
|
93
|
+
exportIntervalMillis: 1000 * 60, // 60 seconds
|
|
94
|
+
metricProducers: [], // experimental by OpenTelemetry, not used by OAS-TLM yet
|
|
95
|
+
},
|
|
96
|
+
extraReaders: [], // e.g. [new PrometheusExporter()]
|
|
97
|
+
extraViews: [], // e.g. [new MetricView({ name: 'my_metric', labels: ['env'] })]
|
|
98
|
+
memoryExporter: {
|
|
99
|
+
enabled: true,
|
|
100
|
+
retentionTimeSeconds: 60 * 60, // 1 hour
|
|
101
|
+
},
|
|
102
|
+
filters: [], // future feature, currently not used
|
|
103
|
+
},
|
|
104
|
+
logs: {
|
|
105
|
+
extraExporters: [], // e.g. [new ConsoleLogRecordExporter()]
|
|
106
|
+
extraProcessors: [], // e.g. [new SimpleLogRecordProcessor(new ConsoleLogRecordExporter())]
|
|
107
|
+
memoryExporter: {
|
|
108
|
+
enabled: true,
|
|
109
|
+
retentionTimeSeconds: 60 * 60, // 1 hour
|
|
110
|
+
},
|
|
111
|
+
filters: [], // future feature, currently not used
|
|
124
112
|
},
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
extraPlugins: [] // future feature
|
|
131
|
-
}
|
|
113
|
+
plugins: {
|
|
114
|
+
enabled: true, // future feature
|
|
115
|
+
extraPlugins: [], // future feature
|
|
116
|
+
},
|
|
117
|
+
instrumentations: [],
|
|
132
118
|
};
|
|
133
119
|
// Helper to get an environment variable with optional transform
|
|
134
120
|
const getParsedEnvVar = (envKey, transform) => {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
121
|
+
const rawValue = process.env[envKey];
|
|
122
|
+
// Treat undefined and "" in env as undefined (skip)
|
|
123
|
+
if (rawValue === undefined || rawValue === "")
|
|
124
|
+
return undefined;
|
|
125
|
+
if (typeof transform === 'function') {
|
|
126
|
+
return transform(rawValue);
|
|
127
|
+
}
|
|
128
|
+
return rawValue;
|
|
142
129
|
};
|
|
143
|
-
const getConfig = (userConfig, fallbackConfig = defaultConfig, envConfig = loadEnv()) => {
|
|
144
|
-
|
|
145
|
-
|
|
130
|
+
const getConfig = (userConfig, fallbackConfig = exports.defaultConfig, envConfig = loadEnv()) => {
|
|
131
|
+
// environment variables OVERRIDE userConfig OVERRIDE fallbackConfig
|
|
132
|
+
return (0, lodash_merge_1.default)({}, fallbackConfig, userConfig, envConfig);
|
|
146
133
|
};
|
|
147
|
-
exports.getConfig = getConfig;
|
|
134
|
+
exports.getConfig = getConfig;
|
|
@@ -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.
|
|
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 NDJSON format
|
|
335
|
+
responses:
|
|
336
|
+
'200':
|
|
337
|
+
description: Traces exported successfully
|
|
338
|
+
content:
|
|
339
|
+
application/x-ndjson:
|
|
340
|
+
schema:
|
|
341
|
+
type: string
|
|
342
|
+
|
|
343
|
+
/traces/import:
|
|
344
|
+
post:
|
|
345
|
+
tags:
|
|
346
|
+
- traces
|
|
347
|
+
summary: Import traces
|
|
348
|
+
description: Import traces from NDJSON format
|
|
349
|
+
requestBody:
|
|
350
|
+
required: true
|
|
351
|
+
content:
|
|
352
|
+
application/x-ndjson:
|
|
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 NDJSON format
|
|
595
|
+
responses:
|
|
596
|
+
'200':
|
|
597
|
+
description: Metrics exported successfully
|
|
598
|
+
content:
|
|
599
|
+
application/x-ndjson:
|
|
600
|
+
schema:
|
|
601
|
+
type: string
|
|
602
|
+
|
|
603
|
+
/metrics/import:
|
|
604
|
+
post:
|
|
605
|
+
tags:
|
|
606
|
+
- metrics
|
|
607
|
+
summary: Import metrics
|
|
608
|
+
description: Import metrics from NDJSON format
|
|
609
|
+
requestBody:
|
|
610
|
+
required: true
|
|
611
|
+
content:
|
|
612
|
+
application/x-ndjson:
|
|
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 NDJSON format
|
|
793
|
+
responses:
|
|
794
|
+
'200':
|
|
795
|
+
description: Logs exported successfully
|
|
796
|
+
content:
|
|
797
|
+
application/x-ndjson:
|
|
798
|
+
schema:
|
|
799
|
+
type: string
|
|
800
|
+
|
|
801
|
+
/logs/import:
|
|
802
|
+
post:
|
|
803
|
+
tags:
|
|
804
|
+
- logs
|
|
805
|
+
summary: Import logs
|
|
806
|
+
description: Import logs from NDJSON format
|
|
807
|
+
requestBody:
|
|
808
|
+
required: true
|
|
809
|
+
content:
|
|
810
|
+
application/x-ndjson:
|
|
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
|
|
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:
|
|
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
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,38 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
require("./telemetry/initializeTelemetry.cjs");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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;
|