@rsdk/core 5.1.0-next.0 → 5.2.0-next.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.2.0-next.0](https://github.com/R-Vision/rsdk/compare/v5.1.0...v5.2.0-next.0) (2024-10-09)
7
+
8
+ ### Features
9
+
10
+ * **core:** opentelemetry logs exporting support [PFM-1892] ([#292](https://github.com/R-Vision/rsdk/issues/292)) ([6db5304](https://github.com/R-Vision/rsdk/commit/6db53049fd61b1307d685ec9f2684c2291257c29))
11
+
12
+ ## [5.1.0](https://github.com/R-Vision/rsdk/compare/v5.1.0-next.0...v5.1.0) (2024-09-03)
13
+
14
+ **Note:** Version bump only for package @rsdk/core
15
+
6
16
  ## [5.1.0-next.0](https://github.com/R-Vision/rsdk/compare/v5.0.5-next.0...v5.1.0-next.0) (2024-09-02)
7
17
 
8
18
  **Note:** Version bump only for package @rsdk/core
@@ -2,4 +2,5 @@ import { LoggingConfig } from './logging.config';
2
2
  export declare class LoggerInitializingModule {
3
3
  private static logger;
4
4
  constructor(config: LoggingConfig);
5
+ private buildTransportOptions;
5
6
  }
@@ -28,14 +28,31 @@ let LoggerInitializingModule = class LoggerInitializingModule {
28
28
  });
29
29
  logging_1.LoggerFactory.reconfigure({
30
30
  ...config,
31
- stream: pino_1.default.destination({
32
- sync: config.sync,
33
- }),
31
+ stream: pino_1.default.transport(this.buildTransportOptions(config)),
34
32
  });
35
33
  };
36
34
  config.onUpdate(cfg);
37
35
  cfg();
38
36
  }
37
+ buildTransportOptions(config) {
38
+ const targets = [
39
+ {
40
+ target: 'pino/file',
41
+ options: { destination: process.stdout.fd },
42
+ },
43
+ ];
44
+ if (config.otelEnabled) {
45
+ targets.push({
46
+ target: 'pino-opentelemetry-transport',
47
+ /**
48
+ * NOTE: {} required to avoid runtime error "Cannot read property 'xxx' of undefined"
49
+ * (unsafe destructuring in pino-opentelemetry-transport)
50
+ */
51
+ options: {},
52
+ });
53
+ }
54
+ return { targets };
55
+ }
39
56
  };
40
57
  exports.LoggerInitializingModule = LoggerInitializingModule;
41
58
  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":";;;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,2CAA8C;AAC9C,gDAAwB;AAExB,qDAAiD;AAG1C,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;;IAC3B,MAAM,CAAC,MAAM,GAAG,uBAAa,CAAC,MAAM,CAAC,0BAAwB,CAAC,CAAC;IAEvE,YAAY,MAAqB;QAC/B,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,CAAC;YAEF,uBAAa,CAAC,WAAW,CAAC;gBACxB,GAAG,MAAM;gBACT,MAAM,EAAE,cAAI,CAAC,WAAW,CAAC;oBACvB,IAAI,EAAE,MAAM,CAAC,IAAI;iBAClB,CAAC;aACH,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACrB,GAAG,EAAE,CAAC;IACR,CAAC;;AAtBU,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,eAAM,EAAC,EAAE,CAAC;qCAIW,8BAAa;GAHtB,wBAAwB,CAuBpC"}
