armeria icon indicating copy to clipboard operation
armeria copied to clipboard

Provide better observability into `KeepAliveHandler`

Open jrhee17 opened this issue 1 month ago • 2 comments

I propose that better observability is offered for KeepAliverHandler.

While users can check logs to verify why a connection was closed, it may be easier to export this in some other way (e.g. metrics) so that users can easily verify/monitor changes.

I propose an API like the following is added to the ConnectionPoolListener API

    enum CloseReason {
        PING_TIMEOUT,
        CONNECTION_IDLE,
        MAX_CONNECTION_AGE,
        UNKNOWN,
    }

    default void onCloseEvent(SessionProtocol protocol,
                              Channel channel,
                              CloseReason reason) {}

    default void onPingSent(SessionProtocol protocol,
                            Channel channel,
                            long data) {}

    default void onPingReceived(SessionProtocol protocol,
                                Channel channel,
                                long data) {}

ref: https://github.com/jrhee17/armeria/tree/poc/keepalive-observe ref: https://discord.com/channels/1087271586832318494/1445319892076200057

@yzfeng2020

Also pinging @line/dx for thoughts/design review

jrhee17 avatar Dec 04 '25 10:12 jrhee17

I agree with the overall direction.

ikhoon avatar Dec 05 '25 01:12 ikhoon

thanks for it, I like it as well!

yzfeng2020 avatar Dec 08 '25 02:12 yzfeng2020