public abstract class ServiceStats extends Object
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
addTiming(String key,
long nanos,
long endNanos) |
<T> T |
collectTiming(String name,
java.util.function.Supplier<T> subject)
Records the execution time for `subject` at a key based on `name`.
|
<T> T |
collectTiming(String name,
java.util.function.Supplier<T> subject,
java.util.function.Predicate<T> successful)
Records the execution time for `subject` at a key based on `name`.
|
<T> T |
collectTimingWithThrownFailures(String name,
java.util.function.Supplier<T> subject,
java.util.function.Predicate<Throwable> expected)
Records the execution time for `subject` at a key based on `name`.
|
void |
complete(String key,
long startNanos)
Puts a timing entry of `System.nanoTime() - startNanos` into the stats for `key`.
|
static void |
configure(DecayConfig decayConfig,
double... quantiles) |
static void |
configure(DecayConfig defaultDecayConfig,
Map<String,DecayConfig> decayConfigMap,
double... quantiles) |
static void |
configure(double... quantiles) |
abstract Stats[] |
consume()
Consumes a snapshot of the live stats currently collected.
|
static void |
disable() |
abstract java.util.stream.Stream<Stats> |
get(String... statsNames)
Gets a snapshot of the live stats currently collected.
|
static ServiceStats |
instance() |
void |
put(String key,
long nanos)
Puts a timing entry of `nanos` into the stats for `key`.
|
<T> CompletableFuture<T> |
timingOnCompletion(String name,
java.util.function.Supplier<CompletableFuture<T>> subject)
Records the execution time for the future produced by `subject` at a key based on `name`.
|
<T> CompletableFuture<T> |
timingOnCompletion(String name,
java.util.function.Supplier<CompletableFuture<T>> subject,
java.util.function.Predicate<T> successful)
Records the execution time for the future produced by `subject` at a key based on `name`.
|
public void put(String key, long nanos)
key - The key to add a timing entry for.nanos - The number of nanoseconds to record.public void complete(String key, long startNanos)
key - The key to add a timing entry for.startNanos - The System.nanoTime() at which the subject task started.public <T> CompletableFuture<T> timingOnCompletion(String name, java.util.function.Supplier<CompletableFuture<T>> subject)
T - name - The base name used to determine which stats key to store the resulting timing entry.subject - A supplier which starts the task to be timed.public <T> CompletableFuture<T> timingOnCompletion(String name, java.util.function.Supplier<CompletableFuture<T>> subject, java.util.function.Predicate<T> successful)
T - name - The base name used to determine which stats key to store the resulting timing entry.subject - A supplier which starts the code to be timed.successful - A predicate on the result of the supplied future to determine whether the task was successful.public <T> T collectTiming(String name, java.util.function.Supplier<T> subject)
T - name - The base name used to determine which stats key to store the resulting timing entry.subject - The task to be timed.public <T> T collectTimingWithThrownFailures(String name, java.util.function.Supplier<T> subject, java.util.function.Predicate<Throwable> expected)
T - name - The base name used to determine which stats key to store the resulting timing entry.subject - The task to be timed.expected - A predicate to indicate whether an thrown Throwable is an expected 'failure' or an 'error'.public <T> T collectTiming(String name, java.util.function.Supplier<T> subject, java.util.function.Predicate<T> successful)
T - name - The base name used to determine which stats key to store the resulting timing entry.subject - The task to be timed.successful - A predicate on the result of the supplied future to determine whether the task was successful.public abstract Stats[] consume()
public abstract java.util.stream.Stream<Stats> get(String... statsNames)
protected abstract void addTiming(String key, long nanos, long endNanos)
public static void disable()
public static void configure(double... quantiles)
public static void configure(DecayConfig decayConfig, double... quantiles)
public static void configure(DecayConfig defaultDecayConfig, Map<String,DecayConfig> decayConfigMap, double... quantiles)
public static ServiceStats instance()
Copyright © 2015. All rights reserved.