Class ConnectionInformationSensors

java.lang.Object
io.confluent.kafka.multitenant.metrics.ConnectionInformationSensors

public class ConnectionInformationSensors extends Object
A per-connection sensor manager to manage the lifecycles of the connection_info metrics. This class is safe to used by different network threads during the processing of multiple connections.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConnectionInformationSensors(org.apache.kafka.common.metrics.Metrics metrics, io.confluent.kafka.multitenant.MultiTenantPrincipal principal, org.apache.kafka.common.network.ClientInformation clientInformation, String clientId, int maxConnectionInfoMetricsPerTenant)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.kafka.common.metrics.Sensor
    Gets or Creates a Sensor and record the new authenticated connection to emit the connection information as the tags of a KafkaMetric.
    org.apache.kafka.common.metrics.Sensor
    Reduces the number of authenticated connection sharing the same connection information by one if the corresponding metric exists.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ConnectionInformationSensors

      public ConnectionInformationSensors(org.apache.kafka.common.metrics.Metrics metrics, io.confluent.kafka.multitenant.MultiTenantPrincipal principal, org.apache.kafka.common.network.ClientInformation clientInformation, String clientId, int maxConnectionInfoMetricsPerTenant)
  • Method Details

    • recordAuthenticatedConnection

      public org.apache.kafka.common.metrics.Sensor recordAuthenticatedConnection()
      Gets or Creates a Sensor and record the new authenticated connection to emit the connection information as the tags of a KafkaMetric. The value of the metric stat is the number of authenticated connection sharing the same connection info, such as client software name/version and client id. The number of unique connection info metric per tenant is subject to a pre-defined cap as
      invalid @link
      {@link this#maxConnectionInfoMetricsPerTenant
      } to prevent memory exhaustion in the case of clients creating connections with different client ids continuously.
      Returns:
      the Sensor to emit connection information or null if the cap is reached
    • recordAuthenticatedDisconnection

      public org.apache.kafka.common.metrics.Sensor recordAuthenticatedDisconnection()
      Reduces the number of authenticated connection sharing the same connection information by one if the corresponding metric exists. If the number of authenticated connections reaches zero, remove the connection info Sensor and its associated metrics to stop emitting them.
      Returns:
      the Sensor to emit the connection information or null if the sensor is removed/doesn't exist