-
Notifications
You must be signed in to change notification settings - Fork 38
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
Implement batching of emails #6
Conversation
… time and max count.
…e/batched-emails Conflicts: src/Seq.App.EmailPlus/EmailReactor.cs
…q server to create an instance of an app.
…ed by the class does not show up in the Seq UI which would be confusing.
…oes not fit well in the Seq UI.
Wow - that's a pretty impressive changeset! :-) I would guess the downsides might be:
But the upsides are pretty great - I can imagine this making the email app applicable to a significantly wider range of scenarios. Whether we ship this as an updated Email+ or initially as a variation (Batched Email?) it'd be great to see this out there. Thanks very much for sending the PR! Cheers, |
So far this seems to be working well on our production Seq server which is a t2.small instance at AWS. I've got it set to email everything that is at least level Warning. That isn't my long term plan, but I'm using it to help transition people who are used to everything landing directly in their inbox. So far about 2k events have been sent through this version of the plugin. Memory use is for sure a concern if you set it with large max value for batch size or delay, or if you have an extreme number of events going through it. I've been testing it with a batch delay of 60s, max delay of 300s, and max size of 50. |
Our production Seq server crashed today, and after investigating it looks like the source of it was an SmtpException thrown from this app. There was not any exception handling in the original app so I had left it that way assuming the Seq server would catch the exceptions. However, based on what happened today I decided to go in and wrap the message send with a try/catch to handle that case. Is it expected that exceptions from a seq-app can bring down the entire Seq server? It doesn't seem like that should be the case. If so, I probably need to add a lot more error handling to this. :) |
Interesting - thanks for the info! Do you still have a stack trace handy? All of the code in the Seq server that interacts with user apps does it in a sandboxed app domain, with In practice, there are probably still some holes - I'm guessing this one may have been an unhandled exception on a threapool thread or within a task. The trace should shine a light on it :-) |
Sorry it took a few days, but here is the stack trace finally.
|
Thanks for the additional info. At first glance, it doesn't seem like there's a lot we can do in the host to prevent unhandled exceptions in the app from bringing it down (since this one is on a task-pool thread and not one we can wrap a try/catch block around). Will investigate options further. I take it you've been able to handle this successfully in the app itself now? Thanks again! |
So far so good, just that one crash ever. I added a try catch with commit https://github.com/kll/seq-apps/commit/46fc29ab4540d4d231b705e5381b5593b6ba0892 and deployed that and nothing else since. |
Hi Kevin! Unfortunately I think I dropped the ball on this one. The codebase has moved on quite a bit in the year since we were on this thread; I've just posted a very, very basic implementation of batched email to: https://github.com/datalust/seq-app-digestemail. It could use some improvement but I needed to scratch an itch and decided to try doing it with the least possible changes atop Email+. If you're keen to check it out there's a package on NuGet, but I gather you're getting along fine with this implementation :-) Just thought I'd send a heads-up; it's probably time we closed this one. Cheers, |
This is a significant change, and is essentially untested on a real Seq server. I did add unit tests, and it looks ok as far as I can tell, but I will hook it up to a real server and test it out over the next few days. I wanted to go ahead and send a PR now to get some feedback. Not only is it significantly different, but it is also not backwards compatible with templates for previous versions due to having an array of events rather than a single event. For those reasons I was not sure about modifying the existing Email+ app versus creating a new separate app. If you would rather it be a different app, let me know and I'll update this PR.
It should work essentially the same as before with one email per event if you do not configure any of the new settings. If you set a delay, then it will start a batch of events based on the templated subject. As long a new event arrives once every delay period, it will keep waiting and add that event to the batch. Once a full delay period has elapsed, or the max delay or max event count has been reached it will construct an email with the details of each event in the body and send it.
Let me know what you think. I'll post a note here after I'm done testing it out and am confident it is working correctly.