Class GrpcConnectionMetrics


  • public class GrpcConnectionMetrics
    extends Object
    A holder for gRPC connection metrics.

    This is a singleton so that one instance can track all connections in a process.

    Because there is no way to actually track gRPC connections this holder tracks them using the remote address in the request header, so each unique address is a connection.

    As there is no tracking of connection closed the connection metrics will expire and be removed after a period of inactivity. The default is five minutes, but this may be changed using the PROP_CONNECTION_TTL system property.

    Author:
    Jonathan Knight 2020.10.16
    • Field Detail

      • PROP_CONNECTION_TTL

        public static final String PROP_CONNECTION_TTL
        The system property used to set the expiry time used to evict connection MBeans when connections have had no activity for a period of time.
        See Also:
        Constant Field Values
    • Method Detail

      • register

        public void register​(io.grpc.ServerCall<?,​?> call)
        Register a ServerCall with the connection metrics, creating a new connection metric if this call is from a new remote address.
        Parameters:
        call - the ServerCall to register