@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.
- package/.env.example +17 -3
- package/README.md +1 -2
- package/dist/cjs/config/bootConfig.cjs +16 -14
- package/dist/cjs/config/config.cjs +120 -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/DiskLogExporter.cjs +121 -0
- package/dist/cjs/telemetry/custom-implementations/exporters/DiskMetricExporter.cjs +101 -0
- package/dist/cjs/telemetry/custom-implementations/exporters/DiskTraceExporter.cjs +103 -0
- package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.cjs +194 -190
- package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.cjs +147 -99
- package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.cjs +143 -116
- package/dist/cjs/telemetry/custom-implementations/exporters/MultiMetricExporter.cjs +57 -0
- 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 +392 -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/wrappers.cjs +209 -138
- package/dist/cjs/telemetry/initializeTelemetry.cjs +35 -91
- package/dist/cjs/telemetry/persistence/DiskImporter.cjs +85 -0
- package/dist/cjs/telemetry/persistence/DiskUtils.cjs +61 -0
- package/dist/cjs/telemetry/persistence/DiskWriter.cjs +66 -0
- package/dist/cjs/telemetry/telemetryConfigurator.cjs +139 -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 +135 -116
- package/dist/cjs/tlm-log/logRoutes.cjs +19 -20
- package/dist/cjs/tlm-log/logService.cjs +29 -0
- package/dist/cjs/tlm-metric/metricsController.cjs +154 -122
- package/dist/cjs/tlm-metric/metricsRoutes.cjs +22 -20
- package/dist/cjs/tlm-metric/metricsService.cjs +26 -0
- 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 +140 -123
- package/dist/cjs/tlm-trace/traceRoutes.cjs +19 -20
- package/dist/cjs/tlm-trace/traceService.cjs +29 -0
- 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 +5 -2
- package/dist/esm/config/config.js +9 -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/DiskLogExporter.js +114 -0
- package/dist/esm/telemetry/custom-implementations/exporters/DiskMetricExporter.js +94 -0
- package/dist/esm/telemetry/custom-implementations/exporters/DiskTraceExporter.js +96 -0
- package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.js +38 -7
- package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.js +107 -48
- package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.js +60 -29
- package/dist/esm/telemetry/custom-implementations/exporters/MultiMetricExporter.js +53 -0
- 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 +385 -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/wrappers.js +77 -6
- package/dist/esm/telemetry/initializeTelemetry.js +27 -69
- package/dist/esm/telemetry/persistence/DiskImporter.js +78 -0
- package/dist/esm/telemetry/persistence/DiskUtils.js +51 -0
- package/dist/esm/telemetry/persistence/DiskWriter.js +59 -0
- package/dist/esm/telemetry/telemetryConfigurator.js +110 -39
- 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 +62 -18
- package/dist/esm/tlm-log/logRoutes.js +3 -1
- package/dist/esm/tlm-log/logService.js +25 -0
- package/dist/esm/tlm-metric/metricsController.js +116 -50
- package/dist/esm/tlm-metric/metricsRoutes.js +8 -3
- package/dist/esm/tlm-metric/metricsService.js +22 -0
- 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 +87 -36
- package/dist/esm/tlm-trace/traceRoutes.js +3 -1
- package/dist/esm/tlm-trace/traceService.js +25 -0
- 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 +3 -0
- package/dist/types/config/config.d.ts +48 -7
- package/dist/types/config/config.types.d.ts +7 -0
- package/dist/types/index.d.ts +2 -3
- package/dist/types/telemetry/custom-implementations/exporters/DiskLogExporter.d.ts +24 -0
- package/dist/types/telemetry/custom-implementations/exporters/DiskMetricExporter.d.ts +23 -0
- package/dist/types/telemetry/custom-implementations/exporters/DiskTraceExporter.d.ts +23 -0
- package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.d.ts +3 -1
- package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.d.ts +56 -15
- package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.d.ts +8 -4
- package/dist/types/telemetry/custom-implementations/exporters/MultiMetricExporter.d.ts +9 -0
- 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/wrappers.d.ts +2 -1
- package/dist/types/telemetry/persistence/DiskImporter.d.ts +17 -0
- package/dist/types/telemetry/persistence/DiskUtils.d.ts +11 -0
- package/dist/types/telemetry/persistence/DiskWriter.d.ts +21 -0
- 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-log/logService.d.ts +4 -0
- package/dist/types/tlm-metric/metricsController.d.ts +11 -2
- package/dist/types/tlm-metric/metricsService.d.ts +6 -0
- package/dist/types/tlm-trace/traceController.d.ts +9 -7
- package/dist/types/tlm-trace/traceService.d.ts +4 -0
- package/dist/types/types/index.d.ts +2 -2
- package/dist/ui/assets/{ApiDocsPage-C_VVPPHa.js → ApiDocsPage-DTCgVbW2.js} +2 -2
- package/dist/ui/assets/CollapsibleCard-lWgfsaAn.js +1 -0
- package/dist/ui/assets/DevToolsPage-DEhf8CBy.js +1 -0
- package/dist/ui/assets/LandingPage-CfEHCDxY.js +6 -0
- package/dist/ui/assets/LogsPage-DFDKRuGH.js +1 -0
- package/dist/ui/assets/{NotFoundPage-B3quk3P1.js → NotFoundPage-DCy0DcV7.js} +1 -1
- package/dist/ui/assets/PluginCreatePage-BawZ5_-h.js +50 -0
- package/dist/ui/assets/PluginPage-D3FmgU7d.js +27 -0
- package/dist/ui/assets/TraceSpansPage-D0_L45Rb.js +6 -0
- package/dist/ui/assets/VirtualizedListPanel-q605n9He.js +16 -0
- package/dist/ui/assets/alert-DBAFshSi.js +1133 -0
- package/dist/ui/assets/badge-DGNBtnxU.js +1 -0
- package/dist/ui/assets/{chevron-down-CPsvsmqj.js → chevron-down-CFEqYzGC.js} +1 -1
- package/dist/ui/assets/{chevron-up-Df9jMo1X.js → chevron-up-lDnFwAJq.js} +1 -1
- package/dist/ui/assets/{circle-alert-DOPQPvU8.js → circle-alert-BpYUuRs7.js} +1 -1
- package/dist/ui/assets/dialog-1dRyI6SC.js +15 -0
- package/dist/ui/assets/index-C7RfU6hR.js +1 -0
- package/dist/ui/assets/index-C9dDYIpd.js +305 -0
- package/dist/ui/assets/index-D6f1KjWV.css +1 -0
- package/dist/ui/assets/info-CuJQWoBU.js +6 -0
- package/dist/ui/assets/{input-Dzvg_ZEZ.js → input-BLXaar0X.js} +1 -1
- package/dist/ui/assets/label-DfAcltsl.js +1 -0
- package/dist/ui/assets/{loader-circle-CrvlRy5o.js → loader-circle-B7oLyPsi.js} +1 -1
- package/dist/ui/assets/{loginPage-qa4V-B70.js → loginPage-DswZvOJ-.js} +1 -1
- package/dist/ui/assets/metrics-page-BhtXrfUW.js +31 -0
- package/dist/ui/assets/metrics-page-D1GxaB_c.css +1 -0
- package/dist/ui/assets/popover-IDker85U.js +11 -0
- package/dist/ui/assets/select-B8y5IidE.js +6 -0
- package/dist/ui/assets/separator-B6EzrxYY.js +6 -0
- package/dist/ui/assets/severityOptions-DtCsaAZK.js +11 -0
- package/dist/ui/assets/square-pen-D_oecB1x.js +6 -0
- package/dist/ui/assets/switch-Dqo0XkRD.js +1 -0
- package/dist/ui/assets/trace-DJq1miYa.js +1 -0
- package/dist/ui/assets/upload-prIohEdY.js +11 -0
- package/dist/ui/assets/{utilService-DNyqzwj0.js → utilService-C8TJKLqs.js} +1 -1
- package/dist/ui/assets/wand-sparkles-OgXuzsSx.js +6 -0
- package/dist/ui/index.html +2 -2
- package/package.json +44 -49
- 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
|
@@ -1,35 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 core_1 = require("@opentelemetry/core");
|
|
8
|
+
const resources_1 = require("@opentelemetry/resources");
|
|
9
|
+
const logger_js_1 = __importDefault(require("../../utils/logger.cjs"));
|
|
10
10
|
class Enabler {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
11
|
+
_enabled = true;
|
|
12
|
+
constructor(enabled) {
|
|
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
|
+
}
|
|
32
32
|
}
|
|
33
|
+
exports.Enabler = Enabler;
|
|
33
34
|
/*
|
|
34
35
|
* Classes for enabler exporters, allowing enable/disable toggling of exporters at runtime.
|
|
35
36
|
*
|
|
@@ -46,130 +47,200 @@ class Enabler {
|
|
|
46
47
|
* disabled, the reader's `collect` method is not called at all, saving additional resources compared to disabling the exporter.
|
|
47
48
|
*
|
|
48
49
|
*/
|
|
49
|
-
exports.Enabler = Enabler;
|
|
50
50
|
class EnablerSpanExporter extends Enabler {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
51
|
+
exporter;
|
|
52
|
+
constructor(exporter) {
|
|
53
|
+
super();
|
|
54
|
+
this.exporter = exporter;
|
|
55
|
+
}
|
|
56
|
+
export(spans, resultCallback) {
|
|
57
|
+
if (this.isEnabled()) {
|
|
58
|
+
this.exporter.export(spans, resultCallback);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
shutdown() {
|
|
62
|
+
return this.exporter.shutdown();
|
|
63
|
+
}
|
|
64
|
+
forceFlush() {
|
|
65
|
+
if (typeof this.exporter.forceFlush === 'function') {
|
|
66
|
+
return this.exporter.forceFlush();
|
|
67
|
+
}
|
|
68
|
+
return Promise.resolve();
|
|
69
|
+
}
|
|
69
70
|
}
|
|
70
71
|
exports.EnablerSpanExporter = EnablerSpanExporter;
|
|
71
72
|
class EnablerLogExporter extends Enabler {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
73
|
+
exporter;
|
|
74
|
+
constructor(exporter) {
|
|
75
|
+
super();
|
|
76
|
+
this.exporter = exporter;
|
|
77
|
+
}
|
|
78
|
+
export(logs, resultCallback) {
|
|
79
|
+
if (this.isEnabled()) {
|
|
80
|
+
this.exporter.export(logs, resultCallback);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
shutdown() {
|
|
84
|
+
return this.exporter.shutdown();
|
|
85
|
+
}
|
|
84
86
|
}
|
|
85
87
|
exports.EnablerLogExporter = EnablerLogExporter;
|
|
86
88
|
class EnablerMultiExporter extends Enabler {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
89
|
+
_exporters = [];
|
|
90
|
+
constructor(exporters) {
|
|
91
|
+
super();
|
|
92
|
+
if (exporters && Array.isArray(exporters)) {
|
|
93
|
+
this._exporters = exporters;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
addExporters(exporter) {
|
|
97
|
+
if (!this._exporters) {
|
|
98
|
+
this._exporters = [];
|
|
99
|
+
}
|
|
100
|
+
if (Array.isArray(exporter)) {
|
|
101
|
+
this._exporters.push(...exporter);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
this._exporters.push(exporter);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
clearExporters() {
|
|
108
|
+
this._exporters = [];
|
|
109
|
+
}
|
|
104
110
|
}
|
|
105
111
|
class EnablerMultiSpanExporter extends EnablerMultiExporter {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
export(spans, resultCallback) {
|
|
113
|
+
logger_js_1.default.debug(`EnablerMultiSpanExporter.export called with ${spans.length} spans, exporters: ${this._exporters?.length ?? 0}, enabled: ${this.isEnabled()}`);
|
|
114
|
+
if (!this.isEnabled() || !this._exporters || this._exporters.length === 0) {
|
|
115
|
+
resultCallback({ code: core_1.ExportResultCode.SUCCESS });
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
let pending = this._exporters.length;
|
|
119
|
+
let failed = false;
|
|
120
|
+
let firstError;
|
|
121
|
+
this._exporters.forEach((exporter) => {
|
|
122
|
+
try {
|
|
123
|
+
exporter.export(spans, (result) => {
|
|
124
|
+
if (result.code === core_1.ExportResultCode.FAILED) {
|
|
125
|
+
failed = true;
|
|
126
|
+
if (result.error && !firstError) {
|
|
127
|
+
firstError = result.error;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
pending -= 1;
|
|
131
|
+
if (pending === 0) {
|
|
132
|
+
resultCallback(failed
|
|
133
|
+
? { code: core_1.ExportResultCode.FAILED, error: firstError }
|
|
134
|
+
: { code: core_1.ExportResultCode.SUCCESS });
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
failed = true;
|
|
140
|
+
if (!firstError) {
|
|
141
|
+
firstError = error instanceof Error ? error : new Error(String(error));
|
|
142
|
+
}
|
|
143
|
+
pending -= 1;
|
|
144
|
+
if (pending === 0) {
|
|
145
|
+
resultCallback({ code: core_1.ExportResultCode.FAILED, error: firstError });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
async shutdown() {
|
|
151
|
+
if (this._exporters) {
|
|
152
|
+
await Promise.all(this._exporters.map((exporter) => exporter.shutdown()));
|
|
153
|
+
}
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
118
156
|
}
|
|
119
157
|
exports.EnablerMultiSpanExporter = EnablerMultiSpanExporter;
|
|
120
158
|
class EnablerMultiLogExporter extends EnablerMultiExporter {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
159
|
+
export(logs, resultCallback) {
|
|
160
|
+
if (!this.isEnabled() || !this._exporters || this._exporters.length === 0) {
|
|
161
|
+
resultCallback({ code: core_1.ExportResultCode.SUCCESS });
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
let pending = this._exporters.length;
|
|
165
|
+
let failed = false;
|
|
166
|
+
let firstError;
|
|
167
|
+
this._exporters.forEach((exporter) => {
|
|
168
|
+
try {
|
|
169
|
+
exporter.export(logs, (result) => {
|
|
170
|
+
if (result.code === core_1.ExportResultCode.FAILED) {
|
|
171
|
+
failed = true;
|
|
172
|
+
if (result.error && !firstError) {
|
|
173
|
+
firstError = result.error;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
pending -= 1;
|
|
177
|
+
if (pending === 0) {
|
|
178
|
+
resultCallback(failed
|
|
179
|
+
? { code: core_1.ExportResultCode.FAILED, error: firstError }
|
|
180
|
+
: { code: core_1.ExportResultCode.SUCCESS });
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
failed = true;
|
|
186
|
+
if (!firstError) {
|
|
187
|
+
firstError = error instanceof Error ? error : new Error(String(error));
|
|
188
|
+
}
|
|
189
|
+
pending -= 1;
|
|
190
|
+
if (pending === 0) {
|
|
191
|
+
resultCallback({ code: core_1.ExportResultCode.FAILED, error: firstError });
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
});
|
|
124
195
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
196
|
+
async shutdown() {
|
|
197
|
+
if (this._exporters) {
|
|
198
|
+
await Promise.all(this._exporters.map((exporter) => exporter.shutdown()));
|
|
199
|
+
}
|
|
200
|
+
return;
|
|
129
201
|
}
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
202
|
}
|
|
133
203
|
exports.EnablerMultiLogExporter = EnablerMultiLogExporter;
|
|
134
204
|
class EnablerMetricReader extends Enabler {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
205
|
+
reader;
|
|
206
|
+
constructor(reader) {
|
|
207
|
+
super();
|
|
208
|
+
this.reader = reader;
|
|
209
|
+
}
|
|
210
|
+
forceFlush(options) {
|
|
211
|
+
if (this.isEnabled()) {
|
|
212
|
+
return this.reader.forceFlush(options);
|
|
213
|
+
}
|
|
214
|
+
return Promise.resolve();
|
|
215
|
+
}
|
|
216
|
+
setMetricProducer(metricProducer) {
|
|
217
|
+
if (this.isEnabled()) {
|
|
218
|
+
this.reader.setMetricProducer(metricProducer);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
selectAggregation(instrumentType) {
|
|
222
|
+
return this.reader.selectAggregation(instrumentType);
|
|
223
|
+
}
|
|
224
|
+
selectAggregationTemporality(instrumentType) {
|
|
225
|
+
return this.reader.selectAggregationTemporality(instrumentType);
|
|
226
|
+
}
|
|
227
|
+
selectCardinalityLimit(instrumentType) {
|
|
228
|
+
return this.reader.selectCardinalityLimit(instrumentType);
|
|
229
|
+
}
|
|
230
|
+
async collect(options) {
|
|
231
|
+
if (this.isEnabled()) {
|
|
232
|
+
return await this.reader.collect(options);
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
resourceMetrics: {
|
|
236
|
+
resource: (0, resources_1.resourceFromAttributes)({}),
|
|
237
|
+
scopeMetrics: [],
|
|
238
|
+
},
|
|
239
|
+
errors: [],
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
shutdown(options) {
|
|
243
|
+
return this.reader.shutdown(options);
|
|
244
|
+
}
|
|
174
245
|
}
|
|
175
|
-
exports.EnablerMetricReader = EnablerMetricReader;
|
|
246
|
+
exports.EnablerMetricReader = EnablerMetricReader;
|
|
@@ -1,98 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
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
|
+
const logger_js_1 = __importDefault(require("../utils/logger.cjs"));
|
|
7
|
+
const bootConfig_js_1 = require("../config/bootConfig.cjs");
|
|
8
|
+
const instrumentation_http_1 = require("@opentelemetry/instrumentation-http");
|
|
9
|
+
const telemetryRegistry_js_1 = require("./telemetryRegistry.cjs");
|
|
10
|
+
const logsInstrumentation_js_1 = require("./custom-implementations/instrumentations/logsInstrumentation.cjs");
|
|
11
|
+
const instrumentation_runtime_node_1 = require("@opentelemetry/instrumentation-runtime-node");
|
|
13
12
|
// THIS INSTRUMENTATIONS NEED TO BE LOADED BEFORE ANYTHING ELSE
|
|
14
13
|
// They use monkey-patching to instrument the HTTP server and client.
|
|
15
14
|
// THIS FILE MUST BE CALLED BEFORE ANYTHING ELSE
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
} else {
|
|
19
|
-
_logger.default.info('🚀 Initializing Open Telemetry');
|
|
20
|
-
initializeTraces();
|
|
21
|
-
initializeMetrics();
|
|
22
|
-
initializeLogs();
|
|
23
|
-
(0, _instrumentation.registerInstrumentations)({
|
|
24
|
-
instrumentations: [new _instrumentationHttp.HttpInstrumentation()
|
|
25
|
-
// new ExpressInstrumentation(),
|
|
26
|
-
]
|
|
27
|
-
});
|
|
15
|
+
if (bootConfig_js_1.bootEnvVariables.OASTLM_BOOT_MODULE_DISABLED) {
|
|
16
|
+
logger_js_1.default.info('🚫 OASTLM module is disabled, Auto Instrumentations not initialized.');
|
|
28
17
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
Object.keys(_telemetryRegistry.originalConsoleMethods).forEach(method => {
|
|
47
|
-
// @ts-expect-error yes
|
|
48
|
-
console[method] = (...args) => {
|
|
49
|
-
const severity = getSeverityForMethod(method);
|
|
50
|
-
loggerInstance.emit({
|
|
51
|
-
severityNumber: severity.number,
|
|
52
|
-
severityText: severity.text,
|
|
53
|
-
body: _util.default.format(...args),
|
|
54
|
-
attributes: {
|
|
55
|
-
'source': `console.${method}`,
|
|
56
|
-
"library": "oas-telemetry"
|
|
18
|
+
else {
|
|
19
|
+
if (!(0, telemetryRegistry_js_1.isBootInitialized)()) {
|
|
20
|
+
// Only HTTP instrumentation por ahora
|
|
21
|
+
const httpInstrumentation = new instrumentation_http_1.HttpInstrumentation({
|
|
22
|
+
// Ignore internal telemetry routes
|
|
23
|
+
ignoreIncomingRequestHook: (req) => {
|
|
24
|
+
const url = req.url || '';
|
|
25
|
+
const path = url.split('?')[0]; // Remove query params
|
|
26
|
+
// Ignore all baseUrl routes except those with 'generate'
|
|
27
|
+
if (path.includes(bootConfig_js_1.bootEnvVariables.OASTLM_BOOT_BASE_URL)) {
|
|
28
|
+
return !path.includes('generate');
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
if (!bootConfig_js_1.bootEnvVariables.OASTLM_BOOT_AUTOINSTRUMENTATIONS_NODE_DISABLED) {
|
|
34
|
+
telemetryRegistry_js_1.instrumentations.push(httpInstrumentation, new instrumentation_runtime_node_1.RuntimeNodeInstrumentation());
|
|
57
35
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
function initializeMetrics() {
|
|
65
|
-
_logger.default.info('📈 Initializing MeterProvider');
|
|
66
|
-
// WARN: Default PeriodicExportingMetricReader is added post initialization (see telemetryConfigurator.ts)
|
|
67
|
-
// The in memory exporter is added by default to that reader. More readers are allowed to be added dynamically
|
|
36
|
+
if (!bootConfig_js_1.bootEnvVariables.OASTLM_BOOT_AUTOINSTRUMENTATIONS_LOGS_DISABLED) {
|
|
37
|
+
telemetryRegistry_js_1.instrumentations.push(new logsInstrumentation_js_1.LogsInstrumentation());
|
|
38
|
+
}
|
|
39
|
+
(0, telemetryRegistry_js_1.setBootInitialized)(true);
|
|
40
|
+
logger_js_1.default.info('✅ Auto Instrumentations created successfully');
|
|
41
|
+
}
|
|
68
42
|
}
|
|
69
|
-
function getSeverityForMethod(method) {
|
|
70
|
-
switch (method) {
|
|
71
|
-
case "log":
|
|
72
|
-
case "info":
|
|
73
|
-
return {
|
|
74
|
-
number: _apiLogs.SeverityNumber.INFO,
|
|
75
|
-
text: "INFO"
|
|
76
|
-
};
|
|
77
|
-
case "debug":
|
|
78
|
-
return {
|
|
79
|
-
number: _apiLogs.SeverityNumber.DEBUG,
|
|
80
|
-
text: "DEBUG"
|
|
81
|
-
};
|
|
82
|
-
case "warn":
|
|
83
|
-
return {
|
|
84
|
-
number: _apiLogs.SeverityNumber.WARN,
|
|
85
|
-
text: "WARN"
|
|
86
|
-
};
|
|
87
|
-
case "error":
|
|
88
|
-
return {
|
|
89
|
-
number: _apiLogs.SeverityNumber.ERROR,
|
|
90
|
-
text: "ERROR"
|
|
91
|
-
};
|
|
92
|
-
default:
|
|
93
|
-
return {
|
|
94
|
-
number: _apiLogs.SeverityNumber.INFO,
|
|
95
|
-
text: "INFO"
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
}
|
|
@@ -0,0 +1,85 @@
|
|
|
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.DiskImporter = void 0;
|
|
7
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
|
+
const logger_js_1 = __importDefault(require("../../utils/logger.cjs"));
|
|
9
|
+
const DiskUtils_js_1 = require("./DiskUtils.cjs");
|
|
10
|
+
class DiskImporter {
|
|
11
|
+
directoryPath;
|
|
12
|
+
segmentPrefix;
|
|
13
|
+
importBatchSize;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
this.directoryPath = options.directoryPath;
|
|
16
|
+
this.segmentPrefix = options.segmentPrefix || DiskUtils_js_1.DEFAULT_SEGMENT_PREFIX;
|
|
17
|
+
this.importBatchSize = options.importBatchSize || 500;
|
|
18
|
+
}
|
|
19
|
+
async import(onBatch) {
|
|
20
|
+
const stats = {
|
|
21
|
+
segmentFilesRead: 0,
|
|
22
|
+
importedRecords: 0,
|
|
23
|
+
failedFrames: 0,
|
|
24
|
+
};
|
|
25
|
+
const segments = await (0, DiskUtils_js_1.listSegments)(this.directoryPath, this.segmentPrefix);
|
|
26
|
+
if (!segments.length) {
|
|
27
|
+
return stats;
|
|
28
|
+
}
|
|
29
|
+
const importBuffer = [];
|
|
30
|
+
const flushImportBuffer = async () => {
|
|
31
|
+
if (!importBuffer.length)
|
|
32
|
+
return;
|
|
33
|
+
const batch = importBuffer.splice(0, importBuffer.length);
|
|
34
|
+
await onBatch(batch);
|
|
35
|
+
stats.importedRecords += batch.length;
|
|
36
|
+
};
|
|
37
|
+
for (const segment of segments) {
|
|
38
|
+
stats.segmentFilesRead += 1;
|
|
39
|
+
let fileBuffer;
|
|
40
|
+
try {
|
|
41
|
+
fileBuffer = await promises_1.default.readFile(segment.filePath);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
logger_js_1.default.warn(`[DiskImporter] Could not read segment ${segment.filePath}: ${error?.message || error}`);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
let offset = 0;
|
|
48
|
+
while (offset + 4 <= fileBuffer.length) {
|
|
49
|
+
const frameLength = fileBuffer.readUInt32LE(offset);
|
|
50
|
+
offset += 4;
|
|
51
|
+
if (frameLength <= 0) {
|
|
52
|
+
stats.failedFrames += 1;
|
|
53
|
+
logger_js_1.default.warn(`[DiskImporter] Invalid frame length in ${segment.filePath}; stopping segment parse.`);
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
if (offset + frameLength > fileBuffer.length) {
|
|
57
|
+
stats.failedFrames += 1;
|
|
58
|
+
logger_js_1.default.warn(`[DiskImporter] Truncated frame in ${segment.filePath}; stopping segment parse.`);
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
const framePayload = fileBuffer.subarray(offset, offset + frameLength);
|
|
62
|
+
offset += frameLength;
|
|
63
|
+
try {
|
|
64
|
+
const decodedSpans = (0, DiskUtils_js_1.decodeRecordBatchFrame)(framePayload);
|
|
65
|
+
importBuffer.push(...decodedSpans);
|
|
66
|
+
while (importBuffer.length >= this.importBatchSize) {
|
|
67
|
+
const batch = importBuffer.splice(0, this.importBatchSize);
|
|
68
|
+
await onBatch(batch);
|
|
69
|
+
stats.importedRecords += batch.length;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
stats.failedFrames += 1;
|
|
74
|
+
logger_js_1.default.warn(`[DiskImporter] Failed to decode frame from ${segment.filePath}: ${error?.message || error}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (offset !== fileBuffer.length) {
|
|
78
|
+
logger_js_1.default.warn(`[DiskImporter] Segment ${segment.filePath} has trailing or incomplete bytes.`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
await flushImportBuffer();
|
|
82
|
+
return stats;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.DiskImporter = DiskImporter;
|
|
@@ -0,0 +1,61 @@
|
|
|
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.DEFAULT_MAX_SEGMENT_BYTES = exports.SEGMENT_EXT = exports.DEFAULT_SEGMENT_PREFIX = void 0;
|
|
7
|
+
exports.getSegmentName = getSegmentName;
|
|
8
|
+
exports.listSegments = listSegments;
|
|
9
|
+
exports.encodeRecordBatchFrame = encodeRecordBatchFrame;
|
|
10
|
+
exports.decodeRecordBatchFrame = decodeRecordBatchFrame;
|
|
11
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const zlib_1 = require("zlib");
|
|
14
|
+
exports.DEFAULT_SEGMENT_PREFIX = 'traces';
|
|
15
|
+
exports.SEGMENT_EXT = '.oastlm';
|
|
16
|
+
exports.DEFAULT_MAX_SEGMENT_BYTES = 8 * 1024 * 1024;
|
|
17
|
+
function getSegmentName(index, prefix = exports.DEFAULT_SEGMENT_PREFIX) {
|
|
18
|
+
return `${prefix}-${index.toString().padStart(6, '0')}${exports.SEGMENT_EXT}`;
|
|
19
|
+
}
|
|
20
|
+
async function listSegments(directoryPath, prefix = exports.DEFAULT_SEGMENT_PREFIX) {
|
|
21
|
+
try {
|
|
22
|
+
const files = await promises_1.default.readdir(directoryPath);
|
|
23
|
+
const regex = new RegExp(`^${prefix}-(\\d{6})${exports.SEGMENT_EXT.replace('.', '\\.')}$`);
|
|
24
|
+
return files
|
|
25
|
+
.map((name) => {
|
|
26
|
+
const match = name.match(regex);
|
|
27
|
+
if (!match)
|
|
28
|
+
return null;
|
|
29
|
+
const index = Number.parseInt(match[1], 10);
|
|
30
|
+
return { index, filePath: path_1.default.join(directoryPath, name) };
|
|
31
|
+
})
|
|
32
|
+
.filter((value) => value !== null)
|
|
33
|
+
.sort((a, b) => a.index - b.index);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (error?.code === 'ENOENT') {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function encodeRecordBatchFrame(records) {
|
|
43
|
+
const lineDelimitedJson = records.map((record) => JSON.stringify(record)).join('\n') + '\n';
|
|
44
|
+
const compressed = (0, zlib_1.gzipSync)(Buffer.from(lineDelimitedJson, 'utf-8'));
|
|
45
|
+
const frame = Buffer.allocUnsafe(4 + compressed.length);
|
|
46
|
+
frame.writeUInt32LE(compressed.length, 0);
|
|
47
|
+
compressed.copy(frame, 4);
|
|
48
|
+
return frame;
|
|
49
|
+
}
|
|
50
|
+
function decodeRecordBatchFrame(framePayload) {
|
|
51
|
+
const decompressed = (0, zlib_1.gunzipSync)(framePayload).toString('utf-8');
|
|
52
|
+
const lines = decompressed.split('\n').filter((line) => line.trim().length > 0);
|
|
53
|
+
return lines.map((line, index) => {
|
|
54
|
+
try {
|
|
55
|
+
return JSON.parse(line);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
throw new Error(`Invalid JSON line at index ${index}`);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|