public static <T> MetricStorage longAsynchronousAccumulator(
      View view,
      InstrumentDescriptor instrument,
      Consumer<ObservableLongMeasurement> metricUpdater) {
    final MetricDescriptor metricDescriptor = MetricDescriptor.create(view, instrument);
    Aggregator<T> aggregator =
        view.getAggregation().createAggregator(instrument, ExemplarFilter.neverSample());
    final AsyncAccumulator<T> measurementAccumulator = new AsyncAccumulator<>(instrument);
    final AttributesProcessor attributesProcessor = view.getAttributesProcessor();
    // TODO: Find a way to grab the measurement JUST ONCE for all async metrics.
    final ObservableLongMeasurement result =
        new ObservableLongMeasurement() {
          @Override
          public void observe(long value, Attributes attributes) {
            T accumulation =
                aggregator.accumulateLongMeasurement(value, attributes, Context.current());
            if (accumulation != null) {
              measurementAccumulator.record(
                  attributesProcessor.process(attributes, Context.current()), accumulation);
            }
          }
          @Override
          public void observe(long value) {
            observe(value, Attributes.empty());
          }
        };
    return new AsynchronousMetricStorage<>(
        metricDescriptor, aggregator, measurementAccumulator, () -> metricUpdater.accept(result));
  }
public static <T> MetricStorage longAsynchronousAccumulator(
      View view,
      InstrumentDescriptor instrument,
      Consumer<ObservableLongMeasurement> metricUpdater) {
    final MetricDescriptor metricDescriptor = MetricDescriptor.create(view, instrument);
    Aggregator<T> aggregator =
        view.getAggregation().createAggregator(instrument, ExemplarFilter.neverSample());
    final AsyncAccumulator<T> measurementAccumulator = new AsyncAccumulator<>(instrument);
    final AttributesProcessor attributesProcessor = view.getAttributesProcessor();
   
    final ObservableLongMeasurement result =
        new ObservableLongMeasurement() {
          @Override
          public void observe(long value, Attributes attributes) {
            T accumulation =
                aggregator.accumulateLongMeasurement(value, attributes, Context.current());
            if (accumulation != null) {
              measurementAccumulator.record(
                  attributesProcessor.process(attributes, Context.current()), accumulation);
            }
          }
          @Override
          public void observe(long value) {
            observe(value, Attributes.empty());
          }
        };
    return new AsynchronousMetricStorage<>(
        metricDescriptor, aggregator, measurementAccumulator, () -> metricUpdater.accept(result));
  }
public static <t> metricstorage longasynchronousaccumulator( view view, instrumentdescriptor instrument, consumer<observablelongmeasurement> metricupdater) { final metricdescriptor metricdescriptor = metricdescriptor.create(view, instrument); aggregator<t> aggregator = view.getaggregation().createaggregator(instrument, exemplarfilter.neversample()); final asyncaccumulator<t> measurementaccumulator = new asyncaccumulator<>(instrument); final attributesprocessor attributesprocessor = view.getattributesprocessor(); final observablelongmeasurement result = new observablelongmeasurement() { @override public void observe(long value, attributes attributes) { t accumulation = aggregator.accumulatelongmeasurement(value, attributes, context.current()); if (accumulation != null) { measurementaccumulator.record( attributesprocessor.process(attributes, context.current()), accumulation); } } @override public void observe(long value) { observe(value, attributes.empty()); } }; return new asynchronousmetricstorage<>( metricdescriptor, aggregator, measurementaccumulator, () -> metricupdater.accept(result)); }