Skip to content

Commit

Permalink
chore: enrich metadata, update error msg in logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Sai Sankeerth committed Nov 18, 2024
1 parent ba0b666 commit 5e56d4d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/controllers/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Check warning on line 13 in src/controllers/source.ts

View check run for this annotation

Codecov / codecov/patch

src/controllers/source.ts#L13

Added line #L13 was not covered by tests
) {
return {

Check warning on line 15 in src/controllers/source.ts

View check run for this annotation

Codecov / codecov/patch

src/controllers/source.ts#L15

Added line #L15 was not covered by tests
...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 {
Expand All @@ -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];
Expand Down

0 comments on commit 5e56d4d

Please sign in to comment.