@lad-tech/nsc-toolkit 1.17.3 → 1.17.5

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
@@ -1,6 +1,6 @@
1
- ## [1.17.3](https://github.com/lad-tech/nsc-toolkit/compare/v1.17.2...v1.17.3) (2023-11-17)
1
+ ## [1.17.5](https://github.com/lad-tech/nsc-toolkit/compare/v1.17.4...v1.17.5) (2023-12-20)
2
2
 
3
3
 
4
4
  ### Bug Fixes
5
5
 
6
- * Throw error if http response 500 ([#90](https://github.com/lad-tech/nsc-toolkit/issues/90)) ([536b5ce](https://github.com/lad-tech/nsc-toolkit/commit/536b5ce6ee43e900367d5eb2d45bc302ad471e1f))
6
+ * Change opentracing protocol ([#94](https://github.com/lad-tech/nsc-toolkit/issues/94)) ([4798767](https://github.com/lad-tech/nsc-toolkit/commit/4798767037a7aa7f91f3e99113cf2051d062c164))
package/dist/Service.js CHANGED
@@ -58,9 +58,15 @@ class Service extends Root_1.Root {
58
58
  [semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME]: this.options.name,
59
59
  }),
60
60
  });
61
- const exporter = new exporter_jaeger_1.JaegerExporter({
62
- endpoint: this.getSettingFromEnv('OTEL_AGENT', false),
63
- });
61
+ let host;
62
+ let port;
63
+ const agentUrl = this.getSettingFromEnv('OTEL_AGENT', false);
64
+ if (agentUrl) {
65
+ const agent = agentUrl.split(':');
66
+ host = agent[0];
67
+ port = parseInt(agent[1]) || undefined;
68
+ }
69
+ const exporter = new exporter_jaeger_1.JaegerExporter({ host, port });
64
70
  provider.addSpanProcessor(new sdk_trace_base_1.SimpleSpanProcessor(exporter));
65
71
  provider.register();
66
72
  }
@@ -501,11 +507,21 @@ class Service extends Root_1.Root {
501
507
  this.httpProbServer = undefined;
502
508
  });
503
509
  }
510
+ /**
511
+ * Type guard for NATS debug event
512
+ */
513
+ isNATSDebugEvent(event) {
514
+ return (event === nats_1.DebugEvents.PingTimer || event === nats_1.DebugEvents.Reconnecting || event === nats_1.DebugEvents.StaleConnection);
515
+ }
504
516
  /**
505
517
  * Logs events from the broker
506
518
  */
507
519
  async watchBrokerEvents() {
508
520
  for await (const event of this.broker.status()) {
521
+ if (this.isNATSDebugEvent(event.type)) {
522
+ this.logger.debug(`${event.type}: ${event.data}`);
523
+ return;
524
+ }
509
525
  this.logger.warn(`${event.type}: ${event.data}`);
510
526
  }
511
527
  }
@@ -98,6 +98,10 @@ export declare class Service<E extends Emitter = Emitter> extends Root {
98
98
  * Up Probe Route for container orchestration service
99
99
  */
100
100
  private upProbeRoutes;
101
+ /**
102
+ * Type guard for NATS debug event
103
+ */
104
+ private isNATSDebugEvent;
101
105
  /**
102
106
  * Logs events from the broker
103
107
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lad-tech/nsc-toolkit",
3
- "version": "1.17.3",
3
+ "version": "1.17.5",
4
4
  "description": "Toolkit for create microservices around NATS",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/types/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  "typescript": "^5.1.3"
35
35
  },
36
36
  "dependencies": {
37
- "@lad-tech/toolbelt": "^1.1.1",
37
+ "@lad-tech/toolbelt": "^1.3.1",
38
38
  "@opentelemetry/api": "^1.1.0",
39
39
  "@opentelemetry/exporter-jaeger": "^1.3.1",
40
40
  "@opentelemetry/resources": "^1.3.1",