@oas-tools/oas-telemetry 0.7.0 → 0.7.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/dist/cjs/index.cjs +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/types/index.d.ts +2 -1
- package/package.json +14 -15
- package/dist/cjs/telemetry/custom-implementations/exporters/PluginLogExporter.cjs +0 -45
- package/dist/cjs/telemetry/custom-implementations/exporters/PluginMetricExporter.cjs +0 -46
- package/dist/cjs/telemetry/custom-implementations/exporters/PluginSpanExporter.cjs +0 -61
- package/dist/cjs/tlm-ai/knownMicroservices.cjs +0 -13
- package/dist/esm/telemetry/custom-implementations/exporters/PluginLogExporter.js +0 -36
- package/dist/esm/telemetry/custom-implementations/exporters/PluginMetricExporter.js +0 -35
- package/dist/esm/telemetry/custom-implementations/exporters/PluginSpanExporter.js +0 -52
- package/dist/esm/tlm-ai/knownMicroservices.js +0 -5
- package/dist/types/telemetry/custom-implementations/exporters/PluginLogExporter.d.ts +0 -8
- package/dist/types/telemetry/custom-implementations/exporters/PluginMetricExporter.d.ts +0 -12
- package/dist/types/telemetry/custom-implementations/exporters/PluginSpanExporter.d.ts +0 -14
- package/dist/types/tlm-ai/knownMicroservices.d.ts +0 -6
package/dist/cjs/index.cjs
CHANGED
|
@@ -15,6 +15,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
15
15
|
// Load environment variables before any other imports
|
|
16
16
|
// Initialize OpenTelemetry instrumentation
|
|
17
17
|
|
|
18
|
+
// WARN: If changed the API, also change in packages/lib/src/types/cjs-index.d.ts (used for CJS compilation)
|
|
18
19
|
/**
|
|
19
20
|
* Returns the OAS-Telemetry middleware.
|
|
20
21
|
* All parameters are optional. However, either `spec` or `specFileName` must be provided to enable endpoint filtering.
|
package/dist/esm/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { Router } from 'express';
|
|
|
6
6
|
import { configureRoutes } from './routesManager.js';
|
|
7
7
|
import { configureTelemetry } from './telemetry/telemetryConfigurator.js';
|
|
8
8
|
import { bootEnvVariables } from "./config/bootConfig.js";
|
|
9
|
+
// WARN: If changed the API, also change in packages/lib/src/types/cjs-index.d.ts (used for CJS compilation)
|
|
9
10
|
/**
|
|
10
11
|
* Returns the OAS-Telemetry middleware.
|
|
11
12
|
* All parameters are optional. However, either `spec` or `specFileName` must be provided to enable endpoint filtering.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ import { UserConfig } from './config/config.types.js';
|
|
|
6
6
|
* Returns the OAS-Telemetry middleware.
|
|
7
7
|
* All parameters are optional. However, either `spec` or `specFileName` must be provided to enable endpoint filtering.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
declare function oasTelemetry(oasTlmInputConfig?: UserConfig): Router;
|
|
10
|
+
export = oasTelemetry;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oas-tools/oas-telemetry",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Automatically collects and stores telemetry data in memory using OpenTelemetry. Just import the Express middleware to access it through the built-in REST API or web UI—no extra setup required.",
|
|
5
5
|
"author": "Manuel Otero",
|
|
6
6
|
"contributors": [
|
|
@@ -13,26 +13,30 @@
|
|
|
13
13
|
"dev": "env OASTLM_BOOT_ENV=development tsx test/e2e/servers/otTestServer.ts",
|
|
14
14
|
"esm": "echo 'Remember to execute: \"npm run build\"' && node test/e2e/servers/otTestServer.mjs",
|
|
15
15
|
"cjs": "echo 'Remember to execute: \"npm run build\"' && node test/e2e/servers/otTestServer.cjs",
|
|
16
|
-
"build": "npm run build:esm && npm run build:cjs",
|
|
16
|
+
"build": "npm run build:esm && npm run build:cjs && npm run copy:types",
|
|
17
17
|
"build:esm": "tsc -p tsconfig.json && npm run copy:spec",
|
|
18
18
|
"copy:spec": "mkdir -p dist/esm/docs dist/cjs/docs && cp src/docs/openapi.yaml dist/esm/docs/ && cp src/docs/openapi.yaml dist/cjs/docs/",
|
|
19
19
|
"build:cjs": "babel ./dist/esm -d ./dist/cjs --out-file-extension .cjs --config-file ./.babelrc",
|
|
20
20
|
"test": "vitest --run",
|
|
21
21
|
"test:watch": "vitest",
|
|
22
|
-
"lint": "eslint --ext .ts . --fix"
|
|
22
|
+
"lint": "eslint --ext .ts . --fix",
|
|
23
|
+
"copy:types": "mkdir -p dist/types && cp src/types/cjs-index.d.ts dist/types/index.d.ts"
|
|
23
24
|
},
|
|
24
25
|
"files": [
|
|
25
26
|
".env.example",
|
|
26
27
|
"NOTICE",
|
|
27
28
|
"dist"
|
|
28
29
|
],
|
|
29
|
-
"main": "./dist/cjs/index.cjs",
|
|
30
|
-
"module": "./dist/esm/index.js",
|
|
31
|
-
"types": "./dist/types/index.d.ts",
|
|
32
30
|
"exports": {
|
|
33
31
|
".": {
|
|
34
|
-
"require":
|
|
35
|
-
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./dist/types/index.d.ts",
|
|
34
|
+
"require": "./dist/cjs/index.cjs"
|
|
35
|
+
},
|
|
36
|
+
"import": {
|
|
37
|
+
"types": "./dist/types/index.d.ts",
|
|
38
|
+
"import": "./dist/esm/index.js"
|
|
39
|
+
}
|
|
36
40
|
}
|
|
37
41
|
},
|
|
38
42
|
"engines": {
|
|
@@ -51,6 +55,7 @@
|
|
|
51
55
|
"@opentelemetry/sdk-trace-node": "^2.0.1",
|
|
52
56
|
"@opentelemetry/semantic-conventions": "^1.34.0",
|
|
53
57
|
"@seald-io/nedb": "^4.1.2",
|
|
58
|
+
"axios": "^1.12.2",
|
|
54
59
|
"cookie-parser": "^1.4.7",
|
|
55
60
|
"cors": "^2.8.5",
|
|
56
61
|
"dotenv": "^17.0.1",
|
|
@@ -72,14 +77,13 @@
|
|
|
72
77
|
"@babel/plugin-transform-object-rest-spread": "^7.27.3",
|
|
73
78
|
"@babel/preset-env": "^7.24.4",
|
|
74
79
|
"@eslint/js": "^9.29.0",
|
|
75
|
-
"@opentelemetry/api": "^1.
|
|
80
|
+
"@opentelemetry/api": "^1.9.0",
|
|
76
81
|
"@types/cookie-parser": "^1.4.9",
|
|
77
82
|
"@types/cors": "^2.8.19",
|
|
78
83
|
"@types/express": "^5.0.3",
|
|
79
84
|
"@types/js-yaml": "^4.0.9",
|
|
80
85
|
"@types/jsonwebtoken": "^9.0.9",
|
|
81
86
|
"@types/lodash.merge": "^4.6.9",
|
|
82
|
-
"axios": "1.12.2",
|
|
83
87
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
84
88
|
"babel-plugin-module-extension": "^0.1.3",
|
|
85
89
|
"babel-plugin-transform-import-meta": "^2.3.3",
|
|
@@ -89,10 +93,5 @@
|
|
|
89
93
|
"typescript": "^5.9.3",
|
|
90
94
|
"typescript-eslint": "^8.34.1",
|
|
91
95
|
"vitest": "^3.2.4"
|
|
92
|
-
},
|
|
93
|
-
"optionalDependencies": {
|
|
94
|
-
"typescript": "^5.9.3",
|
|
95
|
-
"typescriptasdfasdfasdfasdfasdfasdfasdf": "*",
|
|
96
|
-
"typescriptttt": "*"
|
|
97
96
|
}
|
|
98
97
|
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.PluginLogExporter = void 0;
|
|
7
|
-
var _core = require("@opentelemetry/core");
|
|
8
|
-
var _logger = _interopRequireDefault(require("../../../utils/logger.cjs"));
|
|
9
|
-
var _wrappers = require("../wrappers.cjs");
|
|
10
|
-
var _pluginService = require("../../../tlm-plugin/pluginService.cjs");
|
|
11
|
-
var _circular = require("../utils/circular.cjs");
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
class PluginLogExporter extends _wrappers.Enabler {
|
|
14
|
-
constructor() {
|
|
15
|
-
super();
|
|
16
|
-
}
|
|
17
|
-
export(logs, resultCallback) {
|
|
18
|
-
_logger.default.debug('PluginLogExporter.export called with logs: ', logs.length);
|
|
19
|
-
try {
|
|
20
|
-
if (!this.isEnabled()) {
|
|
21
|
-
_logger.default.debug('PluginLogExporter is not enabled. Skipping export.');
|
|
22
|
-
return resultCallback({
|
|
23
|
-
code: _core.ExportResultCode.SUCCESS
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
const cleanLogs = logs.map(log => (0, _circular.removeCircularRefs)(log)).map(log => (0, _circular.applyNesting)(log));
|
|
27
|
-
cleanLogs.forEach(log => {
|
|
28
|
-
_pluginService.pluginService.broadcastLog(log);
|
|
29
|
-
});
|
|
30
|
-
setTimeout(() => resultCallback({
|
|
31
|
-
code: _core.ExportResultCode.SUCCESS
|
|
32
|
-
}), 0);
|
|
33
|
-
} catch (error) {
|
|
34
|
-
_logger.default.error('Error exporting logs\n' + error.message + '\n' + error.stack);
|
|
35
|
-
return resultCallback({
|
|
36
|
-
code: _core.ExportResultCode.FAILED,
|
|
37
|
-
error: new Error('Error exporting logs\n' + error.message + '\n' + error.stack)
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
shutdown() {
|
|
42
|
-
return Promise.resolve();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.PluginLogExporter = PluginLogExporter;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.PluginMetricExporter = void 0;
|
|
7
|
-
var _core = require("@opentelemetry/core");
|
|
8
|
-
var _logger = _interopRequireDefault(require("../../../utils/logger.cjs"));
|
|
9
|
-
var _wrappers = require("../wrappers.cjs");
|
|
10
|
-
var _pluginService = require("../../../tlm-plugin/pluginService.cjs");
|
|
11
|
-
var _circular = require("../utils/circular.cjs");
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
class PluginMetricExporter extends _wrappers.Enabler {
|
|
14
|
-
constructor() {
|
|
15
|
-
super();
|
|
16
|
-
}
|
|
17
|
-
export(metrics, resultCallback) {
|
|
18
|
-
_logger.default.debug('PluginMetricExporter.export called');
|
|
19
|
-
try {
|
|
20
|
-
if (!this.isEnabled()) {
|
|
21
|
-
_logger.default.debug('PluginMetricExporter is not enabled. Skipping export.');
|
|
22
|
-
return resultCallback({
|
|
23
|
-
code: _core.ExportResultCode.SUCCESS
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
const cleanMetrics = (0, _circular.applyNesting)((0, _circular.removeCircularRefs)(metrics));
|
|
27
|
-
_pluginService.pluginService.broadcastMetric(cleanMetrics);
|
|
28
|
-
setTimeout(() => resultCallback({
|
|
29
|
-
code: _core.ExportResultCode.SUCCESS
|
|
30
|
-
}), 0);
|
|
31
|
-
} catch (error) {
|
|
32
|
-
_logger.default.error('Error exporting metrics\n' + error.message + '\n' + error.stack);
|
|
33
|
-
return resultCallback({
|
|
34
|
-
code: _core.ExportResultCode.FAILED,
|
|
35
|
-
error: new Error('Error exporting metrics\n' + error.message + '\n' + error.stack)
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
shutdown() {
|
|
40
|
-
return Promise.resolve();
|
|
41
|
-
}
|
|
42
|
-
forceFlush() {
|
|
43
|
-
return Promise.resolve();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.PluginMetricExporter = PluginMetricExporter;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.PluginSpanExporter = void 0;
|
|
7
|
-
var _core = require("@opentelemetry/core");
|
|
8
|
-
var _logger = _interopRequireDefault(require("../../../utils/logger.cjs"));
|
|
9
|
-
var _wrappers = require("../wrappers.cjs");
|
|
10
|
-
var _pluginService = require("../../../tlm-plugin/pluginService.cjs");
|
|
11
|
-
var _circular = require("../utils/circular.cjs");
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
class PluginSpanExporter extends _wrappers.Enabler {
|
|
14
|
-
constructor() {
|
|
15
|
-
super();
|
|
16
|
-
this._baseUrl = '/telemetry'; // Default base URL, can be overridden by the config
|
|
17
|
-
}
|
|
18
|
-
set baseUrl(baseUrl) {
|
|
19
|
-
this._baseUrl = baseUrl;
|
|
20
|
-
}
|
|
21
|
-
export(readableSpans, resultCallback) {
|
|
22
|
-
_logger.default.debug('PluginSpanExporter.export called with spans: ', readableSpans.length);
|
|
23
|
-
try {
|
|
24
|
-
if (!this.isEnabled()) {
|
|
25
|
-
_logger.default.debug('PluginSpanExporter is not enabled. Skipping export.');
|
|
26
|
-
return resultCallback({
|
|
27
|
-
code: _core.ExportResultCode.SUCCESS
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
// Prepare spans to be inserted into the in-memory database (remove circular references and convert to nested objects)
|
|
31
|
-
const cleanSpans = readableSpans.map(nestedSpan => (0, _circular.removeCircularRefs)(nestedSpan)) // to avoid JSON parsing error
|
|
32
|
-
.map(span => (0, _circular.applyNesting)(span)) // to avoid dot notation in keys (neDB does not support dot notation in keys)
|
|
33
|
-
.filter(span => {
|
|
34
|
-
const target = span?.attributes?.http?.target; // Exclude spans where target includes 'telemetry' but NOT 'telemetry/utils'
|
|
35
|
-
if (target && target.includes(this._baseUrl)) {
|
|
36
|
-
return target.includes(this._baseUrl + '/utils');
|
|
37
|
-
}
|
|
38
|
-
return true;
|
|
39
|
-
});
|
|
40
|
-
cleanSpans.forEach(span => {
|
|
41
|
-
_pluginService.pluginService.broadcastTrace(span);
|
|
42
|
-
});
|
|
43
|
-
setTimeout(() => resultCallback({
|
|
44
|
-
code: _core.ExportResultCode.SUCCESS
|
|
45
|
-
}), 0);
|
|
46
|
-
} catch (error) {
|
|
47
|
-
_logger.default.error('Error exporting spans\n' + error.message + '\n' + error.stack);
|
|
48
|
-
return resultCallback({
|
|
49
|
-
code: _core.ExportResultCode.FAILED,
|
|
50
|
-
error: new Error('Error exporting spans\n' + error.message + '\n' + error.stack)
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
shutdown() {
|
|
55
|
-
return this.forceFlush();
|
|
56
|
-
}
|
|
57
|
-
forceFlush() {
|
|
58
|
-
return Promise.resolve();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.PluginSpanExporter = PluginSpanExporter;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.setKnownMicroservices = exports.getKnownMicroservices = void 0;
|
|
7
|
-
let knownMicroservices = null;
|
|
8
|
-
const getKnownMicroservices = () => knownMicroservices || [];
|
|
9
|
-
exports.getKnownMicroservices = getKnownMicroservices;
|
|
10
|
-
const setKnownMicroservices = microservices => {
|
|
11
|
-
knownMicroservices = microservices;
|
|
12
|
-
};
|
|
13
|
-
exports.setKnownMicroservices = setKnownMicroservices;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ExportResultCode } from '@opentelemetry/core';
|
|
2
|
-
import logger from '../../../utils/logger.js';
|
|
3
|
-
import { Enabler } from '../wrappers.js';
|
|
4
|
-
import { pluginService } from '../../../tlm-plugin/pluginService.js';
|
|
5
|
-
import { applyNesting, removeCircularRefs } from '../utils/circular.js';
|
|
6
|
-
export class PluginLogExporter extends Enabler {
|
|
7
|
-
constructor() {
|
|
8
|
-
super();
|
|
9
|
-
}
|
|
10
|
-
export(logs, resultCallback) {
|
|
11
|
-
logger.debug('PluginLogExporter.export called with logs: ', logs.length);
|
|
12
|
-
try {
|
|
13
|
-
if (!this.isEnabled()) {
|
|
14
|
-
logger.debug('PluginLogExporter is not enabled. Skipping export.');
|
|
15
|
-
return resultCallback({ code: ExportResultCode.SUCCESS });
|
|
16
|
-
}
|
|
17
|
-
const cleanLogs = logs
|
|
18
|
-
.map(log => removeCircularRefs(log))
|
|
19
|
-
.map(log => applyNesting(log));
|
|
20
|
-
cleanLogs.forEach(log => {
|
|
21
|
-
pluginService.broadcastLog(log);
|
|
22
|
-
});
|
|
23
|
-
setTimeout(() => resultCallback({ code: ExportResultCode.SUCCESS }), 0);
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
logger.error('Error exporting logs\n' + error.message + '\n' + error.stack);
|
|
27
|
-
return resultCallback({
|
|
28
|
-
code: ExportResultCode.FAILED,
|
|
29
|
-
error: new Error('Error exporting logs\n' + error.message + '\n' + error.stack),
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
shutdown() {
|
|
34
|
-
return Promise.resolve();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ExportResultCode } from '@opentelemetry/core';
|
|
2
|
-
import logger from '../../../utils/logger.js';
|
|
3
|
-
import { Enabler } from '../wrappers.js';
|
|
4
|
-
import { pluginService } from '../../../tlm-plugin/pluginService.js';
|
|
5
|
-
import { applyNesting, removeCircularRefs } from '../utils/circular.js';
|
|
6
|
-
export class PluginMetricExporter extends Enabler {
|
|
7
|
-
constructor() {
|
|
8
|
-
super();
|
|
9
|
-
}
|
|
10
|
-
export(metrics, resultCallback) {
|
|
11
|
-
logger.debug('PluginMetricExporter.export called');
|
|
12
|
-
try {
|
|
13
|
-
if (!this.isEnabled()) {
|
|
14
|
-
logger.debug('PluginMetricExporter is not enabled. Skipping export.');
|
|
15
|
-
return resultCallback({ code: ExportResultCode.SUCCESS });
|
|
16
|
-
}
|
|
17
|
-
const cleanMetrics = applyNesting(removeCircularRefs(metrics));
|
|
18
|
-
pluginService.broadcastMetric(cleanMetrics);
|
|
19
|
-
setTimeout(() => resultCallback({ code: ExportResultCode.SUCCESS }), 0);
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
logger.error('Error exporting metrics\n' + error.message + '\n' + error.stack);
|
|
23
|
-
return resultCallback({
|
|
24
|
-
code: ExportResultCode.FAILED,
|
|
25
|
-
error: new Error('Error exporting metrics\n' + error.message + '\n' + error.stack),
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
shutdown() {
|
|
30
|
-
return Promise.resolve();
|
|
31
|
-
}
|
|
32
|
-
forceFlush() {
|
|
33
|
-
return Promise.resolve();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { ExportResultCode } from '@opentelemetry/core';
|
|
2
|
-
import logger from '../../../utils/logger.js';
|
|
3
|
-
import { Enabler } from '../wrappers.js';
|
|
4
|
-
import { pluginService } from '../../../tlm-plugin/pluginService.js';
|
|
5
|
-
import { applyNesting, removeCircularRefs } from '../utils/circular.js';
|
|
6
|
-
export class PluginSpanExporter extends Enabler {
|
|
7
|
-
constructor() {
|
|
8
|
-
super();
|
|
9
|
-
this._baseUrl = '/telemetry'; // Default base URL, can be overridden by the config
|
|
10
|
-
}
|
|
11
|
-
;
|
|
12
|
-
set baseUrl(baseUrl) {
|
|
13
|
-
this._baseUrl = baseUrl;
|
|
14
|
-
}
|
|
15
|
-
export(readableSpans, resultCallback) {
|
|
16
|
-
logger.debug('PluginSpanExporter.export called with spans: ', readableSpans.length);
|
|
17
|
-
try {
|
|
18
|
-
if (!this.isEnabled()) {
|
|
19
|
-
logger.debug('PluginSpanExporter is not enabled. Skipping export.');
|
|
20
|
-
return resultCallback({ code: ExportResultCode.SUCCESS });
|
|
21
|
-
}
|
|
22
|
-
// Prepare spans to be inserted into the in-memory database (remove circular references and convert to nested objects)
|
|
23
|
-
const cleanSpans = readableSpans
|
|
24
|
-
.map(nestedSpan => removeCircularRefs(nestedSpan)) // to avoid JSON parsing error
|
|
25
|
-
.map(span => applyNesting(span)) // to avoid dot notation in keys (neDB does not support dot notation in keys)
|
|
26
|
-
.filter(span => {
|
|
27
|
-
const target = span?.attributes?.http?.target; // Exclude spans where target includes 'telemetry' but NOT 'telemetry/utils'
|
|
28
|
-
if (target && target.includes(this._baseUrl)) {
|
|
29
|
-
return target.includes(this._baseUrl + '/utils');
|
|
30
|
-
}
|
|
31
|
-
return true;
|
|
32
|
-
});
|
|
33
|
-
cleanSpans.forEach(span => {
|
|
34
|
-
pluginService.broadcastTrace(span);
|
|
35
|
-
});
|
|
36
|
-
setTimeout(() => resultCallback({ code: ExportResultCode.SUCCESS }), 0);
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
logger.error('Error exporting spans\n' + error.message + '\n' + error.stack);
|
|
40
|
-
return resultCallback({
|
|
41
|
-
code: ExportResultCode.FAILED,
|
|
42
|
-
error: new Error('Error exporting spans\n' + error.message + '\n' + error.stack),
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
shutdown() {
|
|
47
|
-
return this.forceFlush();
|
|
48
|
-
}
|
|
49
|
-
forceFlush() {
|
|
50
|
-
return Promise.resolve();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ExportResult } from '@opentelemetry/core';
|
|
2
|
-
import { ReadableLogRecord, LogRecordExporter } from '@opentelemetry/sdk-logs';
|
|
3
|
-
import { Enabler } from '../wrappers.js';
|
|
4
|
-
export declare class PluginLogExporter extends Enabler implements LogRecordExporter {
|
|
5
|
-
constructor();
|
|
6
|
-
export(logs: ReadableLogRecord[], resultCallback: (result: ExportResult) => void): void;
|
|
7
|
-
shutdown(): Promise<void>;
|
|
8
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ExportResultCode } from '@opentelemetry/core';
|
|
2
|
-
import { ResourceMetrics, PushMetricExporter } from '@opentelemetry/sdk-metrics';
|
|
3
|
-
import { Enabler } from '../wrappers.js';
|
|
4
|
-
export declare class PluginMetricExporter extends Enabler implements PushMetricExporter {
|
|
5
|
-
constructor();
|
|
6
|
-
export(metrics: ResourceMetrics, resultCallback: (result: {
|
|
7
|
-
code: ExportResultCode;
|
|
8
|
-
error?: Error;
|
|
9
|
-
}) => void): void;
|
|
10
|
-
shutdown(): Promise<void>;
|
|
11
|
-
forceFlush(): Promise<void>;
|
|
12
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ExportResultCode } from '@opentelemetry/core';
|
|
2
|
-
import { ReadableSpan, SpanExporter } from '@opentelemetry/sdk-trace-base';
|
|
3
|
-
import { Enabler } from '../wrappers.js';
|
|
4
|
-
export declare class PluginSpanExporter extends Enabler implements SpanExporter {
|
|
5
|
-
private _baseUrl;
|
|
6
|
-
constructor();
|
|
7
|
-
set baseUrl(baseUrl: string);
|
|
8
|
-
export(readableSpans: ReadableSpan[], resultCallback: (result: {
|
|
9
|
-
code: ExportResultCode;
|
|
10
|
-
error?: Error;
|
|
11
|
-
}) => void): void;
|
|
12
|
-
shutdown(): Promise<void>;
|
|
13
|
-
forceFlush(): Promise<void>;
|
|
14
|
-
}
|