All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.opentelemetry.api.metrics.LongCounterBuilder Maven / Gradle / Ivy

There is a newer version: 2.0.0.0-RC3
Show newest version
/*
 * Copyright The OpenTelemetry Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package io.opentelemetry.api.metrics;

import java.util.function.Consumer;

/**
 * Builder class for {@link LongCounter}.
 *
 * @since 1.10.0
 */
public interface LongCounterBuilder {

  /**
   * Sets the description for this instrument.
   *
   * @param description The description.
   * @see Instrument
   *     Description
   */
  LongCounterBuilder setDescription(String description);

  /**
   * Sets the unit of measure for this instrument.
   *
   * @param unit The unit. Instrument units must be 63 or fewer ASCII characters.
   * @see Instrument
   *     Unit
   */
  LongCounterBuilder setUnit(String unit);

  /** Sets the Counter for recording {@code double} values. */
  DoubleCounterBuilder ofDoubles();

  /**
   * Builds and returns a Counter instrument with the configuration.
   *
   * @return The Counter instrument.
   */
  LongCounter build();

  /**
   * Builds an Asynchronous Counter instrument with the given callback.
   *
   * 

The callback will be called when the instrument is being observed. * *

Callbacks are expected to abide by the following restrictions: * *

    *
  • Run in a finite amount of time. *
  • Safe to call repeatedly, across multiple threads. *
* * @param callback A callback which observes measurements when invoked. */ ObservableLongCounter buildWithCallback(Consumer callback); /** * Build an observer for this instrument to observe values from a {@link BatchCallback}. * *

This observer MUST be registered when creating a {@link Meter#batchCallback(Runnable, * ObservableMeasurement, ObservableMeasurement...) batchCallback}, which records to it. Values * observed outside registered callbacks are ignored. * * @return an observable measurement that batch callbacks use to observe values. * @since 1.15.0 */ default ObservableLongMeasurement buildObserver() { return DefaultMeter.getInstance().counterBuilder("noop").buildObserver(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy