Class AbstractTimerBuilder<B extends AbstractTimerBuilder<B>>

java.lang.Object
io.micrometer.core.instrument.AbstractTimerBuilder<B>
Type Parameters:
B - builder type
Direct Known Subclasses:
Timer.Builder, Timer.ResourceSample

public abstract class AbstractTimerBuilder<B extends AbstractTimerBuilder<B>>
extends java.lang.Object
Base builder for Timer.
Since:
1.6.0
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected java.lang.String description  
    protected DistributionStatisticConfig.Builder distributionConfigBuilder  
    protected java.lang.String name  
    protected PauseDetector pauseDetector  
    protected Tags tags  
  • Constructor Summary

    Constructors
    Modifier Constructor Description
    protected AbstractTimerBuilder​(java.lang.String name)  
  • Method Summary

    Modifier and Type Method Description
    B description​(java.lang.String description)  
    B distributionStatisticBufferLength​(java.lang.Integer bufferLength)
    Statistics emanating from a timer like max, percentiles, and histogram counts decay over time to give greater weight to recent samples (exception: histogram counts are cumulative for those systems that expect cumulative histogram buckets).
    B distributionStatisticExpiry​(java.time.Duration expiry)
    Statistics emanating from a timer like max, percentiles, and histogram counts decay over time to give greater weight to recent samples (exception: histogram counts are cumulative for those systems that expect cumulative histogram buckets).
    B maximumExpectedValue​(java.time.Duration max)
    Sets the maximum value that this timer is expected to observe.
    B minimumExpectedValue​(java.time.Duration min)
    Sets the minimum value that this timer is expected to observe.
    B pauseDetector​(PauseDetector pauseDetector)
    Sets the pause detector implementation to use for this timer.
    B percentilePrecision​(java.lang.Integer digitsOfPrecision)
    Determines the number of digits of precision to maintain on the dynamic range histogram used to compute percentile approximations.
    B publishPercentileHistogram()
    Adds histogram buckets used to generate aggregable percentile approximations in monitoring systems that have query facilities to do so (e.g.
    B publishPercentileHistogram​(java.lang.Boolean enabled)
    Adds histogram buckets used to generate aggregable percentile approximations in monitoring systems that have query facilities to do so (e.g.
    B publishPercentiles​(double... percentiles)
    Produces an additional time series for each requested percentile.
    B serviceLevelObjectives​(java.time.Duration... slos)
    Publish at a minimum a histogram containing your defined service level objective (SLO) boundaries.
    B sla​(java.time.Duration... sla)
    Deprecated.
    B tag​(java.lang.String key, java.lang.String value)  
    B tags​(java.lang.Iterable<Tag> tags)  
    B tags​(java.lang.String... tags)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • AbstractTimerBuilder

      protected AbstractTimerBuilder​(java.lang.String name)
  • Method Details

    • tags

      public B tags​(java.lang.String... tags)
      Parameters:
      tags - Must be an even number of arguments representing key/value pairs of tags.
      Returns:
      This builder.
    • tags

      public B tags​(java.lang.Iterable<Tag> tags)
      Parameters:
      tags - Tags to add to the eventual timer.
      Returns:
      The timer builder with added tags.
    • tag

      public B tag​(java.lang.String key, java.lang.String value)
      Parameters:
      key - The tag key.
      value - The tag value.
      Returns:
      The timer builder with a single added tag.
    • publishPercentiles

      public B publishPercentiles​(@Nullable double... percentiles)
      Produces an additional time series for each requested percentile. This percentile is computed locally, and so can't be aggregated with percentiles computed across other dimensions (e.g. in a different instance). Use publishPercentileHistogram() to publish a histogram that can be used to generate aggregable percentile approximations.
      Parameters:
      percentiles - Percentiles to compute and publish. The 95th percentile should be expressed as 0.95.
      Returns:
      This builder.
    • percentilePrecision

      public B percentilePrecision​(@Nullable java.lang.Integer digitsOfPrecision)
      Determines the number of digits of precision to maintain on the dynamic range histogram used to compute percentile approximations. The higher the degrees of precision, the more accurate the approximation is at the cost of more memory.
      Parameters:
      digitsOfPrecision - The digits of precision to maintain for percentile approximations.
      Returns:
      This builder.
    • publishPercentileHistogram

      public B publishPercentileHistogram()
      Adds histogram buckets used to generate aggregable percentile approximations in monitoring systems that have query facilities to do so (e.g. Prometheus' histogram_quantile, Atlas' :percentiles).
      Returns:
      This builder.
    • publishPercentileHistogram

      public B publishPercentileHistogram​(@Nullable java.lang.Boolean enabled)
      Adds histogram buckets used to generate aggregable percentile approximations in monitoring systems that have query facilities to do so (e.g. Prometheus' histogram_quantile, Atlas' :percentiles).
      Parameters:
      enabled - Determines whether percentile histograms should be published.
      Returns:
      This builder.
    • sla

      @Deprecated public B sla​(@Nullable java.time.Duration... sla)
      Deprecated.
      Use {serviceLevelObjectives(Duration...)} instead. "Service Level Agreement" is more formally the agreement between an engineering organization and the business. Service Level Objectives are set more conservatively than the SLA to provide some wiggle room while still satisfying the business requirement. SLOs are the threshold we intend to measure against, then.
      Publish at a minimum a histogram containing your defined service level objective (SLO) boundaries. When used in conjunction with publishPercentileHistogram(), the boundaries defined here are included alongside other buckets used to generate aggregable percentile approximations.
      Parameters:
      sla - Publish SLO boundaries in the set of histogram buckets shipped to the monitoring system.
      Returns:
      This builder.
    • serviceLevelObjectives

      public B serviceLevelObjectives​(@Nullable java.time.Duration... slos)
      Publish at a minimum a histogram containing your defined service level objective (SLO) boundaries. When used in conjunction with publishPercentileHistogram(), the boundaries defined here are included alongside other buckets used to generate aggregable percentile approximations.
      Parameters:
      slos - Publish SLO boundaries in the set of histogram buckets shipped to the monitoring system.
      Returns:
      This builder.
      Since:
      1.5.0
    • minimumExpectedValue

      public B minimumExpectedValue​(@Nullable java.time.Duration min)
      Sets the minimum value that this timer is expected to observe. Sets a lower bound on histogram buckets that are shipped to monitoring systems that support aggregable percentile approximations.
      Parameters:
      min - The minimum value that this timer is expected to observe.
      Returns:
      This builder.
    • maximumExpectedValue

      public B maximumExpectedValue​(@Nullable java.time.Duration max)
      Sets the maximum value that this timer is expected to observe. Sets an upper bound on histogram buckets that are shipped to monitoring systems that support aggregable percentile approximations.
      Parameters:
      max - The maximum value that this timer is expected to observe.
      Returns:
      This builder.
    • distributionStatisticExpiry

      public B distributionStatisticExpiry​(@Nullable java.time.Duration expiry)
      Statistics emanating from a timer like max, percentiles, and histogram counts decay over time to give greater weight to recent samples (exception: histogram counts are cumulative for those systems that expect cumulative histogram buckets). Samples are accumulated to such statistics in ring buffers which rotate after this expiry, with a buffer length of distributionStatisticBufferLength(Integer).
      Parameters:
      expiry - The amount of time samples are accumulated to a histogram before it is reset and rotated.
      Returns:
      This builder.
    • distributionStatisticBufferLength

      public B distributionStatisticBufferLength​(@Nullable java.lang.Integer bufferLength)
      Statistics emanating from a timer like max, percentiles, and histogram counts decay over time to give greater weight to recent samples (exception: histogram counts are cumulative for those systems that expect cumulative histogram buckets). Samples are accumulated to such statistics in ring buffers which rotate after distributionStatisticExpiry(Duration), with this buffer length.
      Parameters:
      bufferLength - The number of histograms to keep in the ring buffer.
      Returns:
      This builder.
    • pauseDetector

      public B pauseDetector​(@Nullable PauseDetector pauseDetector)
      Sets the pause detector implementation to use for this timer. Can also be configured on a registry-level with MeterRegistry.Config.pauseDetector(PauseDetector).
      Parameters:
      pauseDetector - The pause detector implementation to use.
      Returns:
      This builder.
      See Also:
      NoPauseDetector, ClockDriftPauseDetector
    • description

      public B description​(@Nullable java.lang.String description)
      Parameters:
      description - Description text of the eventual timer.
      Returns:
      This builder.