Class StatsTracker
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.module.context.stat.StatsTracker
-
public final class StatsTracker extends java.lang.ObjectInternal object, used to record startup stats. Guava {#Stopwatch} used for time measurements (also native stopwatch time formatting is used). All metrics are cumulative (all measurements are summed).- Since:
- 27.07.2016
-
-
Constructor Summary
Constructors Constructor Description StatsTracker()Create tracker.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcount(Stat name, int count)Inserts value for first call and sum values for consequent calls.com.google.common.base.StopwatchdetailTimer(DetailStat name, java.lang.Class<?> type)Detail stats used to record exact entity metric (like guicey bundle init or run time).java.util.Map<Stat,java.lang.Integer>getCounters()java.util.Map<java.lang.Class<?>,java.time.Duration>getDetails(DetailStat name)GuiceStatsTrackergetGuiceStats()java.util.Map<Stat,com.google.common.base.Stopwatch>getTimers()voidstartJerseyTimer(Stat name)Special methods for tracking time in jersey scope.voidstopJerseyTimer(Stat name)Called to stop currently measured jersey metric (also stops main guice and jersey timers).voidstopTimer(Stat name)Stop running timer.StatTimertimer(Stat name)If measured first time, returns new instance.voidverifyTimersDone()Verify all timers stopped on application complete startup.
-
-
-
Method Detail
-
timer
public StatTimer timer(Stat name)
If measured first time, returns new instance. For second and following measures returns the same instance (to sum measurements). Assumed proper usage: timer stat provided and returned watch correctly stopped.- Parameters:
name- statistic name- Returns:
- timer to measure time
-
stopTimer
public void stopTimer(Stat name)
Stop running timer.- Parameters:
name- timer name
-
detailTimer
public com.google.common.base.Stopwatch detailTimer(DetailStat name, java.lang.Class<?> type)
Detail stats used to record exact entity metric (like guicey bundle init or run time).- Parameters:
name- detail nametype- target type- Returns:
- detail timer
-
count
public void count(Stat name, int count)
Inserts value for first call and sum values for consequent calls.- Parameters:
name- statistics namecount- counter value
-
startJerseyTimer
public void startJerseyTimer(Stat name)
Special methods for tracking time in jersey scope. Such complication used to avoid using 3 different trackers in code. Jersey initialization is performed after bundles run and so out of scope of GuiceBundle.- Parameters:
name- jersey statistics name
-
stopJerseyTimer
public void stopJerseyTimer(Stat name)
Called to stop currently measured jersey metric (also stops main guice and jersey timers).- Parameters:
name- jersey statistic name
-
getTimers
public java.util.Map<Stat,com.google.common.base.Stopwatch> getTimers()
- Returns:
- collected timers map
-
getDetails
public java.util.Map<java.lang.Class<?>,java.time.Duration> getDetails(DetailStat name)
- Parameters:
name- detail stat name- Returns:
- detail stats
-
getCounters
public java.util.Map<Stat,java.lang.Integer> getCounters()
- Returns:
- collected counters map
-
getGuiceStats
public GuiceStatsTracker getGuiceStats()
- Returns:
- guice stats logger tracker object
-
verifyTimersDone
public void verifyTimersDone()
Verify all timers stopped on application complete startup. As timers are inlinable, it is quite possible to not call stop enough times.
-
-