Class CassandraMetricsRegistry.MetricName

java.lang.Object
org.apache.cassandra.metrics.CassandraMetricsRegistry.MetricName
All Implemented Interfaces:
Comparable<CassandraMetricsRegistry.MetricName>
Enclosing class:
CassandraMetricsRegistry

public static class CassandraMetricsRegistry.MetricName extends Object implements Comparable<CassandraMetricsRegistry.MetricName>
A value class encapsulating a metric's owning class and name.
  • Constructor Details

    • MetricName

      public MetricName(Class<?> klass, String name)
      Creates a new CassandraMetricsRegistry.MetricName without a scope.
      Parameters:
      klass - the Class to which the Metric belongs
      name - the name of the Metric
    • MetricName

      public MetricName(String group, String type, String name)
      Creates a new CassandraMetricsRegistry.MetricName without a scope.
      Parameters:
      group - the group to which the Metric belongs
      type - the type to which the Metric belongs
      name - the name of the Metric
    • MetricName

      public MetricName(Class<?> klass, String name, String scope)
      Creates a new CassandraMetricsRegistry.MetricName without a scope.
      Parameters:
      klass - the Class to which the Metric belongs
      name - the name of the Metric
      scope - the scope of the Metric
    • MetricName

      public MetricName(String group, String type, String name, String scope)
      Creates a new CassandraMetricsRegistry.MetricName without a scope.
      Parameters:
      group - the group to which the Metric belongs
      type - the type to which the Metric belongs
      name - the name of the Metric
      scope - the scope of the Metric
    • MetricName

      public MetricName(String group, String type, String name, String scope, String mBeanName)
      Creates a new CassandraMetricsRegistry.MetricName without a scope.
      Parameters:
      group - the group to which the Metric belongs
      type - the type to which the Metric belongs
      name - the name of the Metric
      scope - the scope of the Metric
      mBeanName - the 'ObjectName', represented as a string, to use when registering the MBean.
  • Method Details

    • getGroup

      public String getGroup()
      Returns the group to which the Metric belongs. For class-based metrics, this will be the package name of the Class to which the Metric belongs.
      Returns:
      the group to which the Metric belongs
    • getType

      public String getType()
      Returns the type to which the Metric belongs. For class-based metrics, this will be the simple class name of the Class to which the Metric belongs.
      Returns:
      the type to which the Metric belongs
    • getName

      public String getName()
      Returns the name of the Metric.
      Returns:
      the name of the Metric
    • getMetricName

      public String getMetricName()
    • getScope

      public String getScope()
      Returns the scope of the Metric.
      Returns:
      the scope of the Metric
    • hasScope

      public boolean hasScope()
      Returns true if the Metric has a scope, false otherwise.
      Returns:
      true if the Metric has a scope
    • getMBeanName

      public ObjectName getMBeanName()
      Returns the MBean name for the Metric identified by this metric name.
      Returns:
      the MBean name
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(CassandraMetricsRegistry.MetricName o)
      Specified by:
      compareTo in interface Comparable<CassandraMetricsRegistry.MetricName>
    • chooseGroup

      public static String chooseGroup(String group, Class<?> klass)
      If the group is empty, use the package name of the given class. Otherwise use group
      Parameters:
      group - The group to use by default
      klass - The class being tracked
      Returns:
      a group for the metric
    • chooseType

      public static String chooseType(String type, Class<?> klass)
      If the type is empty, use the simple name of the given class. Otherwise use type
      Parameters:
      type - The type to use by default
      klass - The class being tracked
      Returns:
      a type for the metric
    • chooseName

      public static String chooseName(String name, Method method)
      If name is empty, use the name of the given method. Otherwise use name
      Parameters:
      name - The name to use by default
      method - The method being tracked
      Returns:
      a name for the metric