@nocobase/telemetry 1.2.12-alpha → 1.3.0-alpha.20240710084543
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/package.json +3 -3
- package/lib/index.d.ts +0 -9
- package/lib/index.js +0 -30
- package/lib/metric.d.ts +0 -34
- package/lib/metric.js +0 -100
- package/lib/telemetry.d.ts +0 -30
- package/lib/telemetry.js +0 -85
- package/lib/trace.d.ts +0 -33
- package/lib/trace.js +0 -83
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/telemetry",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-alpha.20240710084543",
|
|
4
4
|
"description": "nocobase telemetry library",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"directory": "packages/telemetry"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@nocobase/utils": "1.
|
|
14
|
+
"@nocobase/utils": "1.3.0-alpha.20240710084543",
|
|
15
15
|
"@opentelemetry/api": "^1.7.0",
|
|
16
16
|
"@opentelemetry/instrumentation": "^0.46.0",
|
|
17
17
|
"@opentelemetry/resources": "^1.19.0",
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
"@opentelemetry/sdk-trace-node": "^1.19.0",
|
|
21
21
|
"@opentelemetry/semantic-conventions": "^1.19.0"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "07a8b596fc64a9779a194cb9b0dc2ca7570ed9d4"
|
|
24
24
|
}
|
package/lib/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
export * from './telemetry';
|
package/lib/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __copyProps = (to, from, except, desc) => {
|
|
15
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
-
for (let key of __getOwnPropNames(from))
|
|
17
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
23
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
-
var src_exports = {};
|
|
25
|
-
module.exports = __toCommonJS(src_exports);
|
|
26
|
-
__reExport(src_exports, require("./telemetry"), module.exports);
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
...require("./telemetry")
|
|
30
|
-
});
|
package/lib/metric.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { Registry } from '@nocobase/utils';
|
|
10
|
-
import { MetricReader, MeterProvider, View } from '@opentelemetry/sdk-metrics';
|
|
11
|
-
import { Resource } from '@opentelemetry/resources';
|
|
12
|
-
export type MetricOptions = {
|
|
13
|
-
meterName?: string;
|
|
14
|
-
version?: string;
|
|
15
|
-
readerName?: string | string[];
|
|
16
|
-
};
|
|
17
|
-
type GetMetricReader = () => MetricReader;
|
|
18
|
-
export declare class Metric {
|
|
19
|
-
meterName: string;
|
|
20
|
-
version: string;
|
|
21
|
-
readerName: string | string[];
|
|
22
|
-
readers: Registry<GetMetricReader>;
|
|
23
|
-
provider: MeterProvider;
|
|
24
|
-
views: View[];
|
|
25
|
-
constructor(options?: MetricOptions);
|
|
26
|
-
init(resource: Resource): void;
|
|
27
|
-
registerReader(name: string, reader: GetMetricReader): void;
|
|
28
|
-
getReader(name: string): GetMetricReader;
|
|
29
|
-
addView(...view: View[]): void;
|
|
30
|
-
getMeter(name?: string, version?: string): import("@opentelemetry/api").Meter;
|
|
31
|
-
start(): void;
|
|
32
|
-
shutdown(): Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
export {};
|
package/lib/metric.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
-
var __export = (target, all) => {
|
|
18
|
-
for (var name in all)
|
|
19
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
-
};
|
|
21
|
-
var __copyProps = (to, from, except, desc) => {
|
|
22
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
-
for (let key of __getOwnPropNames(from))
|
|
24
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
-
}
|
|
27
|
-
return to;
|
|
28
|
-
};
|
|
29
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
-
mod
|
|
36
|
-
));
|
|
37
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
-
var metric_exports = {};
|
|
39
|
-
__export(metric_exports, {
|
|
40
|
-
Metric: () => Metric
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(metric_exports);
|
|
43
|
-
var import_utils = require("@nocobase/utils");
|
|
44
|
-
var import_sdk_metrics = require("@opentelemetry/sdk-metrics");
|
|
45
|
-
var import_api = __toESM(require("@opentelemetry/api"));
|
|
46
|
-
const _Metric = class _Metric {
|
|
47
|
-
meterName;
|
|
48
|
-
version;
|
|
49
|
-
readerName;
|
|
50
|
-
readers = new import_utils.Registry();
|
|
51
|
-
provider;
|
|
52
|
-
views = [];
|
|
53
|
-
constructor(options) {
|
|
54
|
-
const { meterName, readerName, version } = options || {};
|
|
55
|
-
this.readerName = readerName || "console";
|
|
56
|
-
this.meterName = meterName || "nocobase-meter";
|
|
57
|
-
this.version = version || "";
|
|
58
|
-
this.registerReader(
|
|
59
|
-
"console",
|
|
60
|
-
() => new import_sdk_metrics.PeriodicExportingMetricReader({
|
|
61
|
-
exporter: new import_sdk_metrics.ConsoleMetricExporter()
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
init(resource) {
|
|
66
|
-
this.provider = new import_sdk_metrics.MeterProvider({ resource, views: this.views });
|
|
67
|
-
import_api.default.metrics.setGlobalMeterProvider(this.provider);
|
|
68
|
-
}
|
|
69
|
-
registerReader(name, reader) {
|
|
70
|
-
this.readers.register(name, reader);
|
|
71
|
-
}
|
|
72
|
-
getReader(name) {
|
|
73
|
-
return this.readers.get(name);
|
|
74
|
-
}
|
|
75
|
-
addView(...view) {
|
|
76
|
-
this.views.push(...view);
|
|
77
|
-
}
|
|
78
|
-
getMeter(name, version) {
|
|
79
|
-
return this.provider.getMeter(name || this.meterName, version || this.version);
|
|
80
|
-
}
|
|
81
|
-
start() {
|
|
82
|
-
let readerName = this.readerName;
|
|
83
|
-
if (typeof readerName === "string") {
|
|
84
|
-
readerName = readerName.split(",");
|
|
85
|
-
}
|
|
86
|
-
readerName.forEach((name) => {
|
|
87
|
-
const reader = this.getReader(name)();
|
|
88
|
-
this.provider.addMetricReader(reader);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
shutdown() {
|
|
92
|
-
return this.provider.shutdown();
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
__name(_Metric, "Metric");
|
|
96
|
-
let Metric = _Metric;
|
|
97
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
98
|
-
0 && (module.exports = {
|
|
99
|
-
Metric
|
|
100
|
-
});
|
package/lib/telemetry.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { InstrumentationOption } from '@opentelemetry/instrumentation';
|
|
10
|
-
import { Metric, MetricOptions } from './metric';
|
|
11
|
-
import { Trace, TraceOptions } from './trace';
|
|
12
|
-
export interface TelemetryOptions {
|
|
13
|
-
serviceName?: string;
|
|
14
|
-
version?: string;
|
|
15
|
-
trace?: TraceOptions;
|
|
16
|
-
metric?: MetricOptions;
|
|
17
|
-
}
|
|
18
|
-
export declare class Telemetry {
|
|
19
|
-
serviceName: string;
|
|
20
|
-
version: string;
|
|
21
|
-
instrumentations: InstrumentationOption[];
|
|
22
|
-
trace: Trace;
|
|
23
|
-
metric: Metric;
|
|
24
|
-
started: boolean;
|
|
25
|
-
constructor(options?: TelemetryOptions);
|
|
26
|
-
init(): void;
|
|
27
|
-
start(): void;
|
|
28
|
-
shutdown(): Promise<void>;
|
|
29
|
-
addInstrumentation(...instrumentation: InstrumentationOption[]): void;
|
|
30
|
-
}
|
package/lib/telemetry.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
-
var __export = (target, all) => {
|
|
16
|
-
for (var name in all)
|
|
17
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
-
};
|
|
19
|
-
var __copyProps = (to, from, except, desc) => {
|
|
20
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
-
for (let key of __getOwnPropNames(from))
|
|
22
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
-
}
|
|
25
|
-
return to;
|
|
26
|
-
};
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var telemetry_exports = {};
|
|
29
|
-
__export(telemetry_exports, {
|
|
30
|
-
Telemetry: () => Telemetry
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(telemetry_exports);
|
|
33
|
-
var import_semantic_conventions = require("@opentelemetry/semantic-conventions");
|
|
34
|
-
var import_resources = require("@opentelemetry/resources");
|
|
35
|
-
var import_instrumentation = require("@opentelemetry/instrumentation");
|
|
36
|
-
var import_metric = require("./metric");
|
|
37
|
-
var import_trace = require("./trace");
|
|
38
|
-
const _Telemetry = class _Telemetry {
|
|
39
|
-
serviceName;
|
|
40
|
-
version;
|
|
41
|
-
instrumentations = [];
|
|
42
|
-
trace;
|
|
43
|
-
metric;
|
|
44
|
-
started = false;
|
|
45
|
-
constructor(options) {
|
|
46
|
-
const { trace, metric, serviceName, version } = options || {};
|
|
47
|
-
this.trace = new import_trace.Trace({ tracerName: `${serviceName}-trace`, version, ...trace });
|
|
48
|
-
this.metric = new import_metric.Metric({ meterName: `${serviceName}-meter`, version, ...metric });
|
|
49
|
-
this.serviceName = serviceName || "nocobase";
|
|
50
|
-
this.version = version || "";
|
|
51
|
-
}
|
|
52
|
-
init() {
|
|
53
|
-
(0, import_instrumentation.registerInstrumentations)({
|
|
54
|
-
instrumentations: this.instrumentations
|
|
55
|
-
});
|
|
56
|
-
const resource = import_resources.Resource.default().merge(
|
|
57
|
-
new import_resources.Resource({
|
|
58
|
-
[import_semantic_conventions.SemanticResourceAttributes.SERVICE_NAME]: this.serviceName,
|
|
59
|
-
[import_semantic_conventions.SemanticResourceAttributes.SERVICE_VERSION]: this.version
|
|
60
|
-
})
|
|
61
|
-
);
|
|
62
|
-
this.trace.init(resource);
|
|
63
|
-
this.metric.init(resource);
|
|
64
|
-
}
|
|
65
|
-
start() {
|
|
66
|
-
if (!this.started) {
|
|
67
|
-
this.trace.start();
|
|
68
|
-
this.metric.start();
|
|
69
|
-
}
|
|
70
|
-
this.started = true;
|
|
71
|
-
}
|
|
72
|
-
async shutdown() {
|
|
73
|
-
await Promise.all([this.trace.shutdown(), this.metric.shutdown()]);
|
|
74
|
-
this.started = false;
|
|
75
|
-
}
|
|
76
|
-
addInstrumentation(...instrumentation) {
|
|
77
|
-
this.instrumentations.push(...instrumentation);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
__name(_Telemetry, "Telemetry");
|
|
81
|
-
let Telemetry = _Telemetry;
|
|
82
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
83
|
-
0 && (module.exports = {
|
|
84
|
-
Telemetry
|
|
85
|
-
});
|
package/lib/trace.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { Registry } from '@nocobase/utils';
|
|
10
|
-
import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
11
|
-
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
|
|
12
|
-
import { Resource } from '@opentelemetry/resources';
|
|
13
|
-
export type TraceOptions = {
|
|
14
|
-
tracerName?: string;
|
|
15
|
-
version?: string;
|
|
16
|
-
processorName?: string | string[];
|
|
17
|
-
};
|
|
18
|
-
type GetSpanProcessor = () => SpanProcessor;
|
|
19
|
-
export declare class Trace {
|
|
20
|
-
processorName: string | string[];
|
|
21
|
-
processors: Registry<GetSpanProcessor>;
|
|
22
|
-
tracerName: string;
|
|
23
|
-
version: string;
|
|
24
|
-
provider: NodeTracerProvider;
|
|
25
|
-
constructor(options?: TraceOptions);
|
|
26
|
-
init(resource: Resource): void;
|
|
27
|
-
registerProcessor(name: string, processor: GetSpanProcessor): void;
|
|
28
|
-
getProcessor(name: string): GetSpanProcessor;
|
|
29
|
-
getTracer(name?: string, version?: string): import("@opentelemetry/sdk-trace-base").Tracer;
|
|
30
|
-
start(): void;
|
|
31
|
-
shutdown(): Promise<void>;
|
|
32
|
-
}
|
|
33
|
-
export {};
|
package/lib/trace.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
-
var __export = (target, all) => {
|
|
16
|
-
for (var name in all)
|
|
17
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
-
};
|
|
19
|
-
var __copyProps = (to, from, except, desc) => {
|
|
20
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
-
for (let key of __getOwnPropNames(from))
|
|
22
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
-
}
|
|
25
|
-
return to;
|
|
26
|
-
};
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var trace_exports = {};
|
|
29
|
-
__export(trace_exports, {
|
|
30
|
-
Trace: () => Trace
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(trace_exports);
|
|
33
|
-
var import_utils = require("@nocobase/utils");
|
|
34
|
-
var import_sdk_trace_base = require("@opentelemetry/sdk-trace-base");
|
|
35
|
-
var import_sdk_trace_node = require("@opentelemetry/sdk-trace-node");
|
|
36
|
-
const _Trace = class _Trace {
|
|
37
|
-
processorName;
|
|
38
|
-
processors = new import_utils.Registry();
|
|
39
|
-
tracerName;
|
|
40
|
-
version;
|
|
41
|
-
provider;
|
|
42
|
-
constructor(options) {
|
|
43
|
-
const { processorName, tracerName, version } = options || {};
|
|
44
|
-
this.processorName = processorName || "console";
|
|
45
|
-
this.tracerName = tracerName || "nocobase-trace";
|
|
46
|
-
this.version = version || "";
|
|
47
|
-
this.registerProcessor("console", () => new import_sdk_trace_base.BatchSpanProcessor(new import_sdk_trace_base.ConsoleSpanExporter()));
|
|
48
|
-
}
|
|
49
|
-
init(resource) {
|
|
50
|
-
this.provider = new import_sdk_trace_node.NodeTracerProvider({
|
|
51
|
-
resource
|
|
52
|
-
});
|
|
53
|
-
this.provider.register();
|
|
54
|
-
}
|
|
55
|
-
registerProcessor(name, processor) {
|
|
56
|
-
this.processors.register(name, processor);
|
|
57
|
-
}
|
|
58
|
-
getProcessor(name) {
|
|
59
|
-
return this.processors.get(name);
|
|
60
|
-
}
|
|
61
|
-
getTracer(name, version) {
|
|
62
|
-
return this.provider.getTracer(name || this.tracerName, version || this.version);
|
|
63
|
-
}
|
|
64
|
-
start() {
|
|
65
|
-
let processorName = this.processorName;
|
|
66
|
-
if (typeof processorName === "string") {
|
|
67
|
-
processorName = processorName.split(",");
|
|
68
|
-
}
|
|
69
|
-
processorName.forEach((name) => {
|
|
70
|
-
const processor = this.getProcessor(name)();
|
|
71
|
-
this.provider.addSpanProcessor(processor);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
shutdown() {
|
|
75
|
-
return this.provider.shutdown();
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
__name(_Trace, "Trace");
|
|
79
|
-
let Trace = _Trace;
|
|
80
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
-
0 && (module.exports = {
|
|
82
|
-
Trace
|
|
83
|
-
});
|