Skip to content

Commit 31b0eed

Browse files
authored
fix: add more mail ervice traces (#10438)
1 parent c1f1675 commit 31b0eed

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

services/mail/pod-mail/src/mail.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,16 @@ export class MailClient {
4747
async sendMessage (message: SendMailOptions, ctx: MeasureContext, password?: string | undefined): Promise<void> {
4848
const from = message.from as string
4949
const transporter = this.getTransporter(from, password)
50-
transporter.sendMail(message, (err, info) => {
51-
const messageInfo = `(from: ${from}, to: ${message.to as string})`
52-
if (err !== null) {
53-
ctx.error(`Failed to send email ${messageInfo}: ${err.message}`)
54-
Analytics.handleError(err)
55-
} else {
56-
ctx.info(`Email request ${messageInfo} sent: ${info?.response}`)
57-
}
50+
await ctx.with('send', {}, async (ctx) => {
51+
transporter.sendMail(message, (err, info) => {
52+
const messageInfo = `(from: ${from}, to: ${message.to as string})`
53+
if (err !== null) {
54+
ctx.error(`Failed to send email ${messageInfo}: ${err.message}`)
55+
Analytics.handleError(err)
56+
} else {
57+
ctx.info(`Email request ${messageInfo} sent: ${info?.response}`)
58+
}
59+
})
5860
})
5961
}
6062

services/mail/pod-mail/src/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ export const main = async (): Promise<void> => {
5252
endpoint: '/send',
5353
type: 'post',
5454
handler: async (req, res) => {
55-
await handleSendMail(client, req, res, measureCtx)
55+
const { to } = req.body
56+
await measureCtx.with('send email', {}, (ctx) => handleSendMail(client, req, res, ctx), { to })
5657
}
5758
}
5859
]

0 commit comments

Comments
 (0)