Class MetricsUtil

java.lang.Object
io.strimzi.kafka.oauth.metrics.MetricsUtil

public class MetricsUtil extends Object
Static utility methods used for metrics
  • Constructor Details

    • MetricsUtil

      public MetricsUtil()
  • Method Details

    • getSensorKeyAttrs

      public static Map<String,String> getSensorKeyAttrs(String contextId, String mechanism, URI uri, String kind)
      Get the attributes for the sensor key using passed info.
      Parameters:
      contextId - a contextId
      mechanism - a SASL authentication mechanism used
      uri - a URI associated with the sensor
      kind - a 'kind' for the sensor
      Returns:
      The map of attributes for the SensorKey
    • getSensorKeyAttrs

      public static Map<String,String> getSensorKeyAttrs(String contextId, URI uri, String kind)
      Get the attributes for the sensor key using passed info
      Parameters:
      contextId - a contextId
      uri - a URI associated with the sensor
      kind - a 'kind' for the sensor
      Returns:
      The map of attributes for the SensorKey
    • addHttpSuccessAttrs

      public static Map<String,String> addHttpSuccessAttrs(Map<String,String> attrs)
      Add http success attributes to the passed map of attributes
      Parameters:
      attrs - A target attributes map
      Returns:
      The passed attributes map
    • addHttpErrorAttrs

      public static Map<String,String> addHttpErrorAttrs(Map<String,String> attrs, Throwable ex)
      Add http error attributes to the passed map of attributes
      Parameters:
      attrs - A target attributes map
      ex - The exception that occurred
      Returns:
      The passed attributes map
    • pathAttr

      public static String pathAttr(URI uri)
      Resolve the raw path of the passed url
      Parameters:
      uri - a URI object
      Returns:
      The path component of the URI
    • hostAttr

      public static String hostAttr(URI uri)
      Extract the hostname:port from the passed url For 'http' protocol use port 80 as the default. For 'https' protocol use port 443 as the default.
      Parameters:
      uri - the URI object
      Returns:
      The hostname:port