Class MetricsContextTimer
- java.lang.Object
-
- nl.talsmasoftware.context.metrics.MetricsContextTimer
-
- All Implemented Interfaces:
ContextTimer
public class MetricsContextTimer extends Object implements ContextTimer
AContextTimerimplementation that locates an appropriateshared metric registry. Then it registers a newTimerfor context switches and updates it.Shared metric registry resolution
What an appropriate shared metric registry is, is rather complex and determined by the following rules:
- First, if a
contextpropagation.metrics.registrysystem property is defined, the shared metric registry by that name will be used for all context related timers. - Alternatively, the environment property
CONTEXTPROPAGATION_METRICS_REGISTRYserves the same purpose if the system property is not defined. - Next, if there is a
default shared metric registry, that one is used. - Otherwise:
- If there is exactly one shared registry, that one is used instead of the default.
- If there are no shared registries yet, a new one is created by the name
"ContextPropagationMetrics". - Otherwise we cannot sensibly choose and try to register new timers to all shared registries.
Timers, once created, will not be retroactively registered to other shared registries.
- Author:
- Sjoerd Talsma
-
-
Constructor Summary
Constructors Constructor Description MetricsContextTimer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringtoString()voidupdate(Class<?> type, String method, long duration, TimeUnit unit)Provides a new update for the context timer.
-
-
-
Method Detail
-
update
public void update(Class<?> type, String method, long duration, TimeUnit unit)
Description copied from interface:ContextTimerProvides a new update for the context timer.- Specified by:
updatein interfaceContextTimer- Parameters:
type- The class being calledmethod- The method being calledduration- The duration of the methodunit- The unit of the duration
-
-