Package com.atlassian.util.profiling
Class Timers
java.lang.Object
com.atlassian.util.profiling.Timers
Factory and utility methods for create
Timer instances
try (Ticker ignored = Timers.start("my-timer")) {
// monitored code block here
}
- Since:
- 3.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic TimerCombine multipleTimerobjects into one, so they can be started and stopped together.static ProfilerConfigurationGet the currentProfilerConfiguration.static voidCall this method to signal that the request has completed to trigger all configuredprofiler strategiesandmetric strategiesto clean up any request or thread scoped resources associated with profiling state, includingclosinganytickersthat have not yet been closed.static TickerStarts a timer with the given name.static TickerstartWithMetric(String timerName) Starts a timer with the given name and metrics.static TickerstartWithMetric(String timerName, MetricTag.RequiredMetricTag... metricTags) Deprecated.static TickerstartWithMetric(String timerName, String metricName) Deprecated.since 4.3.0, for removal in 5.0.0, usetimerWithMetric(String, Metrics.Builder)with theMetrics.metric(String)builder instead.static TickerstartWithMetric(String timerName, String metricName, MetricTag.RequiredMetricTag... metricTags) Deprecated.since 4.3.0, for removal in 5.0.0, usetimerWithMetric(String, Metrics.Builder)with theMetrics.metric(String)builder instead.static TimerCreates aTimerwith the given name.static TimertimerWithMetric(String name) Creates aTimerwith the given name, and metrics.static TimertimerWithMetric(String traceName, Metrics.Builder metricBuilder) Creates aTimerwith the given trace name, and metrics based on the builder.static TimertimerWithMetric(String name, MetricTag.RequiredMetricTag... tags) Deprecated.since 4.3.0, for removal in 5.0.0, usetimerWithMetric(String, Metrics.Builder)with theMetrics.metric(String)builder instead.static TimertimerWithMetric(String traceName, MetricTimer metricTimer) Creates aTimerwith the given trace name, and mixes in aMetricTimer.static TimertimerWithMetric(String traceName, String metricName) Deprecated.since 4.3.0, for removal in 5.0.0, usetimerWithMetric(String, Metrics.Builder)with theMetrics.metric(String)builder instead.static TimertimerWithMetric(String traceName, String metricName, MetricTag.RequiredMetricTag... tags) Deprecated.since 4.3.0, for removal in 5.0.0, usetimerWithMetric(String, Metrics.Builder)with theMetrics.metric(String)builder instead.static TimertimerWithMetric(String traceName, String metricName, Collection<MetricTag.RequiredMetricTag> tags) Deprecated.since 4.3.0, for removal in 5.0.0, usetimerWithMetric(String, Metrics.Builder)with theMetrics.metric(String)builder instead.static TimertimerWithMetric(String name, Collection<MetricTag.RequiredMetricTag> tags) Deprecated.since 4.3.0, for removal in 5.0.0, usetimerWithMetric(String, Metrics.Builder)with theMetrics.metric(String)builder instead.
-
Method Details
-
concat
Combine multipleTimerobjects into one, so they can be started and stopped together.- Parameters:
timers- to combine- Returns:
- a composite
Timer - Since:
- 3.0.0
-
getConfiguration
Get the currentProfilerConfiguration.- Returns:
- the current configuration.
- Since:
- 3.0.0
-
onRequestEnd
public static void onRequestEnd()Call this method to signal that the request has completed to trigger all configuredprofiler strategiesandmetric strategiesto clean up any request or thread scoped resources associated with profiling state, includingclosinganytickersthat have not yet been closed.- Since:
- 3.0.0
-
start
Starts a timer with the given name.- Returns:
- a
Tickerto stop the created and started timer. - Since:
- 3.0.0
-
startWithMetric
Starts a timer with the given name and metrics.- Returns:
- a
Tickerto stop the created and started timer. - Since:
- 3.0.0
-
startWithMetric
Deprecated.since 4.3.0, for removal in 5.0.0, usetimerWithMetric(String, Metrics.Builder)with theMetrics.metric(String)builder instead.Starts a timer with the given name and metrics with the given metric name.- Returns:
- a
Tickerto stop the created and started timer. - Since:
- 3.0.0
-
startWithMetric
@Deprecated @Nonnull public static Ticker startWithMetric(String timerName, MetricTag.RequiredMetricTag... metricTags) Deprecated.since 4.3.0, for removal in 5.0.0, usetimerWithMetric(String, Metrics.Builder)with theMetrics.metric(String)builder instead.Starts a timer with the given name, and tagged metrics.See
Metrics.Builder.tags(Iterable)for more information about tag behaviour.- Returns:
- a
Tickerto stop the created and started timer. - Since:
- 3.4.2
-
startWithMetric
@Deprecated @Nonnull public static Ticker startWithMetric(String timerName, String metricName, MetricTag.RequiredMetricTag... metricTags) Deprecated.since 4.3.0, for removal in 5.0.0, usetimerWithMetric(String, Metrics.Builder)with theMetrics.metric(String)builder instead.Starts a timer with the given name, and tagged metrics with the given metric name.See
Metrics.Builder.tags(Iterable)for more information about tag behaviour.- Returns:
- a
Tickerto stop the created and started timer. - Since:
- 3.4.1
-
timer
Creates aTimerwith the given name.- Returns:
- the created
Timer. - Since:
- 3.0.0
-
timerWithMetric
Deprecated.since 4.3.0, for removal in 5.0.0, usetimerWithMetric(String, Metrics.Builder)with theMetrics.metric(String)builder instead.Creates aTimerwith the given trace name, and metrics with given metric name.- Returns:
- the created
Timer. - Since:
- 3.0.0
-
timerWithMetric
@Deprecated @Nonnull public static Timer timerWithMetric(String traceName, String metricName, MetricTag.RequiredMetricTag... tags) Deprecated.since 4.3.0, for removal in 5.0.0, usetimerWithMetric(String, Metrics.Builder)with theMetrics.metric(String)builder instead.Creates aTimerwith the given trace name, and tagged metrics with the given metric name.See
Metrics.Builder.tags(Iterable)for more information about tag behaviour.- Returns:
- the created
Timer. - Since:
- 3.4.0
-
timerWithMetric
@Deprecated @Nonnull public static Timer timerWithMetric(String traceName, String metricName, Collection<MetricTag.RequiredMetricTag> tags) Deprecated.since 4.3.0, for removal in 5.0.0, usetimerWithMetric(String, Metrics.Builder)with theMetrics.metric(String)builder instead.Creates aTimerwith the given trace name, and tagged metrics with the given metric name.See
Metrics.Builder.tags(Iterable)for more information about tag behaviour.- Returns:
- the created
Timer. - Since:
- 3.4.0
-
timerWithMetric
Creates aTimerwith the given trace name, and metrics based on the builder.See
Metrics.Builder.tags(Iterable)for more information about tag behaviour.- Returns:
- the created
Timer. - Since:
- 3.5.0
-
timerWithMetric
Creates aTimerwith the given trace name, and mixes in aMetricTimer.- Returns:
- the created
Timer. - Since:
- 3.5.0
-
timerWithMetric
Creates aTimerwith the given name, and metrics.- Returns:
- a
Tickerto stop the created timer. - Since:
- 3.0.0
-
timerWithMetric
@Deprecated @Nonnull public static Timer timerWithMetric(String name, Collection<MetricTag.RequiredMetricTag> tags) Deprecated.since 4.3.0, for removal in 5.0.0, usetimerWithMetric(String, Metrics.Builder)with theMetrics.metric(String)builder instead.Creates aTimerwith the given name, and tagged metrics.See
Metrics.Builder.tags(Iterable)for more information about tag behaviour.- Returns:
- the created
Timer. - Since:
- 3.4.0
-
timerWithMetric
@Deprecated @Nonnull public static Timer timerWithMetric(String name, MetricTag.RequiredMetricTag... tags) Deprecated.since 4.3.0, for removal in 5.0.0, usetimerWithMetric(String, Metrics.Builder)with theMetrics.metric(String)builder instead.Creates aTimerwith the given name, and tagged metrics.See
Metrics.Builder.tags(Iterable)for more information about tag behaviour.- Returns:
- the created
Timer. - Since:
- 3.4.0
-
timerWithMetric(String, Metrics.Builder)with theMetrics.metric(String)builder instead.