Class MonitorData

  • All Implemented Interfaces:
    Iterable<Attribute>

    @PublicAPI(stability=PRIVATE)
    public final class MonitorData
    extends Object
    implements Iterable<Attribute>
    This class is used to hold monitoring data, i.e. a list of attributes. It provides convenient methods to easily build such data.

    Note:
    Creating monitor entries may become a lot easier once we've migrated to the SDK Entry class:

     Entry entry = ...;
     entry.addAttribute("stringStat", "aString")
           .addAttribute("integerStat", 12345)
           .addAttribute("dnStat", DN.valueOf("dc=aDN");
     
    We could also envisage an annotation based approach where we determine the monitor content from annotated fields/methods in an object.
    • Constructor Detail

      • MonitorData

        public MonitorData()
        Constructor to use when the number of attributes to create is unknown.
      • MonitorData

        public MonitorData​(int expectedAttributesCount)
        Constructor that accepts the number of attributes to create.
        Parameters:
        expectedAttributesCount - number of attributes that will be added
    • Method Detail

      • add

        public void add​(String attrName,
                        Object attrValue)
        Adds an attribute with the provided name and value.
        Parameters:
        attrName - the attribute name
        attrValue - the attribute value
      • addIfNotNull

        public void addIfNotNull​(String attrName,
                                 Object attrValue)
        Adds an attribute with the provided name and value if the value is not null.
        Parameters:
        attrName - the attribute name
        attrValue - the attribute value
      • add

        public void add​(String attrName,
                        Collection<?> attrValues)
        Adds an attribute with the provided name and values.
        Parameters:
        attrName - the attribute name
        attrValues - the attribute values
      • addBean

        public void addBean​(Object bean,
                            String attributesPrefix)
                     throws ReflectiveOperationException
        Adds all the properties from the provided bean as attributes, prepending the provided prefix.
        Parameters:
        bean - the bean from which to read the properties
        attributesPrefix - the prefix to prepend to the attributes read from the bean
        Throws:
        ReflectiveOperationException - if a problem occurs while reading the properties of the bean
      • size

        public int size()
        Returns the number of attributes.
        Returns:
        the number of attributes