plutin 1.8.6 → 1.8.8
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 +22 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +22 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -143,6 +143,7 @@ type Registration = {
|
|
|
143
143
|
declare class DependencyContainer {
|
|
144
144
|
static registry: Map<string, Registration>;
|
|
145
145
|
static singletons: Map<string, any>;
|
|
146
|
+
static reset(): void;
|
|
146
147
|
static register<T>(token: string, myClass: Class<T>, options: {
|
|
147
148
|
singleton: boolean;
|
|
148
149
|
}): void;
|
|
@@ -339,7 +340,6 @@ interface IMetricsManager {
|
|
|
339
340
|
}
|
|
340
341
|
declare class MetricsManager implements IMetricsManager {
|
|
341
342
|
private meter;
|
|
342
|
-
constructor();
|
|
343
343
|
private httpRequestsTotal;
|
|
344
344
|
private httpRequestDuration;
|
|
345
345
|
private httpRequestsErrors;
|
package/dist/index.d.ts
CHANGED
|
@@ -143,6 +143,7 @@ type Registration = {
|
|
|
143
143
|
declare class DependencyContainer {
|
|
144
144
|
static registry: Map<string, Registration>;
|
|
145
145
|
static singletons: Map<string, any>;
|
|
146
|
+
static reset(): void;
|
|
146
147
|
static register<T>(token: string, myClass: Class<T>, options: {
|
|
147
148
|
singleton: boolean;
|
|
148
149
|
}): void;
|
|
@@ -339,7 +340,6 @@ interface IMetricsManager {
|
|
|
339
340
|
}
|
|
340
341
|
declare class MetricsManager implements IMetricsManager {
|
|
341
342
|
private meter;
|
|
342
|
-
constructor();
|
|
343
343
|
private httpRequestsTotal;
|
|
344
344
|
private httpRequestDuration;
|
|
345
345
|
private httpRequestsErrors;
|
package/dist/index.mjs
CHANGED
|
@@ -428,6 +428,10 @@ var DependencyContainer = class {
|
|
|
428
428
|
}
|
|
429
429
|
static registry = /* @__PURE__ */ new Map();
|
|
430
430
|
static singletons = /* @__PURE__ */ new Map();
|
|
431
|
+
static reset() {
|
|
432
|
+
this.registry.clear();
|
|
433
|
+
this.singletons.clear();
|
|
434
|
+
}
|
|
431
435
|
static register(token, myClass, options) {
|
|
432
436
|
this.registry.set(token, {
|
|
433
437
|
type: "class",
|
|
@@ -443,7 +447,8 @@ var DependencyContainer = class {
|
|
|
443
447
|
}
|
|
444
448
|
static resolve(target) {
|
|
445
449
|
const injectMetadata = Reflect.getOwnMetadata("inject:params", target) || {};
|
|
446
|
-
const
|
|
450
|
+
const designParamTypes = Reflect.getMetadata("design:paramtypes", target) || [];
|
|
451
|
+
const paramCount = Math.max(designParamTypes.length, Object.keys(injectMetadata).length);
|
|
447
452
|
const params = Array.from({
|
|
448
453
|
length: paramCount
|
|
449
454
|
}, (_, index) => {
|
|
@@ -1604,10 +1609,7 @@ var MetricsManager = class {
|
|
|
1604
1609
|
static {
|
|
1605
1610
|
__name(this, "MetricsManager");
|
|
1606
1611
|
}
|
|
1607
|
-
meter = null;
|
|
1608
|
-
constructor() {
|
|
1609
|
-
this.meter = process.env.OTEL_ENABLE === "true" ? metrics.getMeter(process.env.OTEL_SERVICE_NAME || "plutin-boilerplate-common", process.env.OTEL_SERVICE_VERSION || "1.0.0") : null;
|
|
1610
|
-
}
|
|
1612
|
+
meter = process.env.OTEL_ENABLE === "true" ? metrics.getMeter(process.env.OTEL_SERVICE_NAME || "plutin-boilerplate-common", process.env.OTEL_SERVICE_VERSION || "1.0.0") : null;
|
|
1611
1613
|
httpRequestsTotal = this.meter?.createCounter("http_requests_total", {
|
|
1612
1614
|
description: "Total de requisi\xE7\xF5es HTTP",
|
|
1613
1615
|
unit: "1"
|
|
@@ -1719,7 +1721,7 @@ var MetricsManager = class {
|
|
|
1719
1721
|
collectionInterval;
|
|
1720
1722
|
gcObserver;
|
|
1721
1723
|
recordHttpRequest(params) {
|
|
1722
|
-
if (
|
|
1724
|
+
if (!this.meter) {
|
|
1723
1725
|
return;
|
|
1724
1726
|
}
|
|
1725
1727
|
const { method, route, statusCode, durationSeconds, responseSizeBytes } = params;
|
|
@@ -1743,7 +1745,7 @@ var MetricsManager = class {
|
|
|
1743
1745
|
}
|
|
1744
1746
|
}
|
|
1745
1747
|
recordDbQueryError(params) {
|
|
1746
|
-
if (
|
|
1748
|
+
if (!this.meter) {
|
|
1747
1749
|
return;
|
|
1748
1750
|
}
|
|
1749
1751
|
if (!this.isValidDbQueryErrorParams(params)) {
|
|
@@ -1758,7 +1760,7 @@ var MetricsManager = class {
|
|
|
1758
1760
|
});
|
|
1759
1761
|
}
|
|
1760
1762
|
recordDbQuery(params) {
|
|
1761
|
-
if (
|
|
1763
|
+
if (!this.meter) {
|
|
1762
1764
|
return;
|
|
1763
1765
|
}
|
|
1764
1766
|
if (!this.isValidDbQueryParams(params)) {
|
|
@@ -1792,7 +1794,7 @@ var MetricsManager = class {
|
|
|
1792
1794
|
return true;
|
|
1793
1795
|
}
|
|
1794
1796
|
recordDbTransaction(params) {
|
|
1795
|
-
if (
|
|
1797
|
+
if (!this.meter) {
|
|
1796
1798
|
return;
|
|
1797
1799
|
}
|
|
1798
1800
|
const { operation, repository, durationSeconds } = params;
|
|
@@ -1808,7 +1810,7 @@ var MetricsManager = class {
|
|
|
1808
1810
|
});
|
|
1809
1811
|
}
|
|
1810
1812
|
recordDbDeadlock(params) {
|
|
1811
|
-
if (
|
|
1813
|
+
if (!this.meter) {
|
|
1812
1814
|
return;
|
|
1813
1815
|
}
|
|
1814
1816
|
const { operation, repository, errorMessage } = params;
|
|
@@ -1820,7 +1822,7 @@ var MetricsManager = class {
|
|
|
1820
1822
|
});
|
|
1821
1823
|
}
|
|
1822
1824
|
recordHttpRequestBytes(bytes, attributes) {
|
|
1823
|
-
if (
|
|
1825
|
+
if (!this.meter) {
|
|
1824
1826
|
return;
|
|
1825
1827
|
}
|
|
1826
1828
|
this.httpRequestBytesTotal?.add(bytes, {
|
|
@@ -1830,7 +1832,7 @@ var MetricsManager = class {
|
|
|
1830
1832
|
});
|
|
1831
1833
|
}
|
|
1832
1834
|
recordProcessingDuration(params) {
|
|
1833
|
-
if (
|
|
1835
|
+
if (!this.meter) {
|
|
1834
1836
|
return;
|
|
1835
1837
|
}
|
|
1836
1838
|
const { operation, durationSeconds } = params;
|
|
@@ -1840,7 +1842,7 @@ var MetricsManager = class {
|
|
|
1840
1842
|
});
|
|
1841
1843
|
}
|
|
1842
1844
|
recordProcessingError(params) {
|
|
1843
|
-
if (
|
|
1845
|
+
if (!this.meter) {
|
|
1844
1846
|
return;
|
|
1845
1847
|
}
|
|
1846
1848
|
const { operation, errorType } = params;
|
|
@@ -1851,7 +1853,7 @@ var MetricsManager = class {
|
|
|
1851
1853
|
});
|
|
1852
1854
|
}
|
|
1853
1855
|
recordHttpClientRequest(params) {
|
|
1854
|
-
if (
|
|
1856
|
+
if (!this.meter) {
|
|
1855
1857
|
return;
|
|
1856
1858
|
}
|
|
1857
1859
|
const { method, url, statusCode, durationSeconds, error, timeout } = params;
|
|
@@ -1875,7 +1877,7 @@ var MetricsManager = class {
|
|
|
1875
1877
|
}
|
|
1876
1878
|
}
|
|
1877
1879
|
recordValidationError(params) {
|
|
1878
|
-
if (
|
|
1880
|
+
if (!this.meter) {
|
|
1879
1881
|
return;
|
|
1880
1882
|
}
|
|
1881
1883
|
const { field, errorType } = params;
|
|
@@ -1886,7 +1888,7 @@ var MetricsManager = class {
|
|
|
1886
1888
|
});
|
|
1887
1889
|
}
|
|
1888
1890
|
startSystemMetricsCollection(intervalMs = 5e3) {
|
|
1889
|
-
if (
|
|
1891
|
+
if (!this.meter) {
|
|
1890
1892
|
return;
|
|
1891
1893
|
}
|
|
1892
1894
|
this.eventLoopMonitor.enable();
|
|
@@ -1908,7 +1910,7 @@ var MetricsManager = class {
|
|
|
1908
1910
|
this.collectPeriodicMetrics();
|
|
1909
1911
|
}
|
|
1910
1912
|
stopSystemMetricsCollection() {
|
|
1911
|
-
if (
|
|
1913
|
+
if (!this.meter) {
|
|
1912
1914
|
return;
|
|
1913
1915
|
}
|
|
1914
1916
|
if (this.collectionInterval) {
|
|
@@ -1922,7 +1924,7 @@ var MetricsManager = class {
|
|
|
1922
1924
|
}
|
|
1923
1925
|
}
|
|
1924
1926
|
collectSystemMetrics(observableResult) {
|
|
1925
|
-
if (
|
|
1927
|
+
if (!this.meter) {
|
|
1926
1928
|
return;
|
|
1927
1929
|
}
|
|
1928
1930
|
const attributes = {
|
|
@@ -1963,7 +1965,7 @@ var MetricsManager = class {
|
|
|
1963
1965
|
observableResult.observe(this.processUptimeSeconds, process.uptime(), attributes);
|
|
1964
1966
|
}
|
|
1965
1967
|
collectPeriodicMetrics() {
|
|
1966
|
-
if (
|
|
1968
|
+
if (!this.meter) {
|
|
1967
1969
|
return;
|
|
1968
1970
|
}
|
|
1969
1971
|
const attributes = {
|
|
@@ -1987,7 +1989,7 @@ var MetricsManager = class {
|
|
|
1987
1989
|
}
|
|
1988
1990
|
}
|
|
1989
1991
|
setupGCObserver() {
|
|
1990
|
-
if (
|
|
1992
|
+
if (!this.meter) {
|
|
1991
1993
|
return;
|
|
1992
1994
|
}
|
|
1993
1995
|
try {
|