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() }