Skip to content

Commit

Permalink
chore: move span to top level
Browse files Browse the repository at this point in the history
  • Loading branch information
KishenKumarrrrr committed Nov 25, 2024
1 parent a28bcb6 commit ab35496
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 5 additions & 0 deletions backend/src/email/services/email-callback.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ const parseEvent = async (req: Request): Promise<void> => {
} else {
throw new Error('Unable to handle this event')
}
const parseNotificationAndEventSpan = tracer.startSpan(
'parseNotificationAndEvent',
{ childOf: parseJsonSpan }
)
await Promise.all(records)
parseNotificationAndEventSpan.finish()
}
export const EmailCallbackService = { isAuthenticated, parseEvent }
10 changes: 2 additions & 8 deletions backend/src/email/utils/callback/parsers/ses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +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 @@ -182,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 @@ -281,7 +275,7 @@ const parseRecord = async (record: SesRecord): Promise<void> => {
parseRecordSpan
)
}
return parseNotificationAndEvent(type, message, metadata, parseRecordSpan)
return parseNotificationAndEvent(type, message, metadata)
}
parseRecordSpan.finish()
}
Expand Down

0 comments on commit ab35496

Please sign in to comment.