org.apache.hadoop.metrics2

## Class MetricsRecordBuilder

- java.lang.Object
- - org.apache.hadoop.metrics2.MetricsRecordBuilder

- Direct Known Subclasses:
    MetricsJsonBuilder, MetricStringBuilder

      @InterfaceAudience.Public
       @InterfaceStability.Evolving
      public abstract class MetricsRecordBuilder
      extends Object

  The metrics record builder interface

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MetricsRecordBuilder()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract MetricsRecordBuilder` | `add(AbstractMetric metric)` Add a pre-made immutable metric object
    `abstract MetricsRecordBuilder` | `add(MetricsTag tag)` Add an immutable metrics tag object
    `abstract MetricsRecordBuilder` | `addCounter(MetricsInfo info, int value)` Add an integer metric
    `abstract MetricsRecordBuilder` | `addCounter(MetricsInfo info, long value)` Add an long metric
    `abstract MetricsRecordBuilder` | `addGauge(MetricsInfo info, double value)` Add a double gauge metric
    `abstract MetricsRecordBuilder` | `addGauge(MetricsInfo info, float value)` Add a float gauge metric
    `abstract MetricsRecordBuilder` | `addGauge(MetricsInfo info, int value)` Add a integer gauge metric
    `abstract MetricsRecordBuilder` | `addGauge(MetricsInfo info, long value)` Add a long gauge metric
    `MetricsCollector` | `endRecord()` Syntactic sugar to add multiple records in a collector in a one liner.
    `abstract MetricsCollector` | `parent()`
    `abstract MetricsRecordBuilder` | `setContext(String value)` Set the context tag
    `abstract MetricsRecordBuilder` | `tag(MetricsInfo info, String value)` Add a metrics value with metrics information

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MetricsRecordBuilder

          public MetricsRecordBuilder()

  - ### Method Detail

    - #### tag

          public abstract MetricsRecordBuilder tag(MetricsInfo info,
                                                   String value)

      Add a metrics value with metrics information
      Parameters:
        `info` - metadata of the tag
        `value` - of the tag
      Returns:
        self

    - #### add

          public abstract MetricsRecordBuilder add(MetricsTag tag)

      Add an immutable metrics tag object
      Parameters:
        `tag` - a pre-made tag object (potentially save an object construction)
      Returns:
        self

    - #### add

          public abstract MetricsRecordBuilder add(AbstractMetric metric)

      Add a pre-made immutable metric object
      Parameters:
        `metric` - the pre-made metric to save an object construction
      Returns:
        self

    - #### setContext

          public abstract MetricsRecordBuilder setContext(String value)

      Set the context tag
      Parameters:
        `value` - of the context
      Returns:
        self

    - #### addCounter

          public abstract MetricsRecordBuilder addCounter(MetricsInfo info,
                                                          int value)

      Add an integer metric
      Parameters:
        `info` - metadata of the metric
        `value` - of the metric
      Returns:
        self

    - #### addCounter

          public abstract MetricsRecordBuilder addCounter(MetricsInfo info,
                                                          long value)

      Add an long metric
      Parameters:
        `info` - metadata of the metric
        `value` - of the metric
      Returns:
        self

    - #### addGauge

          public abstract MetricsRecordBuilder addGauge(MetricsInfo info,
                                                        int value)

      Add a integer gauge metric
      Parameters:
        `info` - metadata of the metric
        `value` - of the metric
      Returns:
        self

    - #### addGauge

          public abstract MetricsRecordBuilder addGauge(MetricsInfo info,
                                                        long value)

      Add a long gauge metric
      Parameters:
        `info` - metadata of the metric
        `value` - of the metric
      Returns:
        self

    - #### addGauge

          public abstract MetricsRecordBuilder addGauge(MetricsInfo info,
                                                        float value)

      Add a float gauge metric
      Parameters:
        `info` - metadata of the metric
        `value` - of the metric
      Returns:
        self

    - #### addGauge

          public abstract MetricsRecordBuilder addGauge(MetricsInfo info,
                                                        double value)

      Add a double gauge metric
      Parameters:
        `info` - metadata of the metric
        `value` - of the metric
      Returns:
        self

    - #### parent

          public abstract MetricsCollector parent()

      Returns:
        the parent metrics collector object

    - #### endRecord

          public MetricsCollector endRecord()

      Syntactic sugar to add multiple records in a collector in a one liner.
      Returns:
        the parent metrics collector object

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.