@twin.org/node-core 0.9.2-next.4 → 0.9.2-next.6

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.
@@ -2,9 +2,10 @@
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
3
  import path from "node:path";
4
4
  import { Coerce, Is, Mutex } from "@twin.org/core";
5
- import { AttestationComponentType, AttestationConnectorType, AuditableItemGraphComponentType, AuditableItemStreamComponentType, AutomationComponentType, BackgroundTaskComponentType, BlobStorageComponentType, BlobStorageConnectorType, ContextIdHandlerComponentType, DataProcessingComponentType, DataspaceControlPlaneComponentType, DataspaceDataPlaneComponentType, DltConfigType, DocumentManagementComponentType, EngineTypeHelper, EntityStorageConnectorType, EventBusComponentType, EventBusConnectorType, FaucetConnectorType, FederatedCatalogueComponentType, HealthComponentType, IdentityComponentType, IdentityConnectorType, IdentityProfileComponentType, IdentityProfileConnectorType, IdentityResolverComponentType, IdentityResolverConnectorType, ImmutableProofComponentType, LoggingComponentType, LoggingConnectorType, MessagingAdminComponentType, MessagingComponentType, MessagingEmailConnectorType, MessagingPushNotificationConnectorType, MessagingSmsConnectorType, MetricsCollectorComponentType, MetricsProducerComponentType, NftComponentType, NftConnectorType, NotarizationComponentType, NotarizationConnectorType, PlatformComponentType, RightsManagementPapComponentType, RightsManagementPdpComponentType, RightsManagementPepComponentType, RightsManagementPipComponentType, RightsManagementPmpComponentType, RightsManagementPnapComponentType, RightsManagementPnpComponentType, RightsManagementPxpComponentType, SchemaVersionMigrationComponentType, TaskSchedulerComponentType, TelemetryComponentType, TelemetryConnectorType, TenantAdminComponentType, TrustComponentType, TrustVerifierComponentType, VaultConnectorType, WalletConnectorType } from "@twin.org/engine-types";
5
+ import { AttestationComponentType, AttestationConnectorType, AuditableItemGraphComponentType, AuditableItemStreamComponentType, AutomationComponentType, BackgroundTaskComponentType, BlobStorageComponentType, BlobStorageConnectorType, ContextIdHandlerComponentType, DataProcessingComponentType, DataspaceControlPlaneComponentType, DataspaceDataPlaneComponentType, DltConfigType, DocumentManagementComponentType, EngineTypeHelper, EntityStorageConnectorType, EventBusComponentType, EventBusConnectorType, FaucetConnectorType, FederatedCatalogueComponentType, HealthComponentType, IdentityComponentType, IdentityConnectorType, IdentityProfileComponentType, IdentityProfileConnectorType, IdentityResolverComponentType, IdentityResolverConnectorType, ImmutableProofComponentType, LoggingComponentType, LoggingConnectorType, MessagingAdminComponentType, MessagingComponentType, MessagingEmailConnectorType, MessagingPushNotificationConnectorType, MessagingSmsConnectorType, MetricsCollectorComponentType, MetricsProducerComponentType, NftComponentType, NftConnectorType, NotarizationComponentType, NotarizationConnectorType, PlatformComponentType, RightsManagementPapComponentType, RightsManagementPdpComponentType, RightsManagementPepComponentType, RightsManagementPipComponentType, RightsManagementPmpComponentType, RightsManagementPnapComponentType, RightsManagementPnpComponentType, RightsManagementPxpComponentType, SchemaVersionMigrationComponentType, TaskSchedulerComponentType, TelemetryComponentType, TelemetryConnectorType, TenantAdminComponentType, TracingComponentType, TracingConnectorType, TrustComponentType, TrustVerifierComponentType, VaultConnectorType, WalletConnectorType } from "@twin.org/engine-types";
6
6
  import { OpenTelemetryExporterTypes } from "@twin.org/logging-connector-opentelemetry";
7
7
  import { OpenTelemetryReaderTypes } from "@twin.org/telemetry-connector-opentelemetry";
8
+ import { OpenTelemetryProcessorTypes } from "@twin.org/tracing-connector-opentelemetry";
8
9
  import { CONTEXT_ID_HANDLER_FEATURE_DID, CONTEXT_ID_HANDLER_FEATURE_TENANT } from "../defaults.js";
9
10
  import { isAuthEntityStorageRequired } from "./engineServerEnvBuilder.js";