1
+ {"version":3,"file":"logger-initializing.module.js","sourceRoot":"","sources":["../../src/logging/logger-initializing.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,2CAA8C;AAE9C,gDAAwB;AAExB,qDAAiD;AAG1C,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;;IAC3B,MAAM,CAAC,MAAM,GAAG,uBAAa,CAAC,MAAM,CAAC,0BAAwB,CAAC,CAAC;IAEvE,YAAY,MAAqB;QAC/B,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,CAAC;YAEF,uBAAa,CAAC,WAAW,CAAC;gBACxB,GAAG,MAAM;gBACT,MAAM,EAAE,cAAI,CAAC,SAAS,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;aAC3D,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACrB,GAAG,EAAE,CAAC;IACR,CAAC;IAEO,qBAAqB,CAAC,MAAqB;QACjD,MAAM,OAAO,GAA6B;YACxC;gBACE,MAAM,EAAE,WAAW;gBACnB,OAAO,EAAE,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE;aAC5C;SACF,CAAC;QAEF,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACvB,OAAO,CAAC,IAAI,CAAC;gBACX,MAAM,EAAE,8BAA8B;gBACtC;;;mBAGG;gBACH,OAAO,EAAE,EAAE;aACZ,CAAC,CAAC;QACL,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;;AA1CU,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,eAAM,EAAC,EAAE,CAAC;qCAIW,8BAAa;GAHtB,wBAAwB,CA2CpC"}
@@ -4,4 +4,5 @@ export declare class LoggingConfig extends Config {
4
4
  readonly level: LogLevel;
5
5
  readonly redact: string[];
6
6
  readonly sync: boolean;
7
+ readonly otelEnabled: boolean;
7
8
  }
@@ -17,6 +17,7 @@ let LoggingConfig = class LoggingConfig extends config_1.Config {
17
17
  level;
18
18
  redact;
19
19
  sync;
20
+ otelEnabled;
20
21
  };
21
22
  exports.LoggingConfig = LoggingConfig;
22
23
  __decorate([
@@ -41,6 +42,13 @@ __decorate([
41
42
  }),
42
43
  __metadata("design:type", Boolean)
43
44
  ], LoggingConfig.prototype, "sync", void 0);
45
+ __decorate([
46
+ (0, config_1.Property)('LOG_OTEL_ENABLED', new config_1.BoolParser(), {
47
+ defaultValue: false,
48
+ description: 'Enable OpenTelemetry exporter',
49
+ }),
50
+ __metadata("design:type", Boolean)
51
+ ], LoggingConfig.prototype, "otelEnabled", void 0);
44
52
  exports.LoggingConfig = LoggingConfig = __decorate([
45
53
  (0, config_1.ConfigSection)({
46
54
  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,2CAAwD;AAExD,sCAQmB;AACnB,yDAAmD;AAK5C,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,eAAM;IAM9B,KAAK,CAAY;IAOjB,MAAM,CAAY;IAOlB,IAAI,CAAW;CACzB,CAAA;AArBY,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,YAAY,EAAE,EAAE;QAChB,WAAW,EACT,gGAAgG;KACnG,CAAC;;6CACyB;AAOlB;IALR,IAAA,iBAAQ,EAAC,UAAU,EAAE,IAAI,mBAAU,EAAE,EAAE;QACtC,YA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KACpD,CAAC;GACW,aAAa,CA2BzB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdk/core",
3
- "version": "5.1.0-next.0",
3
+ "version": "5.2.0-next.0",
4
4
  "description": "Nestjs based microservice chassis",
5
5
  "license": "Apache License 2.0",
6
6
  "publishConfig": {
@@ -24,6 +24,7 @@
24
24
  "@nestjs/core": "^10.0.0",
25
25
  "@nestjs/microservices": "^10.0.0",
26
26
  "@opentelemetry/api": "1.7.0",
27
+ "@opentelemetry/exporter-logs-otlp-http": "0.53.0",
27
28
  "@rsdk/actx": "*",
28
29
  "@rsdk/autodoc.protocol": "*",
29
30
  "@rsdk/common": "*",
@@ -33,13 +34,20 @@
33
34
  "@rsdk/logging": "*",
34
35
  "@rsdk/metadata": "*",
35
36
  "@rsdk/nest-tools": "*",
37
+ "pino-opentelemetry-transport": "^1.0.1",
36
38
  "reflect-metadata": "^0.1.12 || ^0.2.0",
37
39
  "rxjs": "^7.8.1"
38
40
  },
39
41
  "peerDependenciesMeta": {
40
42
  "@opentelemetry/api": {
41
43
  "optional": true
44
+ },
45
+ "@opentelemetry/exporter-logs-otlp-http": {
46
+ "optional": true
47
+ },
48
+ "pino-opentelemetry-transport": {
49
+ "optional": true
42
50
  }
43
51
  },
44
- "gitHead": "19ef06e2cadbdfb68d15f2b9dc1e96378e66f314"
52
+ "gitHead": "da77ceb328be50e1741fdc67945d373f07e01374"
45
53
  }
@@ -1,5 +1,6 @@
1
1
  import { Module } from '@nestjs/common';
2
2
  import { LoggerFactory } from '@rsdk/logging';
3
+ import type { TransportMultiOptions, TransportTargetOptions } from 'pino';
3
4
  import pino from 'pino';
4
5
 
5
6
  import { LoggingConfig } from './logging.config';
@@ -19,13 +20,33 @@ export class LoggerInitializingModule {
19
20
 
20
21
  LoggerFactory.reconfigure({
21
22
  ...config,
22
- stream: pino.destination({
23
- sync: config.sync,
24
- }),
23
+ stream: pino.transport(this.buildTransportOptions(config)),
25
24
  });
26
25
  };
27
26
 
28
27
  config.onUpdate(cfg);
29
28
  cfg();
30
29
  }
30
+
31
+ private buildTransportOptions(config: LoggingConfig): TransportMultiOptions {
32
+ const targets: TransportTargetOptions[] = [
33
+ {
34
+ target: 'pino/file',
35
+ options: { destination: process.stdout.fd },
36
+ },
37
+ ];
38
+
39
+ if (config.otelEnabled) {
40
+ targets.push({
41
+ target: 'pino-opentelemetry-transport',
42
+ /**
43
+ * NOTE: {} required to avoid runtime error "Cannot read property 'xxx' of undefined"
44
+ * (unsafe destructuring in pino-opentelemetry-transport)
45
+ */
46
+ options: {},
47
+ });
48
+ }
49
+
50
+ return { targets };
51
+ }
31
52
  }
@@ -35,4 +35,10 @@ export class LoggingConfig extends Config {
35
35
  'Synchronous logs: https://github.com/pinojs/pino/blob/master/docs/asynchronous.md#asynchronous-logging',
36
36
  })
37
37
  readonly sync!: boolean;
38
+
39
+ @Property('LOG_OTEL_ENABLED', new BoolParser(), {
40
+ defaultValue: false,
41
+ description: 'Enable OpenTelemetry exporter',
42
+ })
43
+ readonly otelEnabled!: boolean;
38
44
  }