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

com.wavefront.sdk.entities.tracing.sampling.DurationSampler Maven / Gradle / Ivy

package com.wavefront.sdk.entities.tracing.sampling;

/**
 * Sampler that allows spans above a given duration in milliseconds to be reported.
 *
 * @author Vikram Raman
 * @version $Id: $Id
 */
public class DurationSampler implements Sampler {

  private volatile long duration;

  /**
   * Constructor.
   *
   * @param duration The duration in milliseconds. Spans with durations higher than this are reported.
   */
  public DurationSampler(long duration) {
    setDuration(duration);
  }

  /** {@inheritDoc} */
  @Override
  public boolean sample(String operationName, long traceId, long duration) {
    return duration > this.duration;
  }

  /** {@inheritDoc} */
  @Override
  public boolean isEarly() {
    return false;
  }

  /**
   * Sets the duration for this sampler.
   *
   * @param duration The duration in milliseconds
   */
  public void setDuration(long duration) {
    this.duration = duration;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy