Package io.opencensus.stats
Class Stats
- java.lang.Object
-
- io.opencensus.stats.Stats
-
public final class Stats extends java.lang.Object
Class for accessing the defaultStatsComponent
.- Since:
- 0.8
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Logger
logger
private static StatsComponent
statsComponent
-
Constructor Summary
Constructors Modifier Constructor Description private
Stats()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static StatsCollectionState
getState()
Returns the currentStatsCollectionState
.static StatsRecorder
getStatsRecorder()
Returns the defaultStatsRecorder
.static ViewManager
getViewManager()
Returns the defaultViewManager
.(package private) static StatsComponent
loadStatsComponent(java.lang.ClassLoader classLoader)
static void
setState(StatsCollectionState state)
Deprecated.This method is deprecated because other libraries could cache the result ofgetState()
, use a stale value, and behave incorrectly.
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
statsComponent
private static final StatsComponent statsComponent
-
-
Method Detail
-
getStatsRecorder
public static StatsRecorder getStatsRecorder()
Returns the defaultStatsRecorder
.- Since:
- 0.8
-
getViewManager
public static ViewManager getViewManager()
Returns the defaultViewManager
.- Since:
- 0.8
-
getState
public static StatsCollectionState getState()
Returns the currentStatsCollectionState
.When no implementation is available,
getState
always returnsStatsCollectionState.DISABLED
.Once
getState()
is called, subsequent calls tosetState(StatsCollectionState)
will throw anIllegalStateException
.- Returns:
- the current
StatsCollectionState
. - Since:
- 0.8
-
setState
@Deprecated public static void setState(StatsCollectionState state)
Deprecated.This method is deprecated because other libraries could cache the result ofgetState()
, use a stale value, and behave incorrectly. It is only safe to call early in initialization. This method throwsIllegalStateException
aftergetState()
has been called, in order to limit changes to the result ofgetState()
.Sets the currentStatsCollectionState
.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 newStatsCollectionState
.- Throws:
java.lang.IllegalStateException
- ifgetState()
was previously called.- Since:
- 0.8
-
loadStatsComponent
static StatsComponent loadStatsComponent(@Nullable java.lang.ClassLoader classLoader)
-
-