spectator-reg-metrics3/src/main/java/com/netflix/spectator/metrics3/MetricsGaugeAggr.java [30:68]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  private ConcurrentLinkedQueue<MetricsGauge> gauges;

  /**
   * Creates a new Aggregate Gauge.
   */
  MetricsGaugeAggr() {
    this.gauges = new ConcurrentLinkedQueue<>();
  }

  @Override
  public Double getValue() {
    double aggregatedValue = Double.NaN;

    final Iterator<MetricsGauge> iterator = gauges.iterator();
    while (iterator.hasNext()) {
      final MetricsGauge gauge = iterator.next();

      if (gauge.hasExpired()) {
        iterator.remove();
      } else {
        final double gaugeVal = gauge.value();

        // When it's NaN means the gauge can be unregistered due to it's reference to the value to extract value
        // was garbage collected or simple the gauge returned a NaN so i don't count it
        if (!Double.isNaN(gaugeVal))
          aggregatedValue = (Double.isNaN(aggregatedValue) ? 0 : aggregatedValue) + gaugeVal;
      }
    }

    return aggregatedValue;
  }

  /**
   * Add a gauge to be aggragate to the others.
   *
   * @param gauge Gauge to be added
   */
  void addGauge(MetricsGauge gauge) {
    this.gauges.add(gauge);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



spectator-reg-metrics5/src/main/java/com/netflix/spectator/metrics5/MetricsGaugeAggr.java [30:68]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  private ConcurrentLinkedQueue<MetricsGauge> gauges;

  /**
   * Creates a new Aggregate Gauge.
   */
  MetricsGaugeAggr() {
    this.gauges = new ConcurrentLinkedQueue<>();
  }

  @Override
  public Double getValue() {
    double aggregatedValue = Double.NaN;

    final Iterator<MetricsGauge> iterator = gauges.iterator();
    while (iterator.hasNext()) {
      final MetricsGauge gauge = iterator.next();

      if (gauge.hasExpired()) {
        iterator.remove();
      } else {
        final double gaugeVal = gauge.value();

        // When it's NaN means the gauge can be unregistered due to it's reference to the value to extract value
        // was garbage collected or simple the gauge returned a NaN so i don't count it
        if (!Double.isNaN(gaugeVal))
          aggregatedValue = (Double.isNaN(aggregatedValue) ? 0 : aggregatedValue) + gaugeVal;
      }
    }

    return aggregatedValue;
  }

  /**
   * Add a gauge to be aggragate to the others.
   *
   * @param gauge Gauge to be added
   */
  void addGauge(MetricsGauge gauge) {
    this.gauges.add(gauge);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



