Class OAuthMetrics

java.lang.Object
io.strimzi.kafka.oauth.services.OAuthMetrics

public class OAuthMetrics extends Object
The singleton for handling a cache of all the Sensors to prevent unnecessary redundant re-registrations. There is a one-to-one mapping between a SensorKey and a Sensor, and one-to-one mapping between a Sensor and an MBean name.

MBeans are registered as requested by JmxReporter attached to the Metrics object. The JmxReporter either has to be explicitly configured using a config option strimzi.oauth.metric.reporters, or if that config option si not set, a new instance is configured by default.

Since OAuth instantiates its own Metrics object it also has to instantiate reporters to attach them to this Metrics object. To prevent double instantiation of MetricReporter objects that require to be singleton, all MetricReporter objects to be integrated with OAuthMetrics have to be separately instantiated.

Example 1:

    strimzi.oauth.metric.reporters=org.apache.kafka.common.metrics.JmxReporter,org.some.package.SomeMetricReporter
 
The above will instantiate and integrate with OAuth metrics the JmxReporter instance, and a SomeMetricReporter instance.

Example 2:

    strimzi.oauth.metric.reporters=
 
The above will not instantiate and integrate any metric reporters with OAuth metrics, not even JmxReporter.

Note: On the Kafka broker it is best to use STRIMZI_OAUTH_METRIC_REPORTERS env variable or strimzi.oauth.metric.reporters system property, rather than a `server.properties` global configuration option.

  • Method Details

    • addTime

      public void addTime(SensorKey key, long timeMs)
      Record a request time in millis.
      Parameters:
      key - SensorKey identifying the sensor
      timeMs - Time spent processing the request in millis