@rsdk/core 5.11.1-next.0 → 5.11.1-next.2
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/config/parsers/index.d.ts +1 -0
- package/dist/config/parsers/index.js +1 -0
- package/dist/config/parsers/index.js.map +1 -1
- package/dist/config/parsers/string-record/exception.d.ts +4 -0
- package/dist/config/parsers/string-record/exception.js +14 -0
- package/dist/config/parsers/string-record/exception.js.map +1 -0
- package/dist/config/parsers/string-record/index.d.ts +2 -0
- package/dist/config/parsers/string-record/index.js +21 -0
- package/dist/config/parsers/string-record/index.js.map +1 -0
- package/dist/config/parsers/string-record/string-record.parser.d.ts +8 -0
- package/dist/config/parsers/string-record/string-record.parser.js +42 -0
- package/dist/config/parsers/string-record/string-record.parser.js.map +1 -0
- package/dist/logging/logger-initializing.module.d.ts +22 -1
- package/dist/logging/logger-initializing.module.js +103 -11
- package/dist/logging/logger-initializing.module.js.map +1 -1
- package/dist/logging/logging.config.d.ts +24 -1
- package/dist/logging/logging.config.js +132 -3
- package/dist/logging/logging.config.js.map +1 -1
- package/dist/logging/otel-time.transform.d.ts +9 -0
- package/dist/logging/otel-time.transform.js +35 -0
- package/dist/logging/otel-time.transform.js.map +1 -0
- package/package.json +7 -2
- package/src/config/parsers/index.ts +1 -0
- package/src/config/parsers/string-record/exception.ts +10 -0
- package/src/config/parsers/string-record/index.ts +2 -0
- package/src/config/parsers/string-record/string-record.parser.ts +55 -0
- package/src/config/parsers/string-record/string-record.spec.ts +33 -0
- package/src/logging/logger-factory.lifecycle.spec.ts +91 -0
- package/src/logging/logger-initializing.module.spec.ts +263 -0
- package/src/logging/logger-initializing.module.ts +128 -17
- package/src/logging/logging.config.ts +113 -3
- package/src/logging/otel-time.transform.spec.ts +59 -0
- package/src/logging/otel-time.transform.ts +40 -0
|
@@ -21,6 +21,7 @@ __exportStar(require("./number"), exports);
|
|
|
21
21
|
__exportStar(require("./path"), exports);
|
|
22
22
|
__exportStar(require("./size"), exports);
|
|
23
23
|
__exportStar(require("./string"), exports);
|
|
24
|
+
__exportStar(require("./string-record"), exports);
|
|
24
25
|
__exportStar(require("./timespan"), exports);
|
|
25
26
|
__exportStar(require("./url"), exports);
|
|
26
27
|
__exportStar(require("./array/"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/parsers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,yCAAuB;AACvB,wCAAsB;AACtB,2CAAyB;AACzB,yCAAuB;AACvB,yCAAuB;AACvB,2CAAyB;AACzB,6CAA2B;AAC3B,wCAAsB;AACtB,2CAAyB;AACzB,0CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/parsers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,yCAAuB;AACvB,wCAAsB;AACtB,2CAAyB;AACzB,yCAAuB;AACvB,yCAAuB;AACvB,2CAAyB;AACzB,kDAAgC;AAChC,6CAA2B;AAC3B,wCAAsB;AACtB,2CAAyB;AACzB,0CAAwB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidStringRecord = void 0;
|
|
4
|
+
const exceptions_1 = require("../../../exceptions");
|
|
5
|
+
class InvalidStringRecord extends exceptions_1.BootstrapException {
|
|
6
|
+
constructor(reason, value, cause) {
|
|
7
|
+
super(`Invalid string record: ${reason}`, {
|
|
8
|
+
cause,
|
|
9
|
+
details: { value },
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.InvalidStringRecord = InvalidStringRecord;
|
|
14
|
+
//# sourceMappingURL=exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exception.js","sourceRoot":"","sources":["../../../../src/config/parsers/string-record/exception.ts"],"names":[],"mappings":";;;AAAA,oDAAyD;AAEzD,MAAa,mBAAoB,SAAQ,+BAAkB;IACzD,YAAY,MAAc,EAAE,KAAc,EAAE,KAAe;QACzD,KAAK,CAAC,0BAA0B,MAAM,EAAE,EAAE;YACxC,KAAK;YACL,OAAO,EAAE,EAAE,KAAK,EAAE;SACnB,CAAC,CAAC;IACL,CAAC;CACF;AAPD,kDAOC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.InvalidStringRecord = void 0;
|
|
18
|
+
__exportStar(require("./string-record.parser"), exports);
|
|
19
|
+
var exception_1 = require("./exception");
|
|
20
|
+
Object.defineProperty(exports, "InvalidStringRecord", { enumerable: true, get: function () { return exception_1.InvalidStringRecord; } });
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/config/parsers/string-record/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,yCAAkD;AAAzC,gHAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PropertyParser } from '../../types';
|
|
2
|
+
/** Парсит JSON в плоский объект, проверяя, что все значения — строки. */
|
|
3
|
+
export declare class StringRecordParser implements PropertyParser<Record<string, string>> {
|
|
4
|
+
type(): string;
|
|
5
|
+
description(): string;
|
|
6
|
+
parse(value: unknown): Record<string, string>;
|
|
7
|
+
private toJson;
|
|
8
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringRecordParser = void 0;
|
|
4
|
+
const exception_1 = require("./exception");
|
|
5
|
+
/** Парсит JSON в плоский объект, проверяя, что все значения — строки. */
|
|
6
|
+
class StringRecordParser {
|
|
7
|
+
type() {
|
|
8
|
+
return 'json(Record<string, string>)';
|
|
9
|
+
}
|
|
10
|
+
description() {
|
|
11
|
+
return 'Parses a JSON object whose values are all strings';
|
|
12
|
+
}
|
|
13
|
+
parse(value) {
|
|
14
|
+
const parsed = this.toJson(value);
|
|
15
|
+
if (parsed === null ||
|
|
16
|
+
typeof parsed !== 'object' ||
|
|
17
|
+
Array.isArray(parsed)) {
|
|
18
|
+
throw new exception_1.InvalidStringRecord('expected a JSON object', value);
|
|
19
|
+
}
|
|
20
|
+
const result = {};
|
|
21
|
+
for (const [key, item] of Object.entries(parsed)) {
|
|
22
|
+
if (typeof item !== 'string') {
|
|
23
|
+
throw new exception_1.InvalidStringRecord(`value of key <${key}> must be a string, got ${typeof item}`, value);
|
|
24
|
+
}
|
|
25
|
+
result[key] = item;
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
toJson(value) {
|
|
30
|
+
if (typeof value !== 'string') {
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(value);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
throw new exception_1.InvalidStringRecord('value is not valid JSON', value, error);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.StringRecordParser = StringRecordParser;
|
|
42
|
+
//# sourceMappingURL=string-record.parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string-record.parser.js","sourceRoot":"","sources":["../../../../src/config/parsers/string-record/string-record.parser.ts"],"names":[],"mappings":";;;AAEA,2CAAkD;AAElD,yEAAyE;AACzE,MAAa,kBAAkB;IAG7B,IAAI;QACF,OAAO,8BAA8B,CAAC;IACxC,CAAC;IAED,WAAW;QACT,OAAO,mDAAmD,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,KAAc;QAClB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAElC,IACE,MAAM,KAAK,IAAI;YACf,OAAO,MAAM,KAAK,QAAQ;YAC1B,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EACrB,CAAC;YACD,MAAM,IAAI,+BAAmB,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC;QAED,MAAM,MAAM,GAA2B,EAAE,CAAC;QAE1C,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACjD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC7B,MAAM,IAAI,+BAAmB,CAC3B,iBAAiB,GAAG,2BAA2B,OAAO,IAAI,EAAE,EAC5D,KAAK,CACN,CAAC;YACJ,CAAC;YAED,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;QACrB,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,MAAM,CAAC,KAAc;QAC3B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,+BAAmB,CAAC,yBAAyB,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;CACF;AAjDD,gDAiDC"}
|
|
@@ -1,6 +1,27 @@
|
|
|
1
|
+
import type { OnApplicationShutdown } from '@nestjs/common';
|
|
1
2
|
import { LoggingConfig } from './logging.config';
|
|
2
|
-
export declare class LoggerInitializingModule {
|
|
3
|
+
export declare class LoggerInitializingModule implements OnApplicationShutdown {
|
|
4
|
+
private readonly config;
|
|
3
5
|
private static logger;
|
|
4
6
|
constructor(config: LoggingConfig);
|
|
7
|
+
onApplicationShutdown(): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Worker-транспорт нужен только для сетевых приёмников (OTEL/HTTP) либо по
|
|
10
|
+
* явному запросу. Для логирования лишь в stdout остаёмся на in-process
|
|
11
|
+
* stream — без воркеров, как было до multitransport.
|
|
12
|
+
*/
|
|
13
|
+
private buildDelivery;
|
|
5
14
|
private buildTransportOptions;
|
|
15
|
+
/**
|
|
16
|
+
* OTEL-таргет оборачивается в pipeline `[time-transform → otel]`: трансформ
|
|
17
|
+
* приводит поле `time` к числовому epoch ms, которого требует OTLP (иначе при
|
|
18
|
+
* дефолтном isoTime записи молча отбрасываются), не затрагивая формат времени
|
|
19
|
+
* остальных таргетов.
|
|
20
|
+
*
|
|
21
|
+
* `otlp-logger` (через который работает pino-opentelemetry-transport) НЕ
|
|
22
|
+
* читает ключи `endpoint`/`serviceName`: endpoint задаётся через
|
|
23
|
+
* exporterOptions.url, а имя сервиса — через resourceAttributes/loggerName.
|
|
24
|
+
*/
|
|
25
|
+
private buildOtelTarget;
|
|
26
|
+
private buildHttpTarget;
|
|
6
27
|
}
|
|
@@ -16,45 +16,137 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.LoggerInitializingModule = void 0;
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
18
|
const logging_1 = require("@rsdk/logging");
|
|
19
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
19
20
|
const pino_1 = __importDefault(require("pino"));
|
|
20
21
|
const logging_config_1 = require("./logging.config");
|
|
22
|
+
/**
|
|
23
|
+
* Абсолютный путь к скомпилированному pipeline-трансформу (рядом в dist).
|
|
24
|
+
* Воркер pino грузит таргет по пути, поэтому ссылаемся на .js, а не на модуль.
|
|
25
|
+
*/
|
|
26
|
+
const OTEL_TIME_TRANSFORM = node_path_1.default.join(__dirname, 'otel-time.transform.js');
|
|
21
27
|
let LoggerInitializingModule = class LoggerInitializingModule {
|
|
22
28
|
static { LoggerInitializingModule_1 = this; }
|
|
29
|
+
config;
|
|
23
30
|
static logger = logging_1.LoggerFactory.create(LoggerInitializingModule_1);
|
|
24
31
|
constructor(config) {
|
|
32
|
+
this.config = config;
|
|
25
33
|
const cfg = () => {
|
|
26
34
|
LoggerInitializingModule_1.logger.info(`Setting log level: <${config.level}>`, {
|
|
27
35
|
logLevel: config.level,
|
|
28
36
|
});
|
|
29
37
|
logging_1.LoggerFactory.reconfigure({
|
|
30
38
|
...config,
|
|
31
|
-
|
|
39
|
+
timestampFormat: config.logTimestampFormat,
|
|
40
|
+
...this.buildDelivery(config),
|
|
32
41
|
});
|
|
33
42
|
};
|
|
34
43
|
config.onUpdate(cfg);
|
|
35
44
|
cfg();
|
|
36
45
|
}
|
|
46
|
+
async onApplicationShutdown() {
|
|
47
|
+
await logging_1.LoggerFactory.shutdown(this.config.shutdownTimeout.millis());
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Worker-транспорт нужен только для сетевых приёмников (OTEL/HTTP) либо по
|
|
51
|
+
* явному запросу. Для логирования лишь в stdout остаёмся на in-process
|
|
52
|
+
* stream — без воркеров, как было до multitransport.
|
|
53
|
+
*/
|
|
54
|
+
buildDelivery(config) {
|
|
55
|
+
const needsTransport = config.otelEnabled ||
|
|
56
|
+
Boolean(config.httpEndpoint) ||
|
|
57
|
+
config.forceTransport;
|
|
58
|
+
return needsTransport
|
|
59
|
+
? { transport: this.buildTransportOptions(config) }
|
|
60
|
+
: {
|
|
61
|
+
stream: pino_1.default.destination({
|
|
62
|
+
dest: process.stdout.fd,
|
|
63
|
+
sync: config.sync,
|
|
64
|
+
}),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
37
67
|
buildTransportOptions(config) {
|
|
38
68
|
const targets = [
|
|
39
69
|
{
|
|
40
70
|
target: 'pino/file',
|
|
41
|
-
options: {
|
|
71
|
+
options: {
|
|
72
|
+
destination: process.stdout.fd,
|
|
73
|
+
},
|
|
42
74
|
level: config.level,
|
|
43
75
|
},
|
|
44
76
|
];
|
|
77
|
+
// OTEL включается флагом (endpoint опционален — резолвится из стандартных
|
|
78
|
+
// OTEL_* env), а HTTP — наличием endpoint (у него стандартного discovery
|
|
79
|
+
// нет). Отсюда разные модели enable у двух сетевых транспортов.
|
|
45
80
|
if (config.otelEnabled) {
|
|
46
|
-
targets.push(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
* (unsafe destructuring in pino-opentelemetry-transport)
|
|
51
|
-
*/
|
|
52
|
-
options: {},
|
|
53
|
-
level: config.level,
|
|
54
|
-
});
|
|
81
|
+
targets.push(this.buildOtelTarget(config));
|
|
82
|
+
}
|
|
83
|
+
if (config.httpEndpoint) {
|
|
84
|
+
targets.push(this.buildHttpTarget(config.httpEndpoint, config));
|
|
55
85
|
}
|
|
56
86
|
return { targets };
|
|
57
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* OTEL-таргет оборачивается в pipeline `[time-transform → otel]`: трансформ
|
|
90
|
+
* приводит поле `time` к числовому epoch ms, которого требует OTLP (иначе при
|
|
91
|
+
* дефолтном isoTime записи молча отбрасываются), не затрагивая формат времени
|
|
92
|
+
* остальных таргетов.
|
|
93
|
+
*
|
|
94
|
+
* `otlp-logger` (через который работает pino-opentelemetry-transport) НЕ
|
|
95
|
+
* читает ключи `endpoint`/`serviceName`: endpoint задаётся через
|
|
96
|
+
* exporterOptions.url, а имя сервиса — через resourceAttributes/loggerName.
|
|
97
|
+
*/
|
|
98
|
+
buildOtelTarget(config) {
|
|
99
|
+
const exporterOptions = {};
|
|
100
|
+
// Без явного протокола otlp-logger резолвит его из стандартного
|
|
101
|
+
// OTEL_EXPORTER_OTLP_PROTOCOL env (default protobuf).
|
|
102
|
+
if (config.otelProtocol) {
|
|
103
|
+
exporterOptions.protocol = config.otelProtocol;
|
|
104
|
+
}
|
|
105
|
+
if (config.otelEndpoint) {
|
|
106
|
+
const exporterUrl = { url: config.otelEndpoint.href };
|
|
107
|
+
// url кладём под все три ключа: otlp-logger прочитает только
|
|
108
|
+
// соответствующий выбранному протоколу, остальные проигнорирует.
|
|
109
|
+
exporterOptions.httpExporterOptions = exporterUrl;
|
|
110
|
+
exporterOptions.protobufExporterOptions = exporterUrl;
|
|
111
|
+
exporterOptions.grpcExporterOptions = exporterUrl;
|
|
112
|
+
}
|
|
113
|
+
const options = {
|
|
114
|
+
logRecordProcessorOptions: {
|
|
115
|
+
recordProcessorType: 'batch',
|
|
116
|
+
exporterOptions,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
if (config.otelServiceName) {
|
|
120
|
+
options.loggerName = config.otelServiceName;
|
|
121
|
+
options.resourceAttributes = {
|
|
122
|
+
'service.name': config.otelServiceName,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
level: config.level,
|
|
127
|
+
pipeline: [
|
|
128
|
+
{ target: OTEL_TIME_TRANSFORM },
|
|
129
|
+
{ target: 'pino-opentelemetry-transport', options },
|
|
130
|
+
],
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
buildHttpTarget(url, config) {
|
|
134
|
+
return {
|
|
135
|
+
target: 'pino-http-transport',
|
|
136
|
+
options: {
|
|
137
|
+
url: url.href,
|
|
138
|
+
headers: config.httpHeaders,
|
|
139
|
+
timeout: config.httpTimeout.millis(),
|
|
140
|
+
batchSize: config.httpBatchSize,
|
|
141
|
+
batchInterval: config.httpBatchInterval.millis(),
|
|
142
|
+
maxRetries: config.httpMaxRetries,
|
|
143
|
+
retryDelay: config.httpRetryDelay.millis(),
|
|
144
|
+
maxBufferSize: config.httpMaxBufferSize,
|
|
145
|
+
silent: config.httpSilent,
|
|
146
|
+
},
|
|
147
|
+
level: config.level,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
58
150
|
};
|
|
59
151
|
exports.LoggerInitializingModule = LoggerInitializingModule;
|
|
60
152
|
exports.LoggerInitializingModule = LoggerInitializingModule = LoggerInitializingModule_1 = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger-initializing.module.js","sourceRoot":"","sources":["../../src/logging/logger-initializing.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"logger-initializing.module.js","sourceRoot":"","sources":["../../src/logging/logger-initializing.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,2CAAwC;AAExC,2CAA8C;AAC9C,0DAA6B;AAC7B,gDAIc;AAEd,qDAAiD;AAEjD;;;GAGG;AACH,MAAM,mBAAmB,GAAG,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,wBAAwB,CAAC,CAAC;AAGpE,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;;IAGN;IAFrB,MAAM,CAAC,MAAM,GAAG,uBAAa,CAAC,MAAM,CAAC,0BAAwB,CAAC,CAAC;IAEvE,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;QAChD,MAAM,GAAG,GAAG,GAAS,EAAE;YACrB,0BAAwB,CAAC,MAAM,CAAC,IAAI,CAClC,uBAAuB,MAAM,CAAC,KAAK,GAAG,EACtC;gBACE,QAAQ,EAAE,MAAM,CAAC,KAAK;aACvB,CACF,C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AAqB;QAErB,OAAO;YACL,MAAM,EAAE,qBAAqB;YAC7B,OAAO,EAAE;gBACP,GAAG,EAAE,GAAG,CAAC,IAAI;gBACb,OAAO,EAAE,MAAM,CAAC,WAAW;gBAC3B,OAAO,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE;gBACpC,SAAS,EAAE,MAAM,CAAC,aAAa;gBAC/B,aAAa,EAAE,MAAM,CAAC,iBAAiB,CAAC,MAAM,EAAE;gBAChD,UAAU,EAAE,MAAM,CAAC,cAAc;gBACjC,UAAU,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE;gBAC1C,aAAa,EAAE,MAAM,CAAC,iBAAiB;gBACvC,MAAM,EAAE,MAAM,CAAC,UAAU;aAC1B;YACD,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC;IACJ,CAAC;;AAhJU,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,eAAM,EAAC,EAAE,CAAC;qCAI4B,8BAAa;GAHvC,wBAAwB,CAiJpC"}
|
|
@@ -1,8 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Timespan } from '@rsdk/common';
|
|
2
|
+
import { LogLevel, LogTimestampFormat } from '@rsdk/logging';
|
|
2
3
|
import { Config } from '../config';
|
|
4
|
+
export declare enum LogOtelProtocol {
|
|
5
|
+
httpProtobuf = "http/protobuf",
|
|
6
|
+
http = "http",
|
|
7
|
+
httpJson = "http/json",
|
|
8
|
+
grpc = "grpc",
|
|
9
|
+
console = "console"
|
|
10
|
+
}
|
|
3
11
|
export declare class LoggingConfig extends Config {
|
|
4
12
|
readonly level: LogLevel;
|
|
5
13
|
readonly redact: string[];
|
|
6
14
|
readonly sync: boolean;
|
|
15
|
+
readonly shutdownTimeout: Timespan;
|
|
16
|
+
readonly forceTransport: boolean;
|
|
17
|
+
readonly httpEndpoint?: URL;
|
|
18
|
+
readonly httpHeaders: Record<string, string>;
|
|
19
|
+
readonly httpTimeout: Timespan;
|
|
20
|
+
readonly httpBatchSize: number;
|
|
21
|
+
readonly httpBatchInterval: Timespan;
|
|
22
|
+
readonly httpMaxRetries: number;
|
|
23
|
+
readonly httpRetryDelay: Timespan;
|
|
24
|
+
readonly httpMaxBufferSize: number;
|
|
25
|
+
readonly httpSilent: boolean;
|
|
7
26
|
readonly otelEnabled: boolean;
|
|
27
|
+
readonly otelEndpoint?: URL;
|
|
28
|
+
readonly otelProtocol?: LogOtelProtocol;
|
|
29
|
+
readonly otelServiceName?: string;
|
|
30
|
+
readonly logTimestampFormat: LogTimestampFormat;
|
|
8
31
|
}
|
|
@@ -9,15 +9,39 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.LoggingConfig = void 0;
|
|
12
|
+
exports.LoggingConfig = exports.LogOtelProtocol = void 0;
|
|
13
|
+
const common_1 = require("@rsdk/common");
|
|
13
14
|
const logging_1 = require("@rsdk/logging");
|
|
14
15
|
const config_1 = require("../config");
|
|
15
16
|
const config_const_1 = require("../config/config.const");
|
|
17
|
+
var LogOtelProtocol;
|
|
18
|
+
(function (LogOtelProtocol) {
|
|
19
|
+
LogOtelProtocol["httpProtobuf"] = "http/protobuf";
|
|
20
|
+
LogOtelProtocol["http"] = "http";
|
|
21
|
+
LogOtelProtocol["httpJson"] = "http/json";
|
|
22
|
+
LogOtelProtocol["grpc"] = "grpc";
|
|
23
|
+
LogOtelProtocol["console"] = "console";
|
|
24
|
+
})(LogOtelProtocol || (exports.LogOtelProtocol = LogOtelProtocol = {}));
|
|
16
25
|
let LoggingConfig = class LoggingConfig extends config_1.Config {
|
|
17
26
|
level;
|
|
18
27
|
redact;
|
|
19
28
|
sync;
|
|
29
|
+
shutdownTimeout;
|
|
30
|
+
forceTransport;
|
|
31
|
+
httpEndpoint;
|
|
32
|
+
httpHeaders;
|
|
33
|
+
httpTimeout;
|
|
34
|
+
httpBatchSize;
|
|
35
|
+
httpBatchInterval;
|
|
36
|
+
httpMaxRetries;
|
|
37
|
+
httpRetryDelay;
|
|
38
|
+
httpMaxBufferSize;
|
|
39
|
+
httpSilent;
|
|
20
40
|
otelEnabled;
|
|
41
|
+
otelEndpoint;
|
|
42
|
+
otelProtocol;
|
|
43
|
+
otelServiceName;
|
|
44
|
+
logTimestampFormat;
|
|
21
45
|
};
|
|
22
46
|
exports.LoggingConfig = LoggingConfig;
|
|
23
47
|
__decorate([
|
|
@@ -38,17 +62,122 @@ __decorate([
|
|
|
38
62
|
__decorate([
|
|
39
63
|
(0, config_1.Property)('LOG_SYNC', new config_1.BoolParser(), {
|
|
40
64
|
defaultValue: false,
|
|
41
|
-
description: 'Synchronous
|
|
65
|
+
description: 'Synchronous stdout writes. Applies only to in-process stream mode; worker transports (OTEL/HTTP/forced) are always async. https://github.com/pinojs/pino/blob/master/docs/asynchronous.md',
|
|
42
66
|
}),
|
|
43
67
|
__metadata("design:type", Boolean)
|
|
44
68
|
], LoggingConfig.prototype, "sync", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, config_1.Property)('LOG_SHUTDOWN_TIMEOUT', new config_1.TimespanParser(), {
|
|
71
|
+
defaultValue: new common_1.Timespan(1, 's'),
|
|
72
|
+
description: 'Max time to flush buffered worker-transport logs on application shutdown. Raise it when using OTEL: its worker may take longer to flush the last batch',
|
|
73
|
+
}),
|
|
74
|
+
__metadata("design:type", common_1.Timespan)
|
|
75
|
+
], LoggingConfig.prototype, "shutdownTimeout", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, config_1.Property)('LOG_FORCE_TRANSPORT', new config_1.BoolParser(), {
|
|
78
|
+
defaultValue: false,
|
|
79
|
+
description: 'Use worker-based transport even when only stdout is configured (no OTEL/HTTP). Otherwise stdout-only logging stays in-process',
|
|
80
|
+
}),
|
|
81
|
+
__metadata("design:type", Boolean)
|
|
82
|
+
], LoggingConfig.prototype, "forceTransport", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, config_1.Property)('LOG_HTTP_ENDPOINT', new config_1.UrlParser('http:', 'https:'), {
|
|
85
|
+
defaultValue: undefined,
|
|
86
|
+
description: 'URL endpoint for the HTTP logs transport. Transport is enabled when set',
|
|
87
|
+
}),
|
|
88
|
+
__metadata("design:type", URL)
|
|
89
|
+
], LoggingConfig.prototype, "httpEndpoint", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, config_1.Property)('LOG_HTTP_HEADERS', new config_1.StringRecordParser(), {
|
|
92
|
+
defaultValue: {},
|
|
93
|
+
description: 'JSON object of HTTP headers sent by the HTTP logs transport',
|
|
94
|
+
}),
|
|
95
|
+
__metadata("design:type", Object)
|
|
96
|
+
], LoggingConfig.prototype, "httpHeaders", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
(0, config_1.Property)('LOG_HTTP_TIMEOUT', new config_1.TimespanParser(), {
|
|
99
|
+
defaultValue: new common_1.Timespan(2500, 'ms'),
|
|
100
|
+
description: 'Request timeout for the HTTP logs transport',
|
|
101
|
+
}),
|
|
102
|
+
__metadata("design:type", common_1.Timespan)
|
|
103
|
+
], LoggingConfig.prototype, "httpTimeout", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
(0, config_1.Property)('LOG_HTTP_BATCH_SIZE', new config_1.IntParser(), {
|
|
106
|
+
defaultValue: 100,
|
|
107
|
+
description: 'Number of logs flushed per batch by the HTTP logs transport',
|
|
108
|
+
}),
|
|
109
|
+
__metadata("design:type", Number)
|
|
110
|
+
], LoggingConfig.prototype, "httpBatchSize", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
(0, config_1.Property)('LOG_HTTP_BATCH_INTERVAL', new config_1.TimespanParser(), {
|
|
113
|
+
defaultValue: new common_1.Timespan(5, 's'),
|
|
114
|
+
description: 'Max interval between batch flushes of the HTTP logs transport',
|
|
115
|
+
}),
|
|
116
|
+
__metadata("design:type", common_1.Timespan)
|
|
117
|
+
], LoggingConfig.prototype, "httpBatchInterval", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
(0, config_1.Property)('LOG_HTTP_MAX_RETRIES', new config_1.IntParser(), {
|
|
120
|
+
defaultValue: 2,
|
|
121
|
+
description: 'Max retry attempts for a failed HTTP logs batch',
|
|
122
|
+
}),
|
|
123
|
+
__metadata("design:type", Number)
|
|
124
|
+
], LoggingConfig.prototype, "httpMaxRetries", void 0);
|
|
125
|
+
__decorate([
|
|
126
|
+
(0, config_1.Property)('LOG_HTTP_RETRY_DELAY', new config_1.TimespanParser(), {
|
|
127
|
+
defaultValue: new common_1.Timespan(1, 's'),
|
|
128
|
+
description: 'Base delay between HTTP logs retry attempts',
|
|
129
|
+
}),
|
|
130
|
+
__metadata("design:type", common_1.Timespan)
|
|
131
|
+
], LoggingConfig.prototype, "httpRetryDelay", void 0);
|
|
132
|
+
__decorate([
|
|
133
|
+
(0, config_1.Property)('LOG_HTTP_MAX_BUFFER_SIZE', new config_1.IntParser(), {
|
|
134
|
+
defaultValue: 100000,
|
|
135
|
+
description: 'Max number of buffered logs before dropping (HTTP logs transport)',
|
|
136
|
+
}),
|
|
137
|
+
__metadata("design:type", Number)
|
|
138
|
+
], LoggingConfig.prototype, "httpMaxBufferSize", void 0);
|
|
139
|
+
__decorate([
|
|
140
|
+
(0, config_1.Property)('LOG_HTTP_SILENT', new config_1.BoolParser(), {
|
|
141
|
+
defaultValue: false,
|
|
142
|
+
description: 'Suppress internal warnings/errors of the HTTP logs transport',
|
|
143
|
+
}),
|
|
144
|
+
__metadata("design:type", Boolean)
|
|
145
|
+
], LoggingConfig.prototype, "httpSilent", void 0);
|
|
45
146
|
__decorate([
|
|
46
147
|
(0, config_1.Property)('LOG_OTEL_ENABLED', new config_1.BoolParser(), {
|
|
47
148
|
defaultValue: false,
|
|
48
|
-
description: 'Enable OpenTelemetry exporter',
|
|
149
|
+
description: 'Enable OpenTelemetry logs exporter',
|
|
49
150
|
}),
|
|
50
151
|
__metadata("design:type", Boolean)
|
|
51
152
|
], LoggingConfig.prototype, "otelEnabled", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
(0, config_1.Property)('LOG_OTEL_ENDPOINT', new config_1.UrlParser('http:', 'https:'), {
|
|
155
|
+
defaultValue: undefined,
|
|
156
|
+
description: 'OTLP endpoint URL for the OpenTelemetry logs exporter',
|
|
157
|
+
}),
|
|
158
|
+
__metadata("design:type", URL)
|
|
159
|
+
], LoggingConfig.prototype, "otelEndpoint", void 0);
|
|
160
|
+
__decorate([
|
|
161
|
+
(0, config_1.Property)('LOG_OTEL_PROTOCOL', new config_1.EnumParser(LogOtelProtocol), {
|
|
162
|
+
defaultValue: undefined,
|
|
163
|
+
description: 'OTLP exporter protocol for the OpenTelemetry logs. When unset, resolved from standard OTEL_EXPORTER_OTLP_PROTOCOL env (defaults to http/protobuf)',
|
|
164
|
+
}),
|
|
165
|
+
__metadata("design:type", String)
|
|
166
|
+
], LoggingConfig.prototype, "otelProtocol", void 0);
|
|
167
|
+
__decorate([
|
|
168
|
+
(0, config_1.Property)('LOG_OTEL_SERVICE_NAME', new config_1.StringParser(), {
|
|
169
|
+
defaultValue: undefined,
|
|
170
|
+
description: 'service.name resource attribute for the OpenTelemetry logs. When unset, resolved from standard OTEL env',
|
|
171
|
+
}),
|
|
172
|
+
__metadata("design:type", String)
|
|
173
|
+
], LoggingConfig.prototype, "otelServiceName", void 0);
|
|
174
|
+
__decorate([
|
|
175
|
+
(0, config_1.Property)('LOG_TIMESTAMP_FORMAT', new config_1.EnumParser(logging_1.LogTimestampFormat), {
|
|
176
|
+
defaultValue: logging_1.LogTimestampFormat.isoTime,
|
|
177
|
+
description: 'Log timestamp format',
|
|
178
|
+
}),
|
|
179
|
+
__metadata("design:type", String)
|
|
180
|
+
], LoggingConfig.prototype, "logTimestampFormat", void 0);
|
|
52
181
|
exports.LoggingConfig = LoggingConfig = __decorate([
|
|
53
182
|
(0, config_1.ConfigSection)({
|
|
54
183
|
tags: [config_const_1.ConfigTag.infrastructure, config_const_1.ConfigTag.logging],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging.config.js","sourceRoot":"","sources":["../../src/logging/logging.config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"logging.config.js","sourceRoot":"","sources":["../../src/logging/logging.config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAwC;AACxC,2CAA4E;AAE5E,sCAYmB;AACnB,yDAAmD;AAEnD,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,iDAA8B,CAAA;IAC9B,gCAAa,CAAA;IACb,yCAAsB,CAAA;IACtB,gCAAa,CAAA;IACb,sCAAmB,CAAA;AACrB,CAAC,EANW,eAAe,+BAAf,eAAe,QAM1B;AAKM,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,eAAM;IAM9B,KAAK,CAAY;IAOjB,MAAM,CAAY;IAOlB,IAAI,CAAW;IAOf,eAAe,CAAY;IAO3B,cAAc,CAAW;IAOzB,YAAY,CAAO;IAMnB,WAAW,CAA0B;IAMrC,WAAW,CAAY;IAMvB,aAAa,CAAU;IAOvB,iBAAiB,CAAY;IAM7B,cAAc,CAAU;IAMxB,cAAc,CAAY;IAO1B,iBAAiB,CAAU;IAM3B,UAAU,CAAW;IAMrB,WAAW,CAAW;IAMtB,YAAY,CAAO;IAOnB,YAAY,CAAmB;IAO/B,eAAe,CAAU;IAMzB,kBAAkB,CAAsB;CAClD,CAAA;AA5HY,sCAAa;AAMf;IALR,IAAA,iBAAQ,EAAC,WAAW,EAAE,IAAI,mBAAU,CAAC,kBAAQ,CAAC,EAAE;QAC/C,sEAAsE;QACtE,YAAY,EAAE,uBAAa;QAC3B,WAAW,EAAE,WAAW;KACzB,CAAC;;4CACwB;AAOjB;IALR,IAAA,iBAAQ,EAAC,YAAY,EAAE,IAAI,oBAAW,CAAC,IAAI,qBAAY,EAAE,CAAC,EAAE;QAC3D,Y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9D,YAAY,EAAE,SAAS;QACvB,WAAW,EACT,mJAAmJ;KACtJ,CAAC;;mDACsC;AAO/B;IALR,IAAA,iBAAQ,EAAC,uBAAuB,EAAE,IAAI,qBAAY,EAAE,EAAE;QACrD,YAAY,EAAE,SAAS;QACvB,WAAW,EACT,yGAAyG;KAC5G,CAAC;;sDACgC;AAMzB;IAJR,IAAA,iBAAQ,EAAC,sBAAsB,EAAE,IAAI,mBAAU,CAAC,4BAAkB,CAAC,EAAE;QACpE,YAAY,EAAE,4BAAkB,CAAC,OAAO;QACxC,WAAW,EAAE,sBAAsB;KACpC,CAAC;;yDAC+C;wBA3HtC,aAAa;IAHzB,IAAA,sBAAa,EAAC;QACb,IAAI,EAAE,CAAC,wBAAS,CAAC,cAAc,EAAE,wBAAS,CAAC,OAAO,CAAC;KACpD,CAAC;GACW,aAAa,CA4HzB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Transform } from 'node:stream';
|
|
2
|
+
/**
|
|
3
|
+
* Pipeline-трансформ перед pino-opentelemetry-transport: приводит поле `time`
|
|
4
|
+
* к числу (epoch ms), если оно пришло строкой (например, при дефолтном
|
|
5
|
+
* LOG_TIMESTAMP_FORMAT=isoTime). OTLP ожидает числовой timestamp, иначе запись
|
|
6
|
+
* молча отбрасывается. Трансформ применяется только к OTEL-ветке — stdout и
|
|
7
|
+
* прочие транспорты сохраняют свой человекочитаемый формат времени.
|
|
8
|
+
*/
|
|
9
|
+
export default function buildOtelTimeTransform(): Promise<Transform>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = buildOtelTimeTransform;
|
|
7
|
+
const node_stream_1 = require("node:stream");
|
|
8
|
+
const pino_abstract_transport_1 = __importDefault(require("pino-abstract-transport"));
|
|
9
|
+
/**
|
|
10
|
+
* Pipeline-трансформ перед pino-opentelemetry-transport: приводит поле `time`
|
|
11
|
+
* к числу (epoch ms), если оно пришло строкой (например, при дефолтном
|
|
12
|
+
* LOG_TIMESTAMP_FORMAT=isoTime). OTLP ожидает числовой timestamp, иначе запись
|
|
13
|
+
* молча отбрасывается. Трансформ применяется только к OTEL-ветке — stdout и
|
|
14
|
+
* прочие транспорты сохраняют свой человекочитаемый формат времени.
|
|
15
|
+
*/
|
|
16
|
+
function buildOtelTimeTransform() {
|
|
17
|
+
return (0, pino_abstract_transport_1.default)((source) => {
|
|
18
|
+
const transform = new node_stream_1.Transform({
|
|
19
|
+
objectMode: true,
|
|
20
|
+
autoDestroy: true,
|
|
21
|
+
transform(chunk, _encoding, callback) {
|
|
22
|
+
if (typeof chunk.time === 'string') {
|
|
23
|
+
const epochMs = Date.parse(chunk.time);
|
|
24
|
+
if (!Number.isNaN(epochMs)) {
|
|
25
|
+
chunk.time = epochMs;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
callback(null, `${JSON.stringify(chunk)}\n`);
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
(0, node_stream_1.pipeline)(source, transform, () => { });
|
|
32
|
+
return transform;
|
|
33
|
+
}, { enablePipelining: true });
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=otel-time.transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otel-time.transform.js","sourceRoot":"","sources":["../../src/logging/otel-time.transform.ts"],"names":[],"mappings":";;;;;AAUA,yCA6BC;AAvCD,6CAAkD;AAClD,sFAA4C;AAE5C;;;;;;GAMG;AACH,SAAwB,sBAAsB;IAC5C,OAAO,IAAA,iCAAK,EACV,CAAC,MAAM,EAAE,EAAE;QACT,MAAM,SAAS,GAAG,IAAI,uBAAS,CAAC;YAC9B,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,IAAI;YACjB,SAAS,CACP,KAA8B,EAC9B,SAAyB,EACzB,QAAuD;gBAEvD,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBACnC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBAEvC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;wBAC3B,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC;oBACvB,CAAC;gBACH,CAAC;gBAED,QAAQ,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC/C,CAAC;SACF,CAAC,CAAC;QAEH,IAAA,sBAAQ,EAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAEtC,OAAO,SAAS,CAAC;IACnB,CAAC,EACD,EAAE,gBAAgB,EAAE,IAAI,EAAE,CACM,CAAC;AACrC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/core",
|
|
3
|
-
"version": "5.11.1-next.
|
|
3
|
+
"version": "5.11.1-next.2",
|
|
4
4
|
"description": "Nestjs based microservice chassis",
|
|
5
5
|
"license": "Apache License 2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"dotenv": "^16.0.0",
|
|
18
18
|
"lodash": "^4.17.21",
|
|
19
19
|
"pino": "^8.0.0 || ^9.0.0",
|
|
20
|
+
"pino-abstract-transport": "^2.0.0",
|
|
20
21
|
"prom-client": "^14.2.0"
|
|
21
22
|
},
|
|
22
23
|
"peerDependencies": {
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
"@rsdk/logging": "*",
|
|
35
36
|
"@rsdk/metadata": "*",
|
|
36
37
|
"@rsdk/nest-tools": "*",
|
|
38
|
+
"pino-http-transport": "^1.0.0",
|
|
37
39
|
"pino-opentelemetry-transport": "^1.0.1",
|
|
38
40
|
"reflect-metadata": "^0.1.12 || ^0.2.0",
|
|
39
41
|
"rxjs": "^7.1.0"
|
|
@@ -45,9 +47,12 @@
|
|
|
45
47
|
"@opentelemetry/exporter-logs-otlp-http": {
|
|
46
48
|
"optional": true
|
|
47
49
|
},
|
|
50
|
+
"pino-http-transport": {
|
|
51
|
+
"optional": true
|
|
52
|
+
},
|
|
48
53
|
"pino-opentelemetry-transport": {
|
|
49
54
|
"optional": true
|
|
50
55
|
}
|
|
51
56
|
},
|
|
52
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "69508988b964da6975ce57d28665181771d6dce1"
|
|
53
58
|
}
|