Skip to content

Improve Email Observability in Spring Framework #34496

@famaridon

Description

@famaridon

Hello,

I am using Spring Boot with Micrometer to monitor my application. Everything works well except for email monitoring. The JavaMailSenderImpl class does not support observation.

I created a decorator to solve this issue, but it's not perfect. I had to bridge the send(MimeMessage... mimeMessages) method to the send(MimeMessage mimeMessage) method. This has the side effect of reopening the Transport for each MimeMessage.

Before submitting a pull request, I would like to discuss two possible solutions with you:

Option 1: Register TransportListener

  • Add the ability to register a TransportListener for all created Transport objects.
  • Pros:
    • Useful for metrics: We can count delivered, not delivered, and partially delivered messages.
    • Spring does not need to add a custom class to support this.
  • Cons:
    • Not useful for tracing: We cannot surround the network call.

Option 2: New MailSendListener Interface

  • Create a new interface, MailSendListener, dedicated to mail observations, similar to Spring Data MongoDB.
  • Pros:
    • Useful for metrics: We can count delivered, not delivered, and partially delivered messages.
    • Useful for tracing: We can surround the network call.
  • Cons:
    • Spring needs to add a custom interface to support this.

Please let me know your thoughts on these options.

Thank you!


Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectNeeds a fix in external projectstatus: declinedA suggestion or change that we don't feel we should currently applytheme: observabilityAn issue related to observability and tracing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions