plutin 1.7.12 → 1.7.13
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 +27 -26
- 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 +27 -26
- 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_ENABLED2,
|
|
463
463
|
OtelManager: () => OtelManager,
|
|
464
464
|
RepositoryInstrumentation: () => RepositoryInstrumentation,
|
|
465
465
|
SpanManager: () => SpanManager,
|
|
@@ -1088,7 +1088,6 @@ var import_qs = __toESM(require("qs"), 1);
|
|
|
1088
1088
|
|
|
1089
1089
|
// src/infra/adapters/observability/otel/span-manager.ts
|
|
1090
1090
|
var import_api = require("@opentelemetry/api");
|
|
1091
|
-
var OTEL_ENABLED = process.env.OTEL_ENABLE === "true";
|
|
1092
1091
|
var NullSpan = class NullSpan2 {
|
|
1093
1092
|
static {
|
|
1094
1093
|
__name(this, "NullSpan");
|
|
@@ -1111,15 +1110,12 @@ var SpanManager = class SpanManager2 {
|
|
|
1111
1110
|
__name(this, "SpanManager");
|
|
1112
1111
|
}
|
|
1113
1112
|
static getActiveSpan() {
|
|
1114
|
-
if (!
|
|
1113
|
+
if (process.env.OTEL_ENABLE === "false" || !process.env.OTEL_ENABLE) {
|
|
1115
1114
|
return new NullSpan();
|
|
1116
1115
|
}
|
|
1117
1116
|
const span = import_api.trace.getActiveSpan();
|
|
1118
1117
|
return span || new NullSpan();
|
|
1119
1118
|
}
|
|
1120
|
-
static isEnabled() {
|
|
1121
|
-
return OTEL_ENABLED;
|
|
1122
|
-
}
|
|
1123
1119
|
};
|
|
1124
1120
|
|
|
1125
1121
|
// src/infra/adapters/http/validate-controller-metadata.ts
|
|
@@ -1702,12 +1698,17 @@ var import_api2 = require("@opentelemetry/api");
|
|
|
1702
1698
|
var import_node_os = require("os");
|
|
1703
1699
|
var import_node_perf_hooks = require("perf_hooks");
|
|
1704
1700
|
var import_node_v8 = __toESM(require("v8"), 1);
|
|
1705
|
-
var
|
|
1701
|
+
var OTEL_ENABLED = process.env.OTEL_ENABLE === "true";
|
|
1706
1702
|
var MetricsManager = class {
|
|
1707
1703
|
static {
|
|
1708
1704
|
__name(this, "MetricsManager");
|
|
1709
1705
|
}
|
|
1710
|
-
|
|
1706
|
+
constructor() {
|
|
1707
|
+
console.log("OTEL_ENABLE", process.env.OTEL_ENABLE);
|
|
1708
|
+
console.log("OTEL_SERVICE_NAME", process.env.OTEL_SERVICE_NAME);
|
|
1709
|
+
console.log("OTEL_SERVICE_VERSION", process.env.OTEL_SERVICE_VERSION);
|
|
1710
|
+
}
|
|
1711
|
+
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
1712
|
httpRequestsTotal = this.meter?.createCounter("http_requests_total", {
|
|
1712
1713
|
description: "Total de requisi\xE7\xF5es HTTP",
|
|
1713
1714
|
unit: "1"
|
|
@@ -1819,7 +1820,7 @@ var MetricsManager = class {
|
|
|
1819
1820
|
collectionInterval;
|
|
1820
1821
|
gcObserver;
|
|
1821
1822
|
recordHttpRequest(params) {
|
|
1822
|
-
if (!
|
|
1823
|
+
if (!OTEL_ENABLED) {
|
|
1823
1824
|
return;
|
|
1824
1825
|
}
|
|
1825
1826
|
const { method, route, statusCode, durationSeconds, responseSizeBytes } = params;
|
|
@@ -1843,7 +1844,7 @@ var MetricsManager = class {
|
|
|
1843
1844
|
}
|
|
1844
1845
|
}
|
|
1845
1846
|
recordDbQueryError(params) {
|
|
1846
|
-
if (!
|
|
1847
|
+
if (!OTEL_ENABLED) {
|
|
1847
1848
|
return;
|
|
1848
1849
|
}
|
|
1849
1850
|
if (!this.isValidDbQueryErrorParams(params)) {
|
|
@@ -1858,7 +1859,7 @@ var MetricsManager = class {
|
|
|
1858
1859
|
});
|
|
1859
1860
|
}
|
|
1860
1861
|
recordDbQuery(params) {
|
|
1861
|
-
if (!
|
|
1862
|
+
if (!OTEL_ENABLED) {
|
|
1862
1863
|
return;
|
|
1863
1864
|
}
|
|
1864
1865
|
if (!this.isValidDbQueryParams(params)) {
|
|
@@ -1892,7 +1893,7 @@ var MetricsManager = class {
|
|
|
1892
1893
|
return true;
|
|
1893
1894
|
}
|
|
1894
1895
|
recordDbTransaction(params) {
|
|
1895
|
-
if (!
|
|
1896
|
+
if (!OTEL_ENABLED) {
|
|
1896
1897
|
return;
|
|
1897
1898
|
}
|
|
1898
1899
|
const { operation, repository, durationSeconds } = params;
|
|
@@ -1908,7 +1909,7 @@ var MetricsManager = class {
|
|
|
1908
1909
|
});
|
|
1909
1910
|
}
|
|
1910
1911
|
recordDbDeadlock(params) {
|
|
1911
|
-
if (!
|
|
1912
|
+
if (!OTEL_ENABLED) {
|
|
1912
1913
|
return;
|
|
1913
1914
|
}
|
|
1914
1915
|
const { operation, repository, errorMessage } = params;
|
|
@@ -1920,7 +1921,7 @@ var MetricsManager = class {
|
|
|
1920
1921
|
});
|
|
1921
1922
|
}
|
|
1922
1923
|
recordHttpRequestBytes(bytes, attributes) {
|
|
1923
|
-
if (!
|
|
1924
|
+
if (!OTEL_ENABLED) {
|
|
1924
1925
|
return;
|
|
1925
1926
|
}
|
|
1926
1927
|
this.httpRequestBytesTotal?.add(bytes, {
|
|
@@ -1930,7 +1931,7 @@ var MetricsManager = class {
|
|
|
1930
1931
|
});
|
|
1931
1932
|
}
|
|
1932
1933
|
recordProcessingDuration(params) {
|
|
1933
|
-
if (!
|
|
1934
|
+
if (!OTEL_ENABLED) {
|
|
1934
1935
|
return;
|
|
1935
1936
|
}
|
|
1936
1937
|
const { operation, durationSeconds } = params;
|
|
@@ -1940,7 +1941,7 @@ var MetricsManager = class {
|
|
|
1940
1941
|
});
|
|
1941
1942
|
}
|
|
1942
1943
|
recordProcessingError(params) {
|
|
1943
|
-
if (!
|
|
1944
|
+
if (!OTEL_ENABLED) {
|
|
1944
1945
|
return;
|
|
1945
1946
|
}
|
|
1946
1947
|
const { operation, errorType } = params;
|
|
@@ -1951,7 +1952,7 @@ var MetricsManager = class {
|
|
|
1951
1952
|
});
|
|
1952
1953
|
}
|
|
1953
1954
|
recordHttpClientRequest(params) {
|
|
1954
|
-
if (!
|
|
1955
|
+
if (!OTEL_ENABLED) {
|
|
1955
1956
|
return;
|
|
1956
1957
|
}
|
|
1957
1958
|
const { method, url, statusCode, durationSeconds, error, timeout } = params;
|
|
@@ -1975,7 +1976,7 @@ var MetricsManager = class {
|
|
|
1975
1976
|
}
|
|
1976
1977
|
}
|
|
1977
1978
|
recordValidationError(params) {
|
|
1978
|
-
if (!
|
|
1979
|
+
if (!OTEL_ENABLED) {
|
|
1979
1980
|
return;
|
|
1980
1981
|
}
|
|
1981
1982
|
const { field, errorType } = params;
|
|
@@ -1986,7 +1987,7 @@ var MetricsManager = class {
|
|
|
1986
1987
|
});
|
|
1987
1988
|
}
|
|
1988
1989
|
startSystemMetricsCollection(intervalMs = 5e3) {
|
|
1989
|
-
if (!
|
|
1990
|
+
if (!OTEL_ENABLED || !this.meter) {
|
|
1990
1991
|
return;
|
|
1991
1992
|
}
|
|
1992
1993
|
this.eventLoopMonitor.enable();
|
|
@@ -2008,7 +2009,7 @@ var MetricsManager = class {
|
|
|
2008
2009
|
this.collectPeriodicMetrics();
|
|
2009
2010
|
}
|
|
2010
2011
|
stopSystemMetricsCollection() {
|
|
2011
|
-
if (!
|
|
2012
|
+
if (!OTEL_ENABLED || !this.meter) {
|
|
2012
2013
|
return;
|
|
2013
2014
|
}
|
|
2014
2015
|
if (this.collectionInterval) {
|
|
@@ -2022,7 +2023,7 @@ var MetricsManager = class {
|
|
|
2022
2023
|
}
|
|
2023
2024
|
}
|
|
2024
2025
|
collectSystemMetrics(observableResult) {
|
|
2025
|
-
if (!
|
|
2026
|
+
if (!OTEL_ENABLED) {
|
|
2026
2027
|
return;
|
|
2027
2028
|
}
|
|
2028
2029
|
const attributes = {
|
|
@@ -2063,7 +2064,7 @@ var MetricsManager = class {
|
|
|
2063
2064
|
observableResult.observe(this.processUptimeSeconds, process.uptime(), attributes);
|
|
2064
2065
|
}
|
|
2065
2066
|
collectPeriodicMetrics() {
|
|
2066
|
-
if (!
|
|
2067
|
+
if (!OTEL_ENABLED) {
|
|
2067
2068
|
return;
|
|
2068
2069
|
}
|
|
2069
2070
|
const attributes = {
|
|
@@ -2087,7 +2088,7 @@ var MetricsManager = class {
|
|
|
2087
2088
|
}
|
|
2088
2089
|
}
|
|
2089
2090
|
setupGCObserver() {
|
|
2090
|
-
if (!
|
|
2091
|
+
if (!OTEL_ENABLED) {
|
|
2091
2092
|
return;
|
|
2092
2093
|
}
|
|
2093
2094
|
try {
|
|
@@ -2286,7 +2287,7 @@ var EXCLUDED_METHODS = /* @__PURE__ */ new Set([
|
|
|
2286
2287
|
]);
|
|
2287
2288
|
var TRACER_NAME = process.env.OTEL_SERVICE_NAME || "plutin-boilerplate-common";
|
|
2288
2289
|
var TRACER_VERSION = process.env.OTEL_SERVICE_VERSION || "1.0.0";
|
|
2289
|
-
var
|
|
2290
|
+
var OTEL_ENABLED2 = process.env.OTEL_ENABLE === "true";
|
|
2290
2291
|
var Tracer = class Tracer2 {
|
|
2291
2292
|
static {
|
|
2292
2293
|
__name(this, "Tracer");
|
|
@@ -2725,7 +2726,7 @@ var ProcessingInstrumentationStrategyFactory = class ProcessingInstrumentationSt
|
|
|
2725
2726
|
__name(this, "ProcessingInstrumentationStrategyFactory");
|
|
2726
2727
|
}
|
|
2727
2728
|
static create(serviceName) {
|
|
2728
|
-
if (!
|
|
2729
|
+
if (!OTEL_ENABLED2) {
|
|
2729
2730
|
return new ProcessingLogsOnlyInstrumentationStrategy();
|
|
2730
2731
|
}
|
|
2731
2732
|
const tracer = Tracer.getTracer();
|
|
@@ -2900,7 +2901,7 @@ var RepositoryInstrumentationStrategyFactory = class RepositoryInstrumentationSt
|
|
|
2900
2901
|
__name(this, "RepositoryInstrumentationStrategyFactory");
|
|
2901
2902
|
}
|
|
2902
2903
|
static create(dbSystem) {
|
|
2903
|
-
if (!
|
|
2904
|
+
if (!OTEL_ENABLED2) {
|
|
2904
2905
|
return new RepositoryLogsOnlyInstrumentationStrategy();
|
|
2905
2906
|
}
|
|
2906
2907
|
const tracer = Tracer.getTracer();
|