From a0e523e64c14641c0ac9774d3bc775217eff64be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Wed, 3 Jan 2024 10:41:26 +0100 Subject: [PATCH] fix(syncing-server): add opentelemetry sdk shutdown --- .../src/Infra/OpenTelemetry/OpenTelemetrySDK.ts | 4 ++++ .../src/Infra/OpenTelemetry/OpenTelemetrySDKInterface.ts | 1 + packages/syncing-server/bin/server.ts | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/packages/domain-events-infra/src/Infra/OpenTelemetry/OpenTelemetrySDK.ts b/packages/domain-events-infra/src/Infra/OpenTelemetry/OpenTelemetrySDK.ts index c470f5a79..d7048769a 100644 --- a/packages/domain-events-infra/src/Infra/OpenTelemetry/OpenTelemetrySDK.ts +++ b/packages/domain-events-infra/src/Infra/OpenTelemetry/OpenTelemetrySDK.ts @@ -98,4 +98,8 @@ export class OpenTelemetrySDK implements OpenTelemetrySDKInterface { start(): void { this.sdk.start() } + + async shutdown(): Promise { + await this.sdk.shutdown() + } } diff --git a/packages/domain-events-infra/src/Infra/OpenTelemetry/OpenTelemetrySDKInterface.ts b/packages/domain-events-infra/src/Infra/OpenTelemetry/OpenTelemetrySDKInterface.ts index 73b890e88..20c719c44 100644 --- a/packages/domain-events-infra/src/Infra/OpenTelemetry/OpenTelemetrySDKInterface.ts +++ b/packages/domain-events-infra/src/Infra/OpenTelemetry/OpenTelemetrySDKInterface.ts @@ -1,3 +1,4 @@ export interface OpenTelemetrySDKInterface { start(): void + shutdown(): Promise } diff --git a/packages/syncing-server/bin/server.ts b/packages/syncing-server/bin/server.ts index 93b667282..beab82f7a 100644 --- a/packages/syncing-server/bin/server.ts +++ b/packages/syncing-server/bin/server.ts @@ -146,6 +146,14 @@ void container.load().then((container) => { logger.info('gRPC server closed') } }) + sdk + .shutdown() + .then(() => { + logger.info('OpenTelemetry SDK shut down') + }) + .catch((error) => { + logger.error(`Failed to shut down OpenTelemetry SDK: ${error.message}`) + }) }) logger.info(`Server started on port ${process.env.PORT}`)