Class MetricBuffer

    • Constructor Detail

      • MetricBuffer

        public MetricBuffer​(Attributes commonAttributes)
        Create a new buffer with the provided common set of attributes.
        Parameters:
        commonAttributes - These attributes will be appended (by the New Relic backend) to every Metric in this buffer.
    • Method Detail

      • addMetric

        public void addMetric​(Metric metric)
        Append a Metric to this buffer, to be sent in the next MetricBatch.
        Parameters:
        metric - The new Metric instance to be sent.
      • createBatch

        public MetricBatch createBatch()
        Creates a new MetricBatch from the contents of this buffer, then clears the contents of this buffer.

        Metrics added to this buffer by other threads during this method call will either be added to the MetricBatch being created, or will be saved for the next MetricBatch.

        Returns:
        A new MetricBatch with an immutable collection of Metrics.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • builder

        public static MetricBuffer.Builder builder()
        Returns a new Builder instance for help with creating new MetricBatch instances
        Returns:
        a new instance of MetricBatch.Builder