10
11
  /**
@@ -42,6 +43,7 @@ export async function buildEngineConfiguration(envVars) {
42
43
  await configureEventBus(coreConfig, envVars);
43
44
  await configureTelemetry(coreConfig, envVars);
44
45
  await configureMetricsCollector(coreConfig, envVars);
46
+ await configureTracing(coreConfig, envVars);
45
47
  await configureMessaging(coreConfig, envVars);
46
48
  await configureAutomation(coreConfig, envVars);
47
49
  await configureHealth(coreConfig, envVars);
@@ -354,7 +356,7 @@ async function configureLogging(coreConfig, envVars) {
354
356
  });
355
357
  additionalConnectorCount++;
356
358
  }
357
- else if (loggingConnector === LoggingConnectorType.Otel) {
359
+ else if (loggingConnector === LoggingConnectorType.OpenTelemetry) {
358
360
  const otelLoggingConfig = {
359
361
  loggerName: envVars.openTelemetryLoggingLoggerName,
360
362
  loggerVersion: envVars.openTelemetryLoggingLoggerVersion
@@ -370,7 +372,7 @@ async function configureLogging(coreConfig, envVars) {
370
372
  };
371
373
  }
372
374
  coreConfig.types.loggingConnector.push({
373
- type: LoggingConnectorType.Otel,
375
+ type: LoggingConnectorType.OpenTelemetry,
374
376
  options: {
375
377
  config: otelLoggingConfig
376
378
  }
@@ -499,7 +501,7 @@ async function configureTelemetry(coreConfig, envVars) {
499
501
  }
500
502
  else if (envVars.telemetryConnector === TelemetryConnectorType.OpenTelemetry) {
501
503
  let readers;
502
- if (envVars.openTelemetryReader === "prometheus") {
504
+ if (envVars.openTelemetryReader === OpenTelemetryReaderTypes.Prometheus) {
503
505
  readers = {
504
506
  prometheus: {
505
507
  type: OpenTelemetryReaderTypes.Prometheus,
@@ -552,6 +554,50 @@ async function configureMetricsCollector(coreConfig, envVars) {
552
554
  }
553
555
  }
554
556
  }
557
+ /**
558
+ * Configures the tracing.
559
+ * @param coreConfig The core config.
560
+ * @param envVars The environment variables.
561
+ * @returns A promise that resolves when the tracing configuration has been applied.
562
+ */
563
+ async function configureTracing(coreConfig, envVars) {
564
+ coreConfig.types.tracingConnector ??= [];
565
+ if (envVars.tracingConnector === TracingConnectorType.EntityStorage) {
566
+ coreConfig.types.tracingConnector.push({
567
+ type: TracingConnectorType.EntityStorage,
568
+ options: {
569
+ config: {
570
+ mutexTimeoutMs: Coerce.integer(envVars.tracingMutexTimeout)
571
+ }
572
+ }
573
+ });
574
+ }
575
+ else if (envVars.tracingConnector === TracingConnectorType.OpenTelemetry) {
576
+ const otelTracingConfig = {
577
+ tracerName: envVars.openTelemetryTracingTracerName,
578
+ tracerVersion: envVars.openTelemetryTracingTracerVersion
579
+ };
580
+ if (Is.stringValue(envVars.openTelemetryTracingEndpoint)) {
581
+ otelTracingConfig.exporters = {
582
+ otlp: {
583
+ endpoint: envVars.openTelemetryTracingEndpoint,
584
+ processor: envVars.openTelemetryTracingProcessor ??
585
+ OpenTelemetryProcessorTypes.Batch
586
+ }
587
+ };
588
+ }
589
+ coreConfig.types.tracingConnector.push({
590
+ type: TracingConnectorType.OpenTelemetry,
591
+ options: {
592
+ config: otelTracingConfig
593
+ }
594
+ });
595
+ }
596
+ if (coreConfig.types.tracingConnector.length > 0) {
597
+ coreConfig.types.tracingComponent ??= [];
598
+ coreConfig.types.tracingComponent.push({ type: TracingComponentType.Service });
599
+ }
600
+ }
555
601
  /**
556
602
  * Configures the automation.
557
603
  * @param coreConfig The core config.
@@ -590,6 +636,7 @@ async function configureHealth(coreConfig, envVars) {
590
636
  options: {
591
637
  config: {
592
638
  healthCheckInterval: (Coerce.integer(envVars.healthInterval) ?? 60) * 1000,
639
+ healthCheckApplicationInterval: (Coerce.integer(envVars.healthApplicationInterval) ?? 300) * 1000,
593
640
  initialInterval: (Coerce.integer(envVars.healthStartupInterval) ?? 2) * 1000
594
641
  }
595
642
  },
@@ -766,13 +813,14 @@ async function configureFaucet(coreConfig, envVars) {
766
813
  type: FaucetConnectorType.EntityStorage
767
814
  });
768
815
  }
769
- else if (envVars.faucetConnector === FaucetConnectorType.Iota) {
816
+ else if (envVars.faucetConnector === FaucetConnectorType.Iota &&
817
+ Is.stringValue(envVars.iotaFaucetEndpoint)) {
770
818
  const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
771
819
  coreConfig.types.faucetConnector.push({
772
820
  type: FaucetConnectorType.Iota,
773
821
  options: {
774
822
  config: {
775
- endpoint: envVars.iotaFaucetEndpoint ?? "",
823
+ endpoint: envVars.iotaFaucetEndpoint,
776
824
  clientOptions: dltConfig?.options?.config?.clientOptions ?? { url: "" },
777
825
  network: dltConfig?.options?.config?.network ?? ""
778
826
  }
@@ -1479,7 +1527,8 @@ export function isTaskSchedulerRequired(envVars) {
1479
1527
  return ((Coerce.boolean(envVars.taskSchedulerEnabled) ?? false) ||
1480
1528
  (Coerce.boolean(envVars.dataspaceEnabled) ?? false) ||
1481
1529
  isRightsManagementRequired(envVars) ||
1482
- isAuthEntityStorageRequired(envVars));
1530
+ isAuthEntityStorageRequired(envVars) ||
1531
+ isImmutableProofRequired(envVars));
1483
1532
  }
1484
1533
  /**
1485
1534
  * Checks if the automation subsystem is required.