feat(mail): SMTP code + retryable attrs on gomailer.send spans - #796
Draft
shyim wants to merge 1 commit into
Draft
feat(mail): SMTP code + retryable attrs on gomailer.send spans#796shyim wants to merge 1 commit into
shyim wants to merge 1 commit into
Conversation
Enrich gomailer.send OpenTelemetry spans with low-cardinality messaging.gomailer.smtp_code and mail.retryable so Datadog can alert on SES soft failures (e.g. 451) without recipient/subject cardinality. Co-authored-by: Soner <github@shyim.de>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Production SES failures show up as generic
gomailer.senderror spans (451 4.4.2 Timeout waiting for data from client) with no structured way to filter soft vs hard SMTP failures in Datadog (see #790). Outcome counters from #793 help at the metric layer; this PR adds span attributes so APM queries can alert on SES 451 specifically without high-cardinality recipient data.What
On each instrumented send attempt, when the error wraps
*gomailer.TransportErrorwith an SMTP code:messaging.gomailer.smtp_code451) — extends existing otelmwmessaging.gomailer.*attrsmail.retryabletruefor 4xx soft failures;falsefor 5xx permanentWiring:
AfterSendmiddleware sits insideotelmwso attributes attach to the still-opengomailer.sendspan (otelmw already setsmessaging.gomailer.outcome).Not attached: recipient email, subject, or body.
Classification:
IsRetryableSMTPCodetreats400–499as retryable and5xxas not (RFC 5321 transient vs permanent). Span status remains Error for now; this stands alone from any future error-taxonomy work.Sample Datadog queries
SES 451 rate (APM spans):
Retryable soft failures only:
Monitor idea: alert when count of
@messaging.gomailer.smtp_code:451over a 15m window exceeds a threshold relative to successfulmessaging.gomailer.outcome:success(or useshopmon.mail.send{outcome}from #793 for cheaper volume, and this attr for code breakdown).Test plan
gomailer.sendvia otelmw + AfterSend)mise run lint(local + CI)mise run test(CI Lint and Test green)