From a28bcb6292d3d6bdeb9870209c3d8c1047d21f2c Mon Sep 17 00:00:00 2001 From: KishenKumarrrrr Date: Mon, 25 Nov 2024 16:52:00 +0800 Subject: [PATCH] chore: fix span --- backend/src/email/utils/callback/parsers/ses.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/src/email/utils/callback/parsers/ses.ts b/backend/src/email/utils/callback/parsers/ses.ts index 4b39943ff..c4f995686 100644 --- a/backend/src/email/utils/callback/parsers/ses.ts +++ b/backend/src/email/utils/callback/parsers/ses.ts @@ -136,8 +136,13 @@ const shouldBlacklist = ({ const parseNotificationAndEvent = async ( type: SesEventType, message: any, - metadata: Metadata + metadata: Metadata, + parentSpan?: tracer.Span ): Promise => { + const parseNotificationAndEventSpan = tracer.startSpan( + 'parseNotificationAndEvent', + { childOf: parentSpan } + ) if (!isNotificationAndEventForMainRecipient(message, type)) { logger.info({ message: 'SES notification or event is not for the main recipient', @@ -177,6 +182,7 @@ const parseNotificationAndEvent = async ( }) return } + parseNotificationAndEventSpan.finish() } // Validate SES record hash, returns message ID if valid, otherwise throw errors @@ -275,9 +281,7 @@ const parseRecord = async (record: SesRecord): Promise => { parseRecordSpan ) } - return tracer.wrap('parseNotificationAndEvent', () => - parseNotificationAndEvent(type, message, metadata) - )() + return parseNotificationAndEvent(type, message, metadata, parseRecordSpan) } parseRecordSpan.finish() }