@oas-tools/oas-telemetry 0.7.0-alpha.4 → 0.7.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 +6 -2
- package/README.md +35 -17
- package/dist/cjs/config/bootConfig.cjs +3 -1
- package/dist/cjs/config/config.cjs +7 -5
- package/dist/cjs/docs/openapi.yaml +1399 -0
- package/dist/cjs/routesManager.cjs +36 -48
- package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.cjs +43 -13
- package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.cjs +10 -2
- package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.cjs +21 -16
- package/dist/cjs/telemetry/initializeTelemetry.cjs +39 -15
- package/dist/cjs/telemetry/telemetryConfigurator.cjs +6 -9
- package/dist/cjs/telemetry/telemetryRegistry.cjs +11 -8
- package/dist/cjs/tlm-ai/agent.cjs +54 -84
- package/dist/cjs/tlm-ai/aiController.cjs +69 -47
- package/dist/cjs/tlm-ai/aiRoutes.cjs +10 -3
- package/dist/cjs/tlm-ai/aiService.cjs +109 -0
- package/dist/cjs/tlm-ai/tools.cjs +30 -268
- package/dist/cjs/tlm-auth/authController.cjs +91 -26
- package/dist/cjs/tlm-auth/authMiddleware.cjs +20 -7
- package/dist/cjs/tlm-auth/authRoutes.cjs +3 -2
- package/dist/cjs/tlm-log/logController.cjs +30 -36
- package/dist/cjs/tlm-log/logRoutes.cjs +3 -2
- package/dist/cjs/tlm-metric/metricsController.cjs +15 -8
- package/dist/cjs/tlm-metric/metricsRoutes.cjs +2 -1
- package/dist/cjs/tlm-plugin/pluginController.cjs +11 -1
- package/dist/cjs/tlm-plugin/pluginProcess.cjs +4 -2
- package/dist/cjs/tlm-plugin/pluginService.cjs +3 -0
- package/dist/cjs/tlm-trace/traceController.cjs +16 -9
- package/dist/cjs/tlm-trace/traceRoutes.cjs +2 -1
- package/dist/cjs/tlm-util/utilController.cjs +23 -2
- package/dist/cjs/tlm-util/utilRoutes.cjs +44 -5
- package/dist/cjs/utils/logger.cjs +35 -13
- package/dist/esm/config/bootConfig.js +2 -0
- package/dist/esm/config/config.js +4 -2
- package/dist/esm/docs/openapi.yaml +1399 -0
- package/dist/esm/routesManager.js +37 -49
- package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.js +32 -11
- package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.js +10 -2
- package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.js +20 -13
- package/dist/esm/telemetry/initializeTelemetry.js +22 -14
- package/dist/esm/telemetry/telemetryConfigurator.js +7 -10
- package/dist/esm/telemetry/telemetryRegistry.js +10 -7
- package/dist/esm/tlm-ai/agent.js +37 -78
- package/dist/esm/tlm-ai/aiController.js +56 -39
- package/dist/esm/tlm-ai/aiRoutes.js +11 -4
- package/dist/esm/tlm-ai/aiService.js +94 -0
- package/dist/esm/tlm-ai/tools.js +29 -255
- package/dist/esm/tlm-auth/authController.js +62 -20
- package/dist/esm/tlm-auth/authMiddleware.js +18 -9
- package/dist/esm/tlm-auth/authRoutes.js +4 -3
- package/dist/esm/tlm-log/logController.js +26 -28
- package/dist/esm/tlm-log/logRoutes.js +4 -3
- package/dist/esm/tlm-metric/metricsController.js +10 -6
- package/dist/esm/tlm-metric/metricsRoutes.js +3 -2
- package/dist/esm/tlm-plugin/pluginController.js +2 -1
- package/dist/esm/tlm-plugin/pluginProcess.js +4 -2
- package/dist/esm/tlm-plugin/pluginService.js +4 -0
- package/dist/esm/tlm-trace/traceController.js +11 -7
- package/dist/esm/tlm-trace/traceRoutes.js +3 -2
- package/dist/esm/tlm-util/utilController.js +22 -0
- package/dist/esm/tlm-util/utilRoutes.js +40 -5
- package/dist/esm/utils/logger.js +35 -12
- package/dist/types/config/bootConfig.d.ts +1 -0
- package/dist/types/config/config.d.ts +6 -3
- package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.d.ts +7 -1
- package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.d.ts +1 -0
- package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.d.ts +1 -0
- package/dist/types/telemetry/telemetryRegistry.d.ts +22 -6
- package/dist/types/tlm-ai/agent.d.ts +2 -2
- package/dist/types/tlm-ai/aiController.d.ts +5 -4
- package/dist/types/tlm-ai/aiRoutes.d.ts +1 -1
- package/dist/types/tlm-ai/aiService.d.ts +38 -0
- package/dist/types/tlm-ai/tools.d.ts +5 -14
- package/dist/types/tlm-auth/authController.d.ts +2 -1
- package/dist/types/tlm-log/logController.d.ts +2 -2
- package/dist/types/tlm-metric/metricsController.d.ts +2 -1
- package/dist/types/tlm-plugin/pluginService.d.ts +2 -0
- package/dist/types/tlm-trace/traceController.d.ts +2 -1
- package/dist/types/tlm-util/utilController.d.ts +1 -0
- package/dist/types/utils/logger.d.ts +5 -5
- package/dist/ui/assets/ApiDocsPage-C_VVPPHa.js +16 -0
- package/dist/ui/assets/CollapsibleCard-B3KR_8mL.js +1 -0
- package/dist/ui/assets/DevToolsPage-OyZcDcmw.js +1 -0
- package/dist/ui/assets/LandingPage-CppFBA6K.js +6 -0
- package/dist/ui/assets/LogsPage-9Fq8GArS.js +26 -0
- package/dist/ui/assets/NotFoundPage-B3quk3P1.js +1 -0
- package/dist/ui/assets/PluginCreatePage-X_aCH4t4.js +50 -0
- package/dist/ui/assets/PluginPage-DMDSihrZ.js +27 -0
- package/dist/ui/assets/alert-jQ9HCPIf.js +1133 -0
- package/dist/ui/assets/badge-CNq0-mH5.js +1 -0
- package/dist/ui/assets/card-DFAwwhN3.js +1 -0
- package/dist/ui/assets/chevron-down-CPsvsmqj.js +6 -0
- package/dist/ui/assets/chevron-up-Df9jMo1X.js +6 -0
- package/dist/ui/assets/circle-alert-DOPQPvU8.js +6 -0
- package/dist/ui/assets/index-BkD6DijD.js +15 -0
- package/dist/ui/assets/index-CERGVYZK.js +292 -0
- package/dist/ui/assets/index-CSIPf9qw.css +1 -0
- package/dist/ui/assets/input-Dzvg_ZEZ.js +1 -0
- package/dist/ui/assets/label-DuVnkZ4q.js +1 -0
- package/dist/ui/assets/loader-circle-CrvlRy5o.js +6 -0
- package/dist/ui/assets/loginPage-qa4V-B70.js +6 -0
- package/dist/ui/assets/select-DhS8YUtJ.js +1 -0
- package/dist/ui/assets/separator-isK4chBP.js +6 -0
- package/dist/ui/assets/severityOptions-O38dSOfk.js +11 -0
- package/dist/ui/assets/switch-Z3mImG9n.js +1 -0
- package/dist/ui/assets/tabs-_77MUUQe.js +16 -0
- package/dist/ui/assets/upload-C1LT4Gkb.js +16 -0
- package/dist/ui/assets/utilService-DNyqzwj0.js +1 -0
- package/dist/ui/index.html +2 -2
- package/package.json +18 -7
- package/dist/ui/assets/index-BzIdRox6.js +0 -1733
- package/dist/ui/assets/index-CkoHzrrt.css +0 -1
package/.env.example
CHANGED
|
@@ -10,6 +10,8 @@ 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>"
|
|
14
|
+
OASTLM_BOOT_SERVICE_NAME=
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
# CONFIGURATION --------------------------------------------------------
|
|
@@ -24,12 +26,14 @@ OASTLM_CONFIG_GENERAL_SPEC_FILE_NAME=
|
|
|
24
26
|
|
|
25
27
|
# Enable authentication | Possible values: "true", "false" | Default: "false"
|
|
26
28
|
OASTLM_CONFIG_AUTH_ENABLED=
|
|
27
|
-
# Maximum age for API keys (ms) | Default: 3600000 (1 hour)
|
|
28
|
-
OASTLM_CONFIG_AUTH_API_KEY_MAX_AGE=
|
|
29
29
|
# Password for authentication | Default: "oas-telemetry-password"
|
|
30
30
|
OASTLM_CONFIG_AUTH_PASSWORD=
|
|
31
31
|
# JWT secret for authentication | Default: "oas-telemetry-secret"
|
|
32
32
|
OASTLM_CONFIG_AUTH_JWT_SECRET=
|
|
33
|
+
# Access token max age (ms) | Default: 300000 (5 minutes)
|
|
34
|
+
OASTLM_CONFIG_AUTH_ACCESS_TOKEN_MAX_AGE=
|
|
35
|
+
# Refresh token max age (ms) | Default: 604800000 (7 days)
|
|
36
|
+
OASTLM_CONFIG_AUTH_REFRESH_TOKEN_MAX_AGE=
|
|
33
37
|
|
|
34
38
|
|
|
35
39
|
# Enable memory exporter for traces | Possible values: "true", "false" | Default: "true"
|
package/README.md
CHANGED
|
@@ -3,19 +3,39 @@
|
|
|
3
3
|
|
|
4
4
|
**OAS Telemetry** is a library that automatically configures telemetry in your Express application based on OpenAPI, with no extra code required. Simply use the middleware to instantly access endpoints for viewing recent requests, system logs, and metrics—all stored in memory. This allows you to analyze your API’s behavior and debug issues easily, without manual setup or complex integration. OpenTelemetry is used under the hood to collect traces, metrics, and logs.
|
|
5
5
|
|
|
6
|
-
The middleware is highly configurable and supports both **ES Module (ESM)** and **CommonJS (CJS)** formats
|
|
6
|
+
The middleware is highly configurable and supports both **ES Module (ESM-ES2020)** and **CommonJS (CJS)** formats. Its functionality can be extended via plugins; see [Telemetry Plugins](#telemetry-plugins) for details.
|
|
7
7
|
|
|
8
8
|
> ⚠️ **Warning: Early Development Notice**
|
|
9
9
|
>
|
|
10
|
-
> **OAS Telemetry** is a functional and working package
|
|
10
|
+
> **OAS Telemetry** is a functional and working package currently progressing toward version **1.0**.
|
|
11
|
+
> While the core architecture is solid, features and APIs may still receive refinements or minor changes before the first stable release.
|
|
12
|
+
> Below is the current module status and roadmap:
|
|
11
13
|
>
|
|
12
|
-
> - **
|
|
13
|
-
>
|
|
14
|
-
> - **Metrics:** Not stable. Currently uses OpenTelemetry host metrics. This area is subject to change to improve memory usage and data handling.
|
|
15
|
-
> - **Configuration:** Semi-stable. All configuration options will be available as parameters at initialization and via environment variables (see the `.env.example` file). The configuration system is under active development and will change significantly in future releases.
|
|
16
|
-
> - **UI:** Not stable. Migration to React is in progress. Most views are placeholders except for the AI agent, which is fully functional and can answer questions about traces, and logs (Not yet for metrics). Plugin management page is also functional. Next steps include logs page (almost done) and traces page (subject to change based on instrumentation approach). Metrics page will be the last to be implemented, as we want to support custom metrics in the future.
|
|
14
|
+
> - **Logs:** Fully functional and stable for general use. Only minor changes are expected before version 1.0.
|
|
15
|
+
> Supports fast search by message content and Mongo-like query syntax (similar to traces).
|
|
17
16
|
>
|
|
18
|
-
>
|
|
17
|
+
> - **AI Chat:** Fully functional and stable. Integrated with OpenAI, requiring an API key set via environment variable or in the `.env` file.
|
|
18
|
+
> Only small improvements or new provider integrations are planned.
|
|
19
|
+
>
|
|
20
|
+
> - **Plugin System:** Operational and stable. Only minor adjustments may occur before 1.0.
|
|
21
|
+
> The plugin management page in the UI is already functional.
|
|
22
|
+
>
|
|
23
|
+
> - **Configuration:** The configuration system is considered stable in design.
|
|
24
|
+
> Using environment variables and initialization parameters has proven to be convenient and flexible.
|
|
25
|
+
> We do not expect breaking changes — new configuration options will be added only when new functionality is introduced, and all updates will always be documented in the `.env.example` file and official documentation.
|
|
26
|
+
>
|
|
27
|
+
> - **UI:** Under active development. Major changes to React have already been completed.
|
|
28
|
+
> Logs, Plugin, and ChatAI pages are available and functional.
|
|
29
|
+
> Next, we will work on the **Traces** and **Metrics** pages.
|
|
30
|
+
>
|
|
31
|
+
> - **Traces:** Currently functional with HTTP instrumentation.
|
|
32
|
+
> We are evaluating a possible switch to auto-instrumentation, depending on memory and performance testing results.
|
|
33
|
+
>
|
|
34
|
+
> - **Metrics:** Functional but expected to change.
|
|
35
|
+
> We are exploring optimizations to reduce memory usage and improve data handling before 1.0.
|
|
36
|
+
>
|
|
37
|
+
> Please, if you want to use this package or collaborate, contact us via **motero6@us.es**.
|
|
38
|
+
|
|
19
39
|
|
|
20
40
|
## Usage
|
|
21
41
|
|
|
@@ -101,7 +121,7 @@ export const customTelemetryConfig = {
|
|
|
101
121
|
},
|
|
102
122
|
memoryExporter: {
|
|
103
123
|
enabled: true,
|
|
104
|
-
|
|
124
|
+
retentionTimeInSeconds: 1000 * 60 * 120, // 2 hours
|
|
105
125
|
},
|
|
106
126
|
filters: [],
|
|
107
127
|
},
|
|
@@ -114,7 +134,7 @@ export const customTelemetryConfig = {
|
|
|
114
134
|
extraReaders: [],
|
|
115
135
|
memoryExporter: {
|
|
116
136
|
enabled: true,
|
|
117
|
-
|
|
137
|
+
retentionTimeInSeconds: 1000 * 60 * 120, // 2 hours
|
|
118
138
|
},
|
|
119
139
|
filters: [],
|
|
120
140
|
},
|
|
@@ -124,7 +144,7 @@ export const customTelemetryConfig = {
|
|
|
124
144
|
extraProcessors: [],
|
|
125
145
|
memoryExporter: {
|
|
126
146
|
enabled: true,
|
|
127
|
-
|
|
147
|
+
retentionTimeInSeconds: 1000 * 60 * 120, // 2 hours
|
|
128
148
|
},
|
|
129
149
|
filters: [],
|
|
130
150
|
},
|
|
@@ -197,8 +217,8 @@ You can access the telemetry UI at the endpoint `/telemetry` (or `/custom-teleme
|
|
|
197
217
|
|
|
198
218
|
- `GET /utils/spec`: Load the OpenAPI specification.
|
|
199
219
|
- `GET /utils/heapStats`: Show v8 heap statistics.
|
|
200
|
-
- `GET /utils/
|
|
201
|
-
- `GET /utils/wait/:seconds?`: Wait for a specified number of seconds.
|
|
220
|
+
- `GET /utils/generate-log`: Generate a log message.
|
|
221
|
+
- `GET /utils/generate-wait/:seconds?`: Wait for a specified number of seconds.
|
|
202
222
|
- `GET /utils/health`: Perform a health check.
|
|
203
223
|
|
|
204
224
|
## Telemetry Plugins
|
|
@@ -222,7 +242,7 @@ Using OAS Telemetry, you can access telemetry data through the UI (WIP), the `/t
|
|
|
222
242
|
|
|
223
243
|
Note: if authentication is enabled, you must provide the correct credentials to access the telemetry data.
|
|
224
244
|
|
|
225
|
-
###
|
|
245
|
+
### Search Example
|
|
226
246
|
|
|
227
247
|
To perform a simple search, send a POST request to the `/telemetry/traces/find` endpoint with the following JSON payload:
|
|
228
248
|
|
|
@@ -239,9 +259,7 @@ To perform a simple search, send a POST request to the `/telemetry/traces/find`
|
|
|
239
259
|
}
|
|
240
260
|
```
|
|
241
261
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
For more complex searches using regex, additional parsing on the server and extra attributes in the POST request are required. Send a POST request to the `/telemetry/traces/find` endpoint with the following JSON payload:
|
|
262
|
+
You can also use regular expressions and comparison operators for more complex searches. For example, to find all GET requests to paths starting with `/api/v1/pets` that returned a status code less than or equal to 400, you can use the following query:
|
|
245
263
|
|
|
246
264
|
```json
|
|
247
265
|
{
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.bootEnvVariables = void 0;
|
|
7
7
|
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
8
|
+
var _crypto = require("crypto");
|
|
8
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
10
|
if (process.env.NODE_ENV !== 'test') {
|
|
10
11
|
_dotenv.default.config();
|
|
@@ -14,5 +15,6 @@ if (process.env.NODE_ENV !== 'test') {
|
|
|
14
15
|
const bootEnvVariables = exports.bootEnvVariables = {
|
|
15
16
|
OASTLM_BOOT_ENV: process.env.OASTLM_BOOT_ENV || process.env.NODE_ENV || 'production',
|
|
16
17
|
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_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()}`
|
|
18
20
|
};
|
|
@@ -18,9 +18,10 @@ const loadEnv = () => {
|
|
|
18
18
|
},
|
|
19
19
|
auth: {
|
|
20
20
|
enabled: getParsedEnvVar("OASTLM_CONFIG_AUTH_ENABLED", v => v === "true"),
|
|
21
|
-
apiKeyMaxAge: getParsedEnvVar("OASTLM_CONFIG_AUTH_API_KEY_MAX_AGE", v => parseInt(v, 10)),
|
|
22
21
|
password: getParsedEnvVar("OASTLM_CONFIG_AUTH_PASSWORD"),
|
|
23
|
-
jwtSecret: getParsedEnvVar("OASTLM_CONFIG_AUTH_JWT_SECRET")
|
|
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))
|
|
24
25
|
},
|
|
25
26
|
traces: {
|
|
26
27
|
memoryExporter: {
|
|
@@ -70,10 +71,11 @@ const defaultConfig = exports.defaultConfig = {
|
|
|
70
71
|
},
|
|
71
72
|
auth: {
|
|
72
73
|
enabled: false,
|
|
73
|
-
apiKeyMaxAge: 1000 * 60 * 60,
|
|
74
|
-
// 1 hour
|
|
75
74
|
password: "oas-telemetry-password",
|
|
76
|
-
jwtSecret: "oas-telemetry-secret"
|
|
75
|
+
jwtSecret: "oas-telemetry-secret",
|
|
76
|
+
accessTokenMaxAge: 1000 * 60 * 5,
|
|
77
|
+
// 5 minutes
|
|
78
|
+
refreshTokenMaxAge: 1000 * 60 * 60 * 24 * 7 // 7 days
|
|
77
79
|
},
|
|
78
80
|
ai: {
|
|
79
81
|
openAIKey: null,
|