se.l4.vibe.builder.SamplerBuilder Maven / Gradle / Ivy
package se.l4.vibe.builder;
import java.util.concurrent.TimeUnit;
import se.l4.vibe.event.EventSeverity;
import se.l4.vibe.probes.Sampler;
import se.l4.vibe.trigger.Condition;
import se.l4.vibe.trigger.Conditions;
import se.l4.vibe.trigger.On;
import se.l4.vibe.trigger.Trigger;
import se.l4.vibe.trigger.Triggers;
/**
* Builder for a {@link Sampler}.
*
* @author Andreas Holstenson
*
*/
public interface SamplerBuilder
extends Builder>
{
/**
* Override the default interval for sampling.
*
* @param time
* @param unit
* @return
*/
SamplerBuilder withInterval(long time, TimeUnit unit);
/**
* Create a trigger for this sampler. Triggers will send events
* if the condition is met. Use {@link Triggers} and {@link Conditions}
* to create triggers and conditions suitable for usage with this
* method.
*
*
* Example:
*
* when(
* {@link Triggers#average(long, TimeUnit) average(5, TimeUnit.MINUTES)},
* {@link Conditions#above(Number) above(0.8)
* )
* .sendEvent({@link EventSeverity#CRITICAL})
*
*
* This will create a trigger that activates when the average of the
* series over 5 minutes is above {@code 0.8}.
*
* @param trigger
* @param condition
* @return
*/
TriggerBuilder> when(
Trigger super T, Type> trigger,
Condition condition
);
/**
* Create a trigger for this sampler. See {@link #when(Trigger, Condition)}.
*
* @param trigger
* @param on
* @param condition
* @return
*/
TriggerBuilder> when(
Trigger trigger,
On super T, Middle> on,
Condition condition
);
/**
* Return the sampler without exporting it.
*
* @return
*/
Sampler build();
/**
* Export and return the sampler.
*
* @return
*/
Sampler export();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy