plutin 1.7.16 → 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 +25 -22
- 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 +25 -22
- 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,15 +1698,18 @@ 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(`OTEL ENABLE - ${process.env.OTEL_ENABLE} - ${typeof process.env.OTEL_ENABLE}`);
|
|
1709
|
+
console.log(`OTEL_ENABLED - ${this.OTEL_ENABLED} - ${typeof process.env.OTEL_ENABLE}`);
|
|
1708
1710
|
try {
|
|
1709
|
-
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;
|
|
1712
|
+
console.log(`Meter - ${this.meter}`);
|
|
1710
1713
|
} catch (err) {
|
|
1711
1714
|
console.error("Error initializing metrics manager:", err);
|
|
1712
1715
|
}
|
|
@@ -1822,7 +1825,7 @@ var MetricsManager = class {
|
|
|
1822
1825
|
collectionInterval;
|
|
1823
1826
|
gcObserver;
|
|
1824
1827
|
recordHttpRequest(params) {
|
|
1825
|
-
if (!OTEL_ENABLED) {
|
|
1828
|
+
if (!this.OTEL_ENABLED) {
|
|
1826
1829
|
return;
|
|
1827
1830
|
}
|
|
1828
1831
|
const { method, route, statusCode, durationSeconds, responseSizeBytes } = params;
|
|
@@ -1846,7 +1849,7 @@ var MetricsManager = class {
|
|
|
1846
1849
|
}
|
|
1847
1850
|
}
|
|
1848
1851
|
recordDbQueryError(params) {
|
|
1849
|
-
if (!OTEL_ENABLED) {
|
|
1852
|
+
if (!this.OTEL_ENABLED) {
|
|
1850
1853
|
return;
|
|
1851
1854
|
}
|
|
1852
1855
|
if (!this.isValidDbQueryErrorParams(params)) {
|
|
@@ -1861,7 +1864,7 @@ var MetricsManager = class {
|
|
|
1861
1864
|
});
|
|
1862
1865
|
}
|
|
1863
1866
|
recordDbQuery(params) {
|
|
1864
|
-
if (!OTEL_ENABLED) {
|
|
1867
|
+
if (!this.OTEL_ENABLED) {
|
|
1865
1868
|
return;
|
|
1866
1869
|
}
|
|
1867
1870
|
if (!this.isValidDbQueryParams(params)) {
|
|
@@ -1895,7 +1898,7 @@ var MetricsManager = class {
|
|
|
1895
1898
|
return true;
|
|
1896
1899
|
}
|
|
1897
1900
|
recordDbTransaction(params) {
|
|
1898
|
-
if (!OTEL_ENABLED) {
|
|
1901
|
+
if (!this.OTEL_ENABLED) {
|
|
1899
1902
|
return;
|
|
1900
1903
|
}
|
|
1901
1904
|
const { operation, repository, durationSeconds } = params;
|
|
@@ -1911,7 +1914,7 @@ var MetricsManager = class {
|
|
|
1911
1914
|
});
|
|
1912
1915
|
}
|
|
1913
1916
|
recordDbDeadlock(params) {
|
|
1914
|
-
if (!OTEL_ENABLED) {
|
|
1917
|
+
if (!this.OTEL_ENABLED) {
|
|
1915
1918
|
return;
|
|
1916
1919
|
}
|
|
1917
1920
|
const { operation, repository, errorMessage } = params;
|
|
@@ -1923,7 +1926,7 @@ var MetricsManager = class {
|
|
|
1923
1926
|
});
|
|
1924
1927
|
}
|
|
1925
1928
|
recordHttpRequestBytes(bytes, attributes) {
|
|
1926
|
-
if (!OTEL_ENABLED) {
|
|
1929
|
+
if (!this.OTEL_ENABLED) {
|
|
1927
1930
|
return;
|
|
1928
1931
|
}
|
|
1929
1932
|
this.httpRequestBytesTotal?.add(bytes, {
|
|
@@ -1933,7 +1936,7 @@ var MetricsManager = class {
|
|
|
1933
1936
|
});
|
|
1934
1937
|
}
|
|
1935
1938
|
recordProcessingDuration(params) {
|
|
1936
|
-
if (!OTEL_ENABLED) {
|
|
1939
|
+
if (!this.OTEL_ENABLED) {
|
|
1937
1940
|
return;
|
|
1938
1941
|
}
|
|
1939
1942
|
const { operation, durationSeconds } = params;
|
|
@@ -1943,7 +1946,7 @@ var MetricsManager = class {
|
|
|
1943
1946
|
});
|
|
1944
1947
|
}
|
|
1945
1948
|
recordProcessingError(params) {
|
|
1946
|
-
if (!OTEL_ENABLED) {
|
|
1949
|
+
if (!this.OTEL_ENABLED) {
|
|
1947
1950
|
return;
|
|
1948
1951
|
}
|
|
1949
1952
|
const { operation, errorType } = params;
|
|
@@ -1954,7 +1957,7 @@ var MetricsManager = class {
|
|
|
1954
1957
|
});
|
|
1955
1958
|
}
|
|
1956
1959
|
recordHttpClientRequest(params) {
|
|
1957
|
-
if (!OTEL_ENABLED) {
|
|
1960
|
+
if (!this.OTEL_ENABLED) {
|
|
1958
1961
|
return;
|
|
1959
1962
|
}
|
|
1960
1963
|
const { method, url, statusCode, durationSeconds, error, timeout } = params;
|
|
@@ -1978,7 +1981,7 @@ var MetricsManager = class {
|
|
|
1978
1981
|
}
|
|
1979
1982
|
}
|
|
1980
1983
|
recordValidationError(params) {
|
|
1981
|
-
if (!OTEL_ENABLED) {
|
|
1984
|
+
if (!this.OTEL_ENABLED) {
|
|
1982
1985
|
return;
|
|
1983
1986
|
}
|
|
1984
1987
|
const { field, errorType } = params;
|
|
@@ -1989,8 +1992,8 @@ var MetricsManager = class {
|
|
|
1989
1992
|
});
|
|
1990
1993
|
}
|
|
1991
1994
|
startSystemMetricsCollection(intervalMs = 5e3) {
|
|
1992
|
-
console.log(`OTEL_ENABLED - ${!OTEL_ENABLED} - ${this.meter}`);
|
|
1993
|
-
if (!OTEL_ENABLED || !this.meter) {
|
|
1995
|
+
console.log(`this.OTEL_ENABLED - ${!this.OTEL_ENABLED} - ${this.meter}`);
|
|
1996
|
+
if (!this.OTEL_ENABLED || !this.meter) {
|
|
1994
1997
|
return;
|
|
1995
1998
|
}
|
|
1996
1999
|
this.eventLoopMonitor.enable();
|
|
@@ -2012,7 +2015,7 @@ var MetricsManager = class {
|
|
|
2012
2015
|
this.collectPeriodicMetrics();
|
|
2013
2016
|
}
|
|
2014
2017
|
stopSystemMetricsCollection() {
|
|
2015
|
-
if (!OTEL_ENABLED || !this.meter) {
|
|
2018
|
+
if (!this.OTEL_ENABLED || !this.meter) {
|
|
2016
2019
|
return;
|
|
2017
2020
|
}
|
|
2018
2021
|
if (this.collectionInterval) {
|
|
@@ -2026,7 +2029,7 @@ var MetricsManager = class {
|
|
|
2026
2029
|
}
|
|
2027
2030
|
}
|
|
2028
2031
|
collectSystemMetrics(observableResult) {
|
|
2029
|
-
if (!OTEL_ENABLED) {
|
|
2032
|
+
if (!this.OTEL_ENABLED) {
|
|
2030
2033
|
return;
|
|
2031
2034
|
}
|
|
2032
2035
|
const attributes = {
|
|
@@ -2067,7 +2070,7 @@ var MetricsManager = class {
|
|
|
2067
2070
|
observableResult.observe(this.processUptimeSeconds, process.uptime(), attributes);
|
|
2068
2071
|
}
|
|
2069
2072
|
collectPeriodicMetrics() {
|
|
2070
|
-
if (!OTEL_ENABLED) {
|
|
2073
|
+
if (!this.OTEL_ENABLED) {
|
|
2071
2074
|
return;
|
|
2072
2075
|
}
|
|
2073
2076
|
const attributes = {
|
|
@@ -2091,7 +2094,7 @@ var MetricsManager = class {
|
|
|
2091
2094
|
}
|
|
2092
2095
|
}
|
|
2093
2096
|
setupGCObserver() {
|
|
2094
|
-
if (!OTEL_ENABLED) {
|
|
2097
|
+
if (!this.OTEL_ENABLED) {
|
|
2095
2098
|
return;
|
|
2096
2099
|
}
|
|
2097
2100
|
try {
|
|
@@ -2290,7 +2293,7 @@ var EXCLUDED_METHODS = /* @__PURE__ */ new Set([
|
|
|
2290
2293
|
]);
|
|
2291
2294
|
var TRACER_NAME = process.env.OTEL_SERVICE_NAME || "plutin-boilerplate-common";
|
|
2292
2295
|
var TRACER_VERSION = process.env.OTEL_SERVICE_VERSION || "1.0.0";
|
|
2293
|
-
var
|
|
2296
|
+
var OTEL_ENABLED = process.env.OTEL_ENABLE === "true";
|
|
2294
2297
|
var Tracer = class Tracer2 {
|
|
2295
2298
|
static {
|
|
2296
2299
|
__name(this, "Tracer");
|
|
@@ -2729,7 +2732,7 @@ var ProcessingInstrumentationStrategyFactory = class ProcessingInstrumentationSt
|
|
|
2729
2732
|
__name(this, "ProcessingInstrumentationStrategyFactory");
|
|
2730
2733
|
}
|
|
2731
2734
|
static create(serviceName) {
|
|
2732
|
-
if (!
|
|
2735
|
+
if (!OTEL_ENABLED) {
|
|
2733
2736
|
return new ProcessingLogsOnlyInstrumentationStrategy();
|
|
2734
2737
|
}
|
|
2735
2738
|
const tracer = Tracer.getTracer();
|
|
@@ -2904,7 +2907,7 @@ var RepositoryInstrumentationStrategyFactory = class RepositoryInstrumentationSt
|
|
|
2904
2907
|
__name(this, "RepositoryInstrumentationStrategyFactory");
|
|
2905
2908
|
}
|
|
2906
2909
|
static create(dbSystem) {
|
|
2907
|
-
if (!
|
|
2910
|
+
if (!OTEL_ENABLED) {
|
|
2908
2911
|
return new RepositoryLogsOnlyInstrumentationStrategy();
|
|
2909
2912
|
}
|
|
2910
2913
|
const tracer = Tracer.getTracer();
|