@nocobase/telemetry 2.0.0-alpha.42 → 2.0.0-alpha.44
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/lib/metric.js +21 -1
- package/package.json +3 -3
package/lib/metric.js
CHANGED
|
@@ -59,7 +59,9 @@ const _Metric = class _Metric {
|
|
|
59
59
|
this.registerReader(
|
|
60
60
|
"console",
|
|
61
61
|
() => new import_sdk_metrics.PeriodicExportingMetricReader({
|
|
62
|
-
exporter: new import_sdk_metrics.ConsoleMetricExporter(
|
|
62
|
+
exporter: new import_sdk_metrics.ConsoleMetricExporter({
|
|
63
|
+
temporalitySelector: /* @__PURE__ */ __name(() => import_sdk_metrics.AggregationTemporality.DELTA, "temporalitySelector")
|
|
64
|
+
})
|
|
63
65
|
})
|
|
64
66
|
);
|
|
65
67
|
}
|
|
@@ -76,6 +78,21 @@ const _Metric = class _Metric {
|
|
|
76
78
|
if (!this.resource) {
|
|
77
79
|
throw new Error("Metric.init(resource) must be called before start()");
|
|
78
80
|
}
|
|
81
|
+
const metricNames = new Set(
|
|
82
|
+
(process.env.TELEMETRY_METRICS || "").split(",").map((s) => s.trim()).filter(Boolean)
|
|
83
|
+
);
|
|
84
|
+
const views = [];
|
|
85
|
+
if (metricNames.size > 0) {
|
|
86
|
+
for (const metricName of metricNames) {
|
|
87
|
+
views.push({
|
|
88
|
+
instrumentName: metricName
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
views.push({
|
|
92
|
+
instrumentName: "*",
|
|
93
|
+
aggregation: { type: import_sdk_metrics.AggregationType.DROP }
|
|
94
|
+
});
|
|
95
|
+
}
|
|
79
96
|
let readerNames = this.readerName;
|
|
80
97
|
if (typeof readerNames === "string") {
|
|
81
98
|
readerNames = readerNames.split(",").map((n) => n.trim()).filter(Boolean);
|
|
@@ -93,6 +110,9 @@ const _Metric = class _Metric {
|
|
|
93
110
|
resource: this.resource,
|
|
94
111
|
readers
|
|
95
112
|
};
|
|
113
|
+
if (views.length > 0) {
|
|
114
|
+
providerOptions.views = views;
|
|
115
|
+
}
|
|
96
116
|
this.provider = new import_sdk_metrics.MeterProvider(providerOptions);
|
|
97
117
|
import_api.default.metrics.setGlobalMeterProvider(this.provider);
|
|
98
118
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/telemetry",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.44",
|
|
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": "2.0.0-alpha.
|
|
14
|
+
"@nocobase/utils": "2.0.0-alpha.44",
|
|
15
15
|
"@opentelemetry/api": "^1.9.0",
|
|
16
16
|
"@opentelemetry/instrumentation": "^0.207.0",
|
|
17
17
|
"@opentelemetry/resources": "^2.2.0",
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
"@opentelemetry/sdk-trace-node": "^2.2.0",
|
|
21
21
|
"@opentelemetry/semantic-conventions": "^1.37.0"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "075bd484c270740fe9b02f1989818da91139b6b9"
|
|
24
24
|
}
|