Class StatsComponent

java.lang.Object
io.opencensus.stats.StatsComponent
Direct Known Subclasses:
NoopStats.NoopStatsComponent, StatsComponentImplBase

public abstract class StatsComponent extends Object
Class that holds the implementations for ViewManager and StatsRecorder.

All objects returned by methods on StatsComponent are cacheable.

Since:
0.8
  • Constructor Details

    • StatsComponent

      public StatsComponent()
  • Method Details

    • getViewManager

      public abstract ViewManager getViewManager()
      Returns the default ViewManager.
      Since:
      0.8
    • getStatsRecorder

      public abstract StatsRecorder getStatsRecorder()
      Returns the default StatsRecorder.
      Since:
      0.8
    • getState

      public abstract StatsCollectionState getState()
      Returns the current StatsCollectionState.

      When no implementation is available, getState always returns StatsCollectionState.DISABLED.

      Once getState() is called, subsequent calls to setState(StatsCollectionState) will throw an IllegalStateException.

      Returns:
      the current StatsCollectionState.
      Since:
      0.8
    • setState

      @Deprecated public abstract void setState(StatsCollectionState state)
      Deprecated.
      This method is deprecated because other libraries could cache the result of getState(), use a stale value, and behave incorrectly. It is only safe to call early in initialization. This method throws IllegalStateException after getState() has been called, in order to limit changes to the result of getState().
      Sets the current StatsCollectionState.

      When no implementation is available, setState does not change the state.

      If state is set to StatsCollectionState.DISABLED, all stats that are previously recorded will be cleared.

      Parameters:
      state - the new StatsCollectionState.
      Throws:
      IllegalStateException - if getState() was previously called.
      Since:
      0.8