Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adding logger for undefined source event #3879

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/controllers/source.ts
shrouti1507 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,27 @@
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);
sanpj2292 marked this conversation as resolved.
Show resolved Hide resolved
const integrationService = ServiceSelector.getNativeSourceService();

try {
Expand All @@ -28,6 +42,7 @@
);
ctx.body = resplist;
} catch (err: any) {
shrouti1507 marked this conversation as resolved.
Show resolved Hide resolved
logger.error(err?.message || 'error in source transformation', enrichedMetadata);
const metaTO = integrationService.getTags();
const resp = SourcePostTransformationService.handleFailureEventsSource(err, metaTO);
ctx.body = [resp];
Expand Down
Loading