@oas-tools/oas-telemetry 0.2.2 → 0.4.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/LICENSE +200 -200
- package/README.md +133 -133
- package/dist/exporters/InMemoryDbExporter.cjs +32 -31
- package/dist/index.cjs +79 -19
- package/dist/telemetry.cjs +0 -0
- package/dist/types/exporters/InMemoryDbExporter.d.ts +16 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/telemetry.d.ts +2 -0
- package/dist/types/ui.d.ts +4 -0
- package/dist/ui.cjs +387 -97
- package/package.json +71 -69
- package/src/exporters/InMemoryDbExporter.js +175 -174
- package/src/index.js +310 -255
- package/src/telemetry.js +25 -25
- package/src/ui.js +387 -97
package/README.md
CHANGED
|
@@ -1,133 +1,133 @@
|
|
|
1
|
-
# OAS TELEMETRY
|
|
2
|
-
|
|
3
|
-
OAS Telemetry offers an express middleware designed for collecting telemetry data using Open Telemetry in applications built using the OpenAPI Specification (OAS). This middleware allows developers to easily incorporate telemetry functionality into their APIs.
|
|
4
|
-
|
|
5
|
-
OAS Telemetry provides a set of endpoints that can be accessed to perform various actions related to telemetry data, such as starting and stopping data collection, resetting telemetry data, listing collected data, and searching for specific telemetry records. These endpoints can be easily integrated into an Express.js application, providing developers with a convenient way to manage and analyze telemetry data.
|
|
6
|
-
|
|
7
|
-
Additionally, OAS Telemetry offers customization options, allowing developers to configure the telemetry middleware according to their specific requirements.
|
|
8
|
-
|
|
9
|
-
Overall, OAS Telemetry will serve as a valuable tool for developers looking to gain insights into the operation and performance of their OAS-based APIs, enabling them to monitor, debug, and optimize their applications effectively.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
To use the middelware add this two lines in your index.js (ESM):
|
|
17
|
-
```js
|
|
18
|
-
import oasTelemetry from 'oas-telemetry';
|
|
19
|
-
import {readFileSync} from 'fs';
|
|
20
|
-
|
|
21
|
-
app.use(oasTelemetry({
|
|
22
|
-
spec : readFileSync('./spec/oas.yaml',{ encoding: 'utf8', flag: 'r' })
|
|
23
|
-
}))
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Custom Configuration
|
|
28
|
-
|
|
29
|
-
You can also customize the telemetry configuration by passing options to the middleware function. For example:
|
|
30
|
-
```js
|
|
31
|
-
const customTelemetryConfig = {
|
|
32
|
-
exporter: myCustomExporter,
|
|
33
|
-
spec: /* OAS content in json or yaml */
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
app.use(oasTelemetry(customTelemetryConfig));
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Telemetry UI
|
|
40
|
-
|
|
41
|
-
You can access the telemetry UI in the endpoint ``/telemetry``
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
## API Telemetry Endpoints
|
|
45
|
-
|
|
46
|
-
OAS Telemetry middleware adds the following endpoints to your Express application:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
- /telemetry/start: Start telemetry data collection.
|
|
50
|
-
- /telemetry/stop: Stop telemetry data collection.
|
|
51
|
-
- /telemetry/status: Get status of telemetry.
|
|
52
|
-
- /telemetry/reset: Reset telemetry data.
|
|
53
|
-
- /telemetry/list: List all telemetry data.
|
|
54
|
-
- /telemetry/find (POST): Search telemetry data.
|
|
55
|
-
- /telemetry/heapStats: Shows v8 heapStats.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
## Simple Example [ES Module](https://nodejs.org/docs/latest/api/esm.html) (*.mjs)
|
|
59
|
-
```js index.mjs
|
|
60
|
-
import oasTelemetry from '@oas-tools/oas-telemetry';
|
|
61
|
-
import express from 'express';
|
|
62
|
-
|
|
63
|
-
const app = express();
|
|
64
|
-
const port = 3000;
|
|
65
|
-
|
|
66
|
-
const spec = { "paths": {
|
|
67
|
-
"/api/v1/pets": {
|
|
68
|
-
"get": {
|
|
69
|
-
"summary": "Get pets",
|
|
70
|
-
"responses":{
|
|
71
|
-
"200": {
|
|
72
|
-
"description": "Success"
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
app.use(oasTelemetry({
|
|
81
|
-
spec : JSON.stringify(spec)
|
|
82
|
-
}))
|
|
83
|
-
|
|
84
|
-
app.use(express.json());
|
|
85
|
-
|
|
86
|
-
app.get("/api/v1/pets", (req, res) => {
|
|
87
|
-
res.send([{ name: "rocky"},{ name: "pikachu"}]);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
app.listen(port, () => {
|
|
91
|
-
console.log(`Example app listening at http://localhost:${port}`);
|
|
92
|
-
console.log(`Telemetry portal available at http://localhost:${port}/telemetry`);
|
|
93
|
-
});
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Simple Example [Common.js Module](https://nodejs.org/docs/latest/api/modules.html) (*.cjs)
|
|
97
|
-
```js index.cjs
|
|
98
|
-
let oasTelemetry = require('@oas-tools/oas-telemetry');
|
|
99
|
-
let express = require('express');
|
|
100
|
-
|
|
101
|
-
const app = express();
|
|
102
|
-
const port = 3000;
|
|
103
|
-
|
|
104
|
-
const spec = { "paths": {
|
|
105
|
-
"/api/v1/pets": {
|
|
106
|
-
"get": {
|
|
107
|
-
"summary": "Get pets",
|
|
108
|
-
"responses":{
|
|
109
|
-
"200": {
|
|
110
|
-
"description": "Success"
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
app.use(oasTelemetry({
|
|
119
|
-
spec : JSON.stringify(spec)
|
|
120
|
-
}))
|
|
121
|
-
|
|
122
|
-
app.use(express.json());
|
|
123
|
-
|
|
124
|
-
app.get("/api/v1/pets", (req, res) => {
|
|
125
|
-
res.send([{ name: "rocky"},{ name: "pikachu"}]);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
app.listen(port, () => {
|
|
129
|
-
console.log(`Example app listening at http://localhost:${port}`);
|
|
130
|
-
console.log(`Telemetry portal available at http://localhost:${port}/telemetry`);
|
|
131
|
-
});
|
|
132
|
-
```
|
|
133
|
-
|
|
1
|
+
# OAS TELEMETRY
|
|
2
|
+
|
|
3
|
+
OAS Telemetry offers an express middleware designed for collecting telemetry data using Open Telemetry in applications built using the OpenAPI Specification (OAS). This middleware allows developers to easily incorporate telemetry functionality into their APIs.
|
|
4
|
+
|
|
5
|
+
OAS Telemetry provides a set of endpoints that can be accessed to perform various actions related to telemetry data, such as starting and stopping data collection, resetting telemetry data, listing collected data, and searching for specific telemetry records. These endpoints can be easily integrated into an Express.js application, providing developers with a convenient way to manage and analyze telemetry data.
|
|
6
|
+
|
|
7
|
+
Additionally, OAS Telemetry offers customization options, allowing developers to configure the telemetry middleware according to their specific requirements.
|
|
8
|
+
|
|
9
|
+
Overall, OAS Telemetry will serve as a valuable tool for developers looking to gain insights into the operation and performance of their OAS-based APIs, enabling them to monitor, debug, and optimize their applications effectively.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
To use the middelware add this two lines in your index.js (ESM):
|
|
17
|
+
```js
|
|
18
|
+
import oasTelemetry from 'oas-telemetry';
|
|
19
|
+
import {readFileSync} from 'fs';
|
|
20
|
+
|
|
21
|
+
app.use(oasTelemetry({
|
|
22
|
+
spec : readFileSync('./spec/oas.yaml',{ encoding: 'utf8', flag: 'r' })
|
|
23
|
+
}))
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Custom Configuration
|
|
28
|
+
|
|
29
|
+
You can also customize the telemetry configuration by passing options to the middleware function. For example:
|
|
30
|
+
```js
|
|
31
|
+
const customTelemetryConfig = {
|
|
32
|
+
exporter: myCustomExporter,
|
|
33
|
+
spec: /* OAS content in json or yaml */
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
app.use(oasTelemetry(customTelemetryConfig));
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Telemetry UI
|
|
40
|
+
|
|
41
|
+
You can access the telemetry UI in the endpoint ``/telemetry``
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## API Telemetry Endpoints
|
|
45
|
+
|
|
46
|
+
OAS Telemetry middleware adds the following endpoints to your Express application:
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
- /telemetry/start: Start telemetry data collection.
|
|
50
|
+
- /telemetry/stop: Stop telemetry data collection.
|
|
51
|
+
- /telemetry/status: Get status of telemetry.
|
|
52
|
+
- /telemetry/reset: Reset telemetry data.
|
|
53
|
+
- /telemetry/list: List all telemetry data.
|
|
54
|
+
- /telemetry/find (POST): Search telemetry data.
|
|
55
|
+
- /telemetry/heapStats: Shows v8 heapStats.
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
## Simple Example [ES Module](https://nodejs.org/docs/latest/api/esm.html) (*.mjs)
|
|
59
|
+
```js index.mjs
|
|
60
|
+
import oasTelemetry from '@oas-tools/oas-telemetry';
|
|
61
|
+
import express from 'express';
|
|
62
|
+
|
|
63
|
+
const app = express();
|
|
64
|
+
const port = 3000;
|
|
65
|
+
|
|
66
|
+
const spec = { "paths": {
|
|
67
|
+
"/api/v1/pets": {
|
|
68
|
+
"get": {
|
|
69
|
+
"summary": "Get pets",
|
|
70
|
+
"responses":{
|
|
71
|
+
"200": {
|
|
72
|
+
"description": "Success"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
app.use(oasTelemetry({
|
|
81
|
+
spec : JSON.stringify(spec)
|
|
82
|
+
}))
|
|
83
|
+
|
|
84
|
+
app.use(express.json());
|
|
85
|
+
|
|
86
|
+
app.get("/api/v1/pets", (req, res) => {
|
|
87
|
+
res.send([{ name: "rocky"},{ name: "pikachu"}]);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
app.listen(port, () => {
|
|
91
|
+
console.log(`Example app listening at http://localhost:${port}`);
|
|
92
|
+
console.log(`Telemetry portal available at http://localhost:${port}/telemetry`);
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Simple Example [Common.js Module](https://nodejs.org/docs/latest/api/modules.html) (*.cjs)
|
|
97
|
+
```js index.cjs
|
|
98
|
+
let oasTelemetry = require('@oas-tools/oas-telemetry');
|
|
99
|
+
let express = require('express');
|
|
100
|
+
|
|
101
|
+
const app = express();
|
|
102
|
+
const port = 3000;
|
|
103
|
+
|
|
104
|
+
const spec = { "paths": {
|
|
105
|
+
"/api/v1/pets": {
|
|
106
|
+
"get": {
|
|
107
|
+
"summary": "Get pets",
|
|
108
|
+
"responses":{
|
|
109
|
+
"200": {
|
|
110
|
+
"description": "Success"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
app.use(oasTelemetry({
|
|
119
|
+
spec : JSON.stringify(spec)
|
|
120
|
+
}))
|
|
121
|
+
|
|
122
|
+
app.use(express.json());
|
|
123
|
+
|
|
124
|
+
app.get("/api/v1/pets", (req, res) => {
|
|
125
|
+
res.send([{ name: "rocky"},{ name: "pikachu"}]);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
app.listen(port, () => {
|
|
129
|
+
console.log(`Example app listening at http://localhost:${port}`);
|
|
130
|
+
console.log(`Telemetry portal available at http://localhost:${port}/telemetry`);
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
@@ -34,6 +34,7 @@ class InMemoryExporter {
|
|
|
34
34
|
cleanSpans.forEach(t => {
|
|
35
35
|
dbglog(`Sending trace <${t._id}> to plugin (Plugin #${i}) <${p.name}>`);
|
|
36
36
|
dbglog(`Trace: \n<${JSON.stringify(t, null, 2)}`);
|
|
37
|
+
//TODO: This should be called newSpan instead of newTrace
|
|
37
38
|
p.newTrace(t);
|
|
38
39
|
});
|
|
39
40
|
});
|
|
@@ -65,8 +66,8 @@ class InMemoryExporter {
|
|
|
65
66
|
this._spans = new _nedb.default();
|
|
66
67
|
return this.forceFlush();
|
|
67
68
|
}
|
|
68
|
-
/**
|
|
69
|
-
* Exports any pending spans in the exporter
|
|
69
|
+
/**
|
|
70
|
+
* Exports any pending spans in the exporter
|
|
70
71
|
*/
|
|
71
72
|
forceFlush() {
|
|
72
73
|
return Promise.resolve();
|
|
@@ -110,30 +111,30 @@ function removeCircularRefs(obj) {
|
|
|
110
111
|
return JSON.parse(jsonString);
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
/**
|
|
114
|
-
* Recursively converts dot-separated keys in an object to nested objects.
|
|
115
|
-
*
|
|
116
|
-
* @param {Object} obj - The object to process.
|
|
117
|
-
* @returns {Object} - The object with all dot-separated keys converted to nested objects.
|
|
118
|
-
* @example
|
|
119
|
-
* // Input:
|
|
120
|
-
* // {
|
|
121
|
-
* // "http.method": "GET",
|
|
122
|
-
* // "http.url": "http://example.com",
|
|
123
|
-
* // "nested.obj.key": "value"
|
|
124
|
-
* // }
|
|
125
|
-
* // Output:
|
|
126
|
-
* // {
|
|
127
|
-
* // "http": {
|
|
128
|
-
* // "method": "GET",
|
|
129
|
-
* // "url": "http://example.com"
|
|
130
|
-
* // },
|
|
131
|
-
* // "nested": {
|
|
132
|
-
* // "obj": {
|
|
133
|
-
* // "key": "value"
|
|
134
|
-
* // }
|
|
135
|
-
* // }
|
|
136
|
-
* // }
|
|
114
|
+
/**
|
|
115
|
+
* Recursively converts dot-separated keys in an object to nested objects.
|
|
116
|
+
*
|
|
117
|
+
* @param {Object} obj - The object to process.
|
|
118
|
+
* @returns {Object} - The object with all dot-separated keys converted to nested objects.
|
|
119
|
+
* @example
|
|
120
|
+
* // Input:
|
|
121
|
+
* // {
|
|
122
|
+
* // "http.method": "GET",
|
|
123
|
+
* // "http.url": "http://example.com",
|
|
124
|
+
* // "nested.obj.key": "value"
|
|
125
|
+
* // }
|
|
126
|
+
* // Output:
|
|
127
|
+
* // {
|
|
128
|
+
* // "http": {
|
|
129
|
+
* // "method": "GET",
|
|
130
|
+
* // "url": "http://example.com"
|
|
131
|
+
* // },
|
|
132
|
+
* // "nested": {
|
|
133
|
+
* // "obj": {
|
|
134
|
+
* // "key": "value"
|
|
135
|
+
* // }
|
|
136
|
+
* // }
|
|
137
|
+
* // }
|
|
137
138
|
*/
|
|
138
139
|
function convertToNestedObject(obj) {
|
|
139
140
|
const result = {};
|
|
@@ -157,11 +158,11 @@ function convertToNestedObject(obj) {
|
|
|
157
158
|
return result;
|
|
158
159
|
}
|
|
159
160
|
|
|
160
|
-
/**
|
|
161
|
-
* Applies nesting to all dot-separated keys within an object.
|
|
162
|
-
*
|
|
163
|
-
* @param {Object} obj - The object to apply nesting to.
|
|
164
|
-
* @returns {Object} - The transformed object with nested structures.
|
|
161
|
+
/**
|
|
162
|
+
* Applies nesting to all dot-separated keys within an object.
|
|
163
|
+
*
|
|
164
|
+
* @param {Object} obj - The object to apply nesting to.
|
|
165
|
+
* @returns {Object} - The transformed object with nested structures.
|
|
165
166
|
*/
|
|
166
167
|
function applyNesting(obj) {
|
|
167
168
|
// Recursively apply convertToNestedObject to each level of the object
|
package/dist/index.cjs
CHANGED
|
@@ -12,6 +12,8 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
12
12
|
var _jsYaml = _interopRequireDefault(require("js-yaml"));
|
|
13
13
|
var _ui = _interopRequireDefault(require("./ui.cjs"));
|
|
14
14
|
var _axios = _interopRequireDefault(require("axios"));
|
|
15
|
+
var _importFromString = require("import-from-string");
|
|
16
|
+
var _dynamicInstaller = require("dynamic-installer");
|
|
15
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
18
|
// telemetryMiddleware.js
|
|
17
19
|
|
|
@@ -202,29 +204,87 @@ const listPlugins = (req, res) => {
|
|
|
202
204
|
};
|
|
203
205
|
}));
|
|
204
206
|
};
|
|
205
|
-
const registerPlugin = (req, res) => {
|
|
207
|
+
const registerPlugin = async (req, res) => {
|
|
206
208
|
let pluginResource = req.body;
|
|
207
209
|
dbglog(`Plugin Registration Request: = ${JSON.stringify(req.body, null, 2)}...`);
|
|
208
210
|
dbglog(`Getting plugin at ${pluginResource.url}...`);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
if (
|
|
217
|
-
|
|
218
|
-
pluginResource.plugin = plugin;
|
|
219
|
-
pluginResource.name = plugin.getName();
|
|
220
|
-
pluginResource.active = true;
|
|
221
|
-
plugins.push(pluginResource);
|
|
222
|
-
_telemetry.inMemoryExporter.activatePlugin(pluginResource.plugin);
|
|
223
|
-
res.status(201).send(`Plugin registered`);
|
|
211
|
+
let pluginCode;
|
|
212
|
+
if (!pluginResource.url && !pluginResource.code) {
|
|
213
|
+
res.status(400).send(`Plugin code or URL must be provided`);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
let module;
|
|
217
|
+
try {
|
|
218
|
+
if (pluginResource.code) {
|
|
219
|
+
pluginCode = pluginResource.code;
|
|
224
220
|
} else {
|
|
225
|
-
|
|
226
|
-
|
|
221
|
+
const response = await _axios.default.get(pluginResource.url);
|
|
222
|
+
pluginCode = response.data;
|
|
223
|
+
}
|
|
224
|
+
if (!pluginCode) {
|
|
225
|
+
res.status(400).send(`Plugin code could not be loaded`);
|
|
226
|
+
return;
|
|
227
227
|
}
|
|
228
|
-
|
|
228
|
+
//install dependencies if any
|
|
229
|
+
if (pluginResource.install) {
|
|
230
|
+
const dependenciesStatus = await (0, _dynamicInstaller.installDependencies)(pluginResource.install);
|
|
231
|
+
if (!dependenciesStatus.success) {
|
|
232
|
+
if (pluginResource.install.ignoreErrors === true) {
|
|
233
|
+
console.warn(`Warning: Error installing dependencies: ${JSON.stringify(dependenciesStatus.details)}`);
|
|
234
|
+
} else {
|
|
235
|
+
res.status(400).send(`Error installing dependencies: ${JSON.stringify(dependenciesStatus.details)}`);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
dbglog("Plugin size: " + pluginCode?.length);
|
|
241
|
+
dbglog("Plugin format: " + pluginResource?.moduleFormat);
|
|
242
|
+
if (pluginResource?.moduleFormat && pluginResource.moduleFormat.toUpperCase() == "ESM") {
|
|
243
|
+
console.log("ESM detected");
|
|
244
|
+
module = await (0, _importFromString.importFromString)(pluginCode);
|
|
245
|
+
} else {
|
|
246
|
+
console.log("CJS detected (default)");
|
|
247
|
+
module = await (0, _importFromString.requireFromString)(pluginCode);
|
|
248
|
+
console.log(module);
|
|
249
|
+
}
|
|
250
|
+
} catch (error) {
|
|
251
|
+
console.error(`Error loading plugin: ${error}`);
|
|
252
|
+
res.status(400).send(`Error loading plugin: ${error}`);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Check if the plugin is in module.default or module.plugin (supports default syntax)
|
|
257
|
+
const plugin = module.default?.plugin || module.plugin;
|
|
258
|
+
if (plugin == undefined) {
|
|
259
|
+
res.status(400).send(`Plugin code should export a "plugin" object`);
|
|
260
|
+
console.log("Error in plugin code: no plugin object exported");
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
for (let requiredFunction of ["load", "getName", "isConfigured"]) {
|
|
264
|
+
if (plugin[requiredFunction] == undefined) {
|
|
265
|
+
res.status(400).send(`The plugin code exports a "plugin" object, however it should have a "${requiredFunction}" method`);
|
|
266
|
+
console.log("Error in plugin code: some required functions are missing");
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
try {
|
|
271
|
+
await plugin.load(pluginResource.config);
|
|
272
|
+
} catch (error) {
|
|
273
|
+
console.error(`Error loading plugin configuration: ${error}`);
|
|
274
|
+
res.status(400).send(`Error loading plugin configuration: ${error}`);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
if (plugin.isConfigured()) {
|
|
278
|
+
dbglog(`Loaded plugin <${plugin.getName()}>`);
|
|
279
|
+
pluginResource.plugin = plugin;
|
|
280
|
+
pluginResource.name = plugin.getName();
|
|
281
|
+
pluginResource.active = true;
|
|
282
|
+
plugins.push(pluginResource);
|
|
283
|
+
_telemetry.inMemoryExporter.activatePlugin(pluginResource.plugin);
|
|
284
|
+
res.status(201).send(`Plugin registered`);
|
|
285
|
+
} else {
|
|
286
|
+
console.error(`Plugin <${plugin.getName()}> can not be configured`);
|
|
287
|
+
res.status(400).send(`Plugin configuration problem`);
|
|
288
|
+
}
|
|
229
289
|
};
|
|
230
290
|
module.exports = exports.default;
|
package/dist/telemetry.cjs
CHANGED
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export class InMemoryExporter {
|
|
2
|
+
static plugins: any[];
|
|
3
|
+
_spans: any;
|
|
4
|
+
_stopped: boolean;
|
|
5
|
+
export(readableSpans: any, resultCallback: any): any;
|
|
6
|
+
start(): void;
|
|
7
|
+
stop(): void;
|
|
8
|
+
shutdown(): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Exports any pending spans in the exporter
|
|
11
|
+
*/
|
|
12
|
+
forceFlush(): Promise<void>;
|
|
13
|
+
reset(): void;
|
|
14
|
+
getFinishedSpans(): any;
|
|
15
|
+
activatePlugin(plugin: any): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function oasTelemetry(tlConfig?: any): import("express-serve-static-core").Router;
|