Skip to content

Commit

Permalink
refactor: use tracer.wrap for parseNotficationAndEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
KishenKumarrrrr committed Nov 25, 2024
1 parent 8273ca2 commit 5d07b87
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions backend/src/email/utils/callback/parsers/ses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,8 @@ const shouldBlacklist = ({
const parseNotificationAndEvent = async (
type: SesEventType,
message: any,
metadata: Metadata,
parentSpan?: tracer.Span
metadata: Metadata
): Promise<void> => {
const parseNotificationAndEventSpan = tracer.startSpan(
'parseNotificationAndEvent',
{
childOf: parentSpan,
}
)
if (!isNotificationAndEventForMainRecipient(message, type)) {
logger.info({
message: 'SES notification or event is not for the main recipient',
Expand Down Expand Up @@ -184,7 +177,6 @@ const parseNotificationAndEvent = async (
})
return
}
parseNotificationAndEventSpan.finish()
}

// Validate SES record hash, returns message ID if valid, otherwise throw errors
Expand Down Expand Up @@ -283,7 +275,9 @@ const parseRecord = async (record: SesRecord): Promise<void> => {
parseRecordSpan
)
}
return parseNotificationAndEvent(type, message, metadata, parseRecordSpan)
return tracer.wrap('parseNotificationAndEvent', () =>
parseNotificationAndEvent(type, message, metadata)
)()
}
parseRecordSpan.finish()
}
Expand Down

0 comments on commit 5d07b87

Please sign in to comment.