plutin 1.7.17 → 1.7.18
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/index.cjs +24 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +24 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -459,7 +459,7 @@ __export(src_exports, {
|
|
|
459
459
|
Metrics: () => Metrics,
|
|
460
460
|
MetricsManager: () => MetricsManager,
|
|
461
461
|
NullSpan: () => NullSpan,
|
|
462
|
-
OTEL_ENABLED: () =>
|
|
462
|
+
OTEL_ENABLED: () => OTEL_ENABLED,
|
|
463
463
|
OtelManager: () => OtelManager,
|
|
464
464
|
RepositoryInstrumentation: () => RepositoryInstrumentation,
|
|
465
465
|
SpanManager: () => SpanManager,
|
|
@@ -1698,16 +1698,17 @@ var import_api2 = require("@opentelemetry/api");
|
|
|
1698
1698
|
var import_node_os = require("os");
|
|
1699
1699
|
var import_node_perf_hooks = require("perf_hooks");
|
|
1700
1700
|
var import_node_v8 = __toESM(require("v8"), 1);
|
|
1701
|
-
var OTEL_ENABLED = process.env.OTEL_ENABLE === "true";
|
|
1702
1701
|
var MetricsManager = class {
|
|
1703
1702
|
static {
|
|
1704
1703
|
__name(this, "MetricsManager");
|
|
1705
1704
|
}
|
|
1705
|
+
OTEL_ENABLED = process.env.OTEL_ENABLE === "true";
|
|
1706
1706
|
meter = null;
|
|
1707
1707
|
constructor() {
|
|
1708
|
-
console.log(`
|
|
1708
|
+
console.log(`OTEL ENABLE - ${process.env.OTEL_ENABLE} - ${typeof process.env.OTEL_ENABLE}`);
|
|
1709
|
+
console.log(`OTEL_ENABLED - ${this.OTEL_ENABLED} - ${typeof process.env.OTEL_ENABLE}`);
|
|
1709
1710
|
try {
|
|
1710
|
-
this.meter = OTEL_ENABLED ? import_api2.metrics.getMeter(process.env.OTEL_SERVICE_NAME || "plutin-boilerplate-common", process.env.OTEL_SERVICE_VERSION || "1.0.0") : null;
|
|
1711
|
+
this.meter = this.OTEL_ENABLED ? import_api2.metrics.getMeter(process.env.OTEL_SERVICE_NAME || "plutin-boilerplate-common", process.env.OTEL_SERVICE_VERSION || "1.0.0") : null;
|
|
1711
1712
|
console.log(`Meter - ${this.meter}`);
|
|
1712
1713
|
} catch (err) {
|
|
1713
1714
|
console.error("Error initializing metrics manager:", err);
|
|
@@ -1824,7 +1825,7 @@ var MetricsManager = class {
|
|
|
1824
1825
|
collectionInterval;
|
|
1825
1826
|
gcObserver;
|
|
1826
1827
|
recordHttpRequest(params) {
|
|
1827
|
-
if (!OTEL_ENABLED) {
|
|
1828
|
+
if (!this.OTEL_ENABLED) {
|
|
1828
1829
|
return;
|
|
1829
1830
|
}
|
|
1830
1831
|
const { method, route, statusCode, durationSeconds, responseSizeBytes } = params;
|
|
@@ -1848,7 +1849,7 @@ var MetricsManager = class {
|
|
|
1848
1849
|
}
|
|
1849
1850
|
}
|
|
1850
1851
|
recordDbQueryError(params) {
|
|
1851
|
-
if (!OTEL_ENABLED) {
|
|
1852
|
+
if (!this.OTEL_ENABLED) {
|
|
1852
1853
|
return;
|
|
1853
1854
|
}
|
|
1854
1855
|
if (!this.isValidDbQueryErrorParams(params)) {
|
|
@@ -1863,7 +1864,7 @@ var MetricsManager = class {
|
|
|
1863
1864
|
});
|
|
1864
1865
|
}
|
|
1865
1866
|
recordDbQuery(params) {
|
|
1866
|
-
if (!OTEL_ENABLED) {
|
|
1867
|
+
if (!this.OTEL_ENABLED) {
|
|
1867
1868
|
return;
|
|
1868
1869
|
}
|
|
1869
1870
|
if (!this.isValidDbQueryParams(params)) {
|
|
@@ -1897,7 +1898,7 @@ var MetricsManager = class {
|
|
|
1897
1898
|
return true;
|
|
1898
1899
|
}
|
|
1899
1900
|
recordDbTransaction(params) {
|
|
1900
|
-
if (!OTEL_ENABLED) {
|
|
1901
|
+
if (!this.OTEL_ENABLED) {
|
|
1901
1902
|
return;
|
|
1902
1903
|
}
|
|
1903
1904
|
const { operation, repository, durationSeconds } = params;
|
|
@@ -1913,7 +1914,7 @@ var MetricsManager = class {
|
|
|
1913
1914
|
});
|
|
1914
1915
|
}
|
|
1915
1916
|
recordDbDeadlock(params) {
|
|
1916
|
-
if (!OTEL_ENABLED) {
|
|
1917
|
+
if (!this.OTEL_ENABLED) {
|
|
1917
1918
|
return;
|
|
1918
1919
|
}
|
|
1919
1920
|
const { operation, repository, errorMessage } = params;
|
|
@@ -1925,7 +1926,7 @@ var MetricsManager = class {
|
|
|
1925
1926
|
});
|
|
1926
1927
|
}
|
|
1927
1928
|
recordHttpRequestBytes(bytes, attributes) {
|
|
1928
|
-
if (!OTEL_ENABLED) {
|
|
1929
|
+
if (!this.OTEL_ENABLED) {
|
|
1929
1930
|
return;
|
|
1930
1931
|
}
|
|
1931
1932
|
this.httpRequestBytesTotal?.add(bytes, {
|
|
@@ -1935,7 +1936,7 @@ var MetricsManager = class {
|
|
|
1935
1936
|
});
|
|
1936
1937
|
}
|
|
1937
1938
|
recordProcessingDuration(params) {
|
|
1938
|
-
if (!OTEL_ENABLED) {
|
|
1939
|
+
if (!this.OTEL_ENABLED) {
|
|
1939
1940
|
return;
|
|
1940
1941
|
}
|
|
1941
1942
|
const { operation, durationSeconds } = params;
|
|
@@ -1945,7 +1946,7 @@ var MetricsManager = class {
|
|
|
1945
1946
|
});
|
|
1946
1947
|
}
|
|
1947
1948
|
recordProcessingError(params) {
|
|
1948
|
-
if (!OTEL_ENABLED) {
|
|
1949
|
+
if (!this.OTEL_ENABLED) {
|
|
1949
1950
|
return;
|
|
1950
1951
|
}
|
|
1951
1952
|
const { operation, errorType } = params;
|
|
@@ -1956,7 +1957,7 @@ var MetricsManager = class {
|
|
|
1956
1957
|
});
|
|
1957
1958
|
}
|
|
1958
1959
|
recordHttpClientRequest(params) {
|
|
1959
|
-
if (!OTEL_ENABLED) {
|
|
1960
|
+
if (!this.OTEL_ENABLED) {
|
|
1960
1961
|
return;
|
|
1961
1962
|
}
|
|
1962
1963
|
const { method, url, statusCode, durationSeconds, error, timeout } = params;
|
|
@@ -1980,7 +1981,7 @@ var MetricsManager = class {
|
|
|
1980
1981
|
}
|
|
1981
1982
|
}
|
|
1982
1983
|
recordValidationError(params) {
|
|
1983
|
-
if (!OTEL_ENABLED) {
|
|
1984
|
+
if (!this.OTEL_ENABLED) {
|
|
1984
1985
|
return;
|
|
1985
1986
|
}
|
|
1986
1987
|
const { field, errorType } = params;
|
|
@@ -1991,8 +1992,8 @@ var MetricsManager = class {
|
|
|
1991
1992
|
});
|
|
1992
1993
|
}
|
|
1993
1994
|
startSystemMetricsCollection(intervalMs = 5e3) {
|
|
1994
|
-
console.log(`OTEL_ENABLED - ${!OTEL_ENABLED} - ${this.meter}`);
|
|
1995
|
-
if (!OTEL_ENABLED || !this.meter) {
|
|
1995
|
+
console.log(`this.OTEL_ENABLED - ${!this.OTEL_ENABLED} - ${this.meter}`);
|
|
1996
|
+
if (!this.OTEL_ENABLED || !this.meter) {
|
|
1996
1997
|
return;
|
|
1997
1998
|
}
|
|
1998
1999
|
this.eventLoopMonitor.enable();
|
|
@@ -2014,7 +2015,7 @@ var MetricsManager = class {
|
|
|
2014
2015
|
this.collectPeriodicMetrics();
|
|
2015
2016
|
}
|
|
2016
2017
|
stopSystemMetricsCollection() {
|
|
2017
|
-
if (!OTEL_ENABLED || !this.meter) {
|
|
2018
|
+
if (!this.OTEL_ENABLED || !this.meter) {
|
|
2018
2019
|
return;
|
|
2019
2020
|
}
|
|
2020
2021
|
if (this.collectionInterval) {
|
|
@@ -2028,7 +2029,7 @@ var MetricsManager = class {
|
|
|
2028
2029
|
}
|
|
2029
2030
|
}
|
|
2030
2031
|
collectSystemMetrics(observableResult) {
|
|
2031
|
-
if (!OTEL_ENABLED) {
|
|
2032
|
+
if (!this.OTEL_ENABLED) {
|
|
2032
2033
|
return;
|
|
2033
2034
|
}
|
|
2034
2035
|
const attributes = {
|
|
@@ -2069,7 +2070,7 @@ var MetricsManager = class {
|
|
|
2069
2070
|
observableResult.observe(this.processUptimeSeconds, process.uptime(), attributes);
|
|
2070
2071
|
}
|
|
2071
2072
|
collectPeriodicMetrics() {
|
|
2072
|
-
if (!OTEL_ENABLED) {
|
|
2073
|
+
if (!this.OTEL_ENABLED) {
|
|
2073
2074
|
return;
|
|
2074
2075
|
}
|
|
2075
2076
|
const attributes = {
|
|
@@ -2093,7 +2094,7 @@ var MetricsManager = class {
|
|
|
2093
2094
|
}
|
|
2094
2095
|
}
|
|
2095
2096
|
setupGCObserver() {
|
|
2096
|
-
if (!OTEL_ENABLED) {
|
|
2097
|
+
if (!this.OTEL_ENABLED) {
|
|
2097
2098
|
return;
|
|
2098
2099
|
}
|
|
2099
2100
|
try {
|
|
@@ -2292,7 +2293,7 @@ var EXCLUDED_METHODS = /* @__PURE__ */ new Set([
|
|
|
2292
2293
|
]);
|
|
2293
2294
|
var TRACER_NAME = process.env.OTEL_SERVICE_NAME || "plutin-boilerplate-common";
|
|
2294
2295
|
var TRACER_VERSION = process.env.OTEL_SERVICE_VERSION || "1.0.0";
|
|
2295
|
-
var
|
|
2296
|
+
var OTEL_ENABLED = process.env.OTEL_ENABLE === "true";
|
|
2296
2297
|
var Tracer = class Tracer2 {
|
|
2297
2298
|
static {
|
|
2298
2299
|
__name(this, "Tracer");
|
|
@@ -2731,7 +2732,7 @@ var ProcessingInstrumentationStrategyFactory = class ProcessingInstrumentationSt
|
|
|
2731
2732
|
__name(this, "ProcessingInstrumentationStrategyFactory");
|
|
2732
2733
|
}
|
|
2733
2734
|
static create(serviceName) {
|
|
2734
|
-
if (!
|
|
2735
|
+
if (!OTEL_ENABLED) {
|
|
2735
2736
|
return new ProcessingLogsOnlyInstrumentationStrategy();
|
|
2736
2737
|
}
|
|
2737
2738
|
const tracer = Tracer.getTracer();
|
|
@@ -2906,7 +2907,7 @@ var RepositoryInstrumentationStrategyFactory = class RepositoryInstrumentationSt
|
|
|
2906
2907
|
__name(this, "RepositoryInstrumentationStrategyFactory");
|
|
2907
2908
|
}
|
|
2908
2909
|
static create(dbSystem) {
|
|
2909
|
-
if (!
|
|
2910
|
+
if (!OTEL_ENABLED) {
|
|
2910
2911
|
return new RepositoryLogsOnlyInstrumentationStrategy();
|
|
2911
2912
|
}
|
|
2912
2913
|
const tracer = Tracer.getTracer();
|