Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Email Observability in Spring Framework #34496

Closed
famaridon opened this issue Feb 26, 2025 · 8 comments
Closed

Improve Email Observability in Spring Framework #34496

famaridon opened this issue Feb 26, 2025 · 8 comments
Labels
for: external-project Needs a fix in external project status: declined A suggestion or change that we don't feel we should currently apply theme: observability An issue related to observability and tracing

Comments

@famaridon
Copy link

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!


@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 26, 2025
@bclozel
Copy link
Member

bclozel commented Feb 26, 2025

That's something we could look into.
Are you aware of existing instrumentations or semantic conventions for this?
I'm wondering if this couldn't be just like JMS: an instrumentation at the jakarta.mail level that could be contributed to Micrometer directly.

@bclozel bclozel added the status: waiting-for-feedback We need additional information before we can continue label Feb 26, 2025
@famaridon
Copy link
Author

I found nothing about mail/SMTP in the semantic conventions. I will create an issue on the OpenTelemetry side.

It might be nice to add this to Micrometer. I will check how it works and test it.

Is it something like this? Micrometer Jakarta9 JMS Instrumentation

@bclozel
Copy link
Member

bclozel commented Feb 27, 2025

@famaridon

I found nothing about mail/SMTP in the semantic conventions. I will create an issue on the OpenTelemetry side.

Thanks! Please share the link here.

Is it something like this? Micrometer Jakarta9 JMS Instrumentation

Yes, but proxying in this case might not be required, it all depends on what should be instrumented and how.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Feb 27, 2025
@famaridon
Copy link
Author

@bclozel I think I need proxying the Session and the Transport to be able to catch calls to transport.sendMessage()

@bclozel
Copy link
Member

bclozel commented Feb 27, 2025

Thanks @famaridon . I'll leave this opened for now but I will probably close it as soon as the OTel and Micrometer issues are created.

@bclozel bclozel added status: waiting-for-feedback We need additional information before we can continue theme: observability An issue related to observability and tracing and removed status: feedback-provided Feedback has been provided labels Feb 27, 2025
@famaridon
Copy link
Author

Opentelemtry request open-telemetry/semantic-conventions#1945

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Feb 27, 2025
@bclozel
Copy link
Member

bclozel commented Feb 28, 2025

If anyone here is interested in this feature, they should raise a new issue or PR to Micrometer directly as instrumentation probably needs to happen at the jakarta.mail level.

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Feb 28, 2025
@bclozel bclozel added status: declined A suggestion or change that we don't feel we should currently apply for: external-project Needs a fix in external project and removed status: waiting-for-triage An issue we've not yet triaged or decided on status: feedback-provided Feedback has been provided labels Feb 28, 2025
@famaridon
Copy link
Author

Link to micrometer issue micrometer-metrics/micrometer#5985

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project Needs a fix in external project status: declined A suggestion or change that we don't feel we should currently apply theme: observability An issue related to observability and tracing
Projects
None yet
Development

No branches or pull requests

3 participants