java.lang.Object
ru.vyarus.dropwizard.guice.module.context.stat.StatsTracker

public final class StatsTracker extends Object
Internal 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 Details

    • StatsTracker

      public StatsTracker()
      Create tracker.
  • Method Details

    • 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, Class<?> type)
      Detail stats used to record exact entity metric (like guicey bundle init or run time).
      Parameters:
      name - detail name
      type - 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 name
      count - 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 Map<Stat,com.google.common.base.Stopwatch> getTimers()
      Returns:
      collected timers map
    • getDetails

      public Map<Class<?>,Duration> getDetails(DetailStat name)
      Parameters:
      name - detail stat name
      Returns:
      detail stats
    • getCounters

      public Map<Stat,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.