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

Feature Request: Improve observability #273

Open
sapmli opened this issue Sep 19, 2024 · 0 comments
Open

Feature Request: Improve observability #273

sapmli opened this issue Sep 19, 2024 · 0 comments

Comments

@sapmli
Copy link
Contributor

sapmli commented Sep 19, 2024

We would like to improve our monitoring and error handling, especially for those cases which do not reach the backend session.

For example, we would like to expose the number of currently connected clients to Prometheus, to better understand load and idle times. But s.conns is an internal field, which we cannot grab during the NewSession(c *smtp.Conn) (smtp.Session, error) call.
It would be great to have a method like this:

// Len returns the number of active connections.
func (s *Server) Len() int {
	s.locker.Lock()
	defer s.locker.Unlock()

	return len(s.conns)
}

The other thing is that, before the session is created, there is nothing we can do to identify a client connection.
For example, there's no possibility to capture clients which do connect, timeout, and disconnect to whole time.
We would like to trace such cases, in order to help users debug and fix setup problems, e.g. a missing proxy protocol or broken TLS certificate or whatever might be in the way, before the session is established.

For this, it would be great to add a connection ID as public field in the Conn struct. It should be generated as soon as the connection is accepted. Maybe something like a UUID or the format postfix uses as queue ID.
MTAs usually log connect/disconnect events like [<conn-id>] connect from <hostname>[<ip-addr:port>], which is currently not possible. So, additionally to adding the connection ID, it would be great to either make go-smtp log that itself, or offer a logging hook, or to enhance the existing ErrorLog hook to also support connect and disconnect events.
Also, all log lines sent to the ErrorLog should be enriched by the connection ID.

I'm looking forward to hear your opinion about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant