From cbec73151770c1f3de2dd9ede5e5596b0580c862 Mon Sep 17 00:00:00 2001 From: shrouti1507 Date: Fri, 15 Nov 2024 12:01:50 +0530 Subject: [PATCH 1/4] fix: adding logger for undefined source event --- src/controllers/source.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/controllers/source.ts b/src/controllers/source.ts index 8b6d2d70f8..cdd8ba281e 100644 --- a/src/controllers/source.ts +++ b/src/controllers/source.ts @@ -28,6 +28,11 @@ export class SourceController { ); ctx.body = resplist; } catch (err: any) { + logger.error(`[source transformation] ${err?.message || 'error in source transformation'}`, { + source, + version, + events, + }); const metaTO = integrationService.getTags(); const resp = SourcePostTransformationService.handleFailureEventsSource(err, metaTO); ctx.body = [resp]; From ba0b666127d00f840fe735b982bda862d8f312c3 Mon Sep 17 00:00:00 2001 From: shrouti1507 Date: Mon, 18 Nov 2024 11:42:58 +0530 Subject: [PATCH 2/4] fix: review comment addressed --- src/controllers/source.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/controllers/source.ts b/src/controllers/source.ts index cdd8ba281e..ca9383367a 100644 --- a/src/controllers/source.ts +++ b/src/controllers/source.ts @@ -31,7 +31,6 @@ export class SourceController { logger.error(`[source transformation] ${err?.message || 'error in source transformation'}`, { source, version, - events, }); const metaTO = integrationService.getTags(); const resp = SourcePostTransformationService.handleFailureEventsSource(err, metaTO); From 5e56d4ddf3ae986a76b87ea4e8a361550d2028b9 Mon Sep 17 00:00:00 2001 From: Sai Sankeerth Date: Mon, 18 Nov 2024 12:03:32 +0530 Subject: [PATCH 3/4] chore: enrich metadata, update error msg in logger --- src/controllers/source.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/controllers/source.ts b/src/controllers/source.ts index ca9383367a..49e592fa7a 100644 --- a/src/controllers/source.ts +++ b/src/controllers/source.ts @@ -4,13 +4,27 @@ import { MiscService } from '../services/misc'; import { SourcePostTransformationService } from '../services/source/postTransformation'; import { ControllerUtility } from './util'; import logger from '../logger'; +import { FixMe } from '../util/types'; export class SourceController { + private static enrichMetadata( + metadata: { namespace: string; cluster: string; features: FixMe }, + source: string, + version: string, + ) { + return { + ...metadata, + source, + version, + }; + } + public static async sourceTransform(ctx: Context) { logger.debug('Native(Source-Transform):: Request to transformer::', ctx.request.body); const requestMetadata = MiscService.getRequestMetadata(ctx); const events = ctx.request.body as object[]; const { version, source }: { version: string; source: string } = ctx.params; + const enrichedMetadata = this.enrichMetadata(requestMetadata, source, version); const integrationService = ServiceSelector.getNativeSourceService(); try { @@ -28,10 +42,7 @@ export class SourceController { ); ctx.body = resplist; } catch (err: any) { - logger.error(`[source transformation] ${err?.message || 'error in source transformation'}`, { - source, - version, - }); + logger.error(err?.message || 'error in source transformation', enrichedMetadata); const metaTO = integrationService.getTags(); const resp = SourcePostTransformationService.handleFailureEventsSource(err, metaTO); ctx.body = [resp]; From 68404c17a59871f0a91d3c58a79549bd7a2443ed Mon Sep 17 00:00:00 2001 From: Sai Sankeerth Date: Mon, 18 Nov 2024 13:16:47 +0530 Subject: [PATCH 4/4] chore: code review updates --- src/controllers/source.ts | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/controllers/source.ts b/src/controllers/source.ts index 49e592fa7a..3d9fa4f4a4 100644 --- a/src/controllers/source.ts +++ b/src/controllers/source.ts @@ -4,27 +4,18 @@ import { MiscService } from '../services/misc'; import { SourcePostTransformationService } from '../services/source/postTransformation'; import { ControllerUtility } from './util'; import logger from '../logger'; -import { FixMe } from '../util/types'; export class SourceController { - private static enrichMetadata( - metadata: { namespace: string; cluster: string; features: FixMe }, - source: string, - version: string, - ) { - return { - ...metadata, - source, - version, - }; - } - public static async sourceTransform(ctx: Context) { logger.debug('Native(Source-Transform):: Request to transformer::', ctx.request.body); const requestMetadata = MiscService.getRequestMetadata(ctx); const events = ctx.request.body as object[]; const { version, source }: { version: string; source: string } = ctx.params; - const enrichedMetadata = this.enrichMetadata(requestMetadata, source, version); + const enrichedMetadata = { + ...requestMetadata, + source, + version, + }; const integrationService = ServiceSelector.getNativeSourceService(); try {