@Internal @ParametersAreNonnullByDefault public interface MetricStrategy
Metrics.
Only metric timers and histograms created through Metrics.timer(String),
Metrics.startTimer(String), Metrics.histogram(String), Timers.timerWithMetric(java.lang.String, java.lang.String) and
Timers.startWithMetric(java.lang.String) will interact with
configured MetricStrategy instances.
| Modifier and Type | Method and Description |
|---|---|
default void |
cleanupMetrics(MetricsFilter filter)
Removes existing metrics that are not accepted by the specified filter.
|
default void |
incrementCounter(MetricKey metricKey,
long deltaValue)
Does not guarantee safety from lost-updates, check implementations.
|
default void |
incrementGauge(MetricKey metricKey,
long deltaValue)
Does not guarantee safety from lost-updates, check implementations.
|
default void |
onRequestEnd()
Method that is called to signal that the request has completed.
|
default void |
resetMetric(MetricKey metricKey)
Resets (that may mean removal depending on the metric strategy) a specific metric that exactly matches a
MetricKey. |
default void |
setConfiguration(MetricsConfiguration configuration)
Method that is called when the strategy is
registered. |
default void |
setGauge(MetricKey metricKey,
long currentValue)
Called to set the gauge by the value.
|
default Ticker |
startLongRunningTimer(MetricKey metricKey)
Called to time something that is long-running and could benefit from periodic updates on the timer duration.
|
default Ticker |
startLongRunningTimer(String metricName)
Called to time something that is long-running and could benefit from periodic updates on the timer duration.
|
default Ticker |
startTimer(MetricKey metricKey)
Called to mark the end of a block of code for which metrics should be calculated.
|
Ticker |
startTimer(String metricName)
Called to mark the end of a block of code for which metrics should be calculated.
|
default void |
updateHistogram(MetricKey metricKey,
long value)
Called when a histogram is
updated. |
void |
updateHistogram(String metricName,
long value)
Called when a histogram is
updated. |
default void |
updateTimer(MetricKey metricKey,
Duration time)
Called when a metric is
updated. |
void |
updateTimer(String metricName,
long time,
TimeUnit timeUnit)
Called when a metric is
updated. |
default void cleanupMetrics(MetricsFilter filter)
Note: this optional for strategies to support
filter - Metrics that are not accepted by the specified filter will be removed from this strategy.default void resetMetric(MetricKey metricKey)
MetricKey.metricKey - metric key to be reset.default void onRequestEnd()
default void setConfiguration(MetricsConfiguration configuration)
registered.configuration - the configuration@Nonnull Ticker startTimer(String metricName)
metricName - the name of metricticker that can be used to mark the end of the code block for
which metrics should be calculated. Must be non-null, but can be Ticker.NO_OP if the strategy
opts out of tracking.@Nonnull default Ticker startTimer(MetricKey metricKey)
metricKey - the key of metricticker that can be used to mark the end of the code block for
which metrics should be calculated. Must be non-null, but can be Ticker.NO_OP if the strategy
opts out of tracking.@Nonnull default Ticker startLongRunningTimer(String metricName)
Note: this optional for strategies to support This is an optional method, not all strategies will support this
metricName - the name of metricticker that can be used to mark the end of the code block for
which metrics should be calculated. Must be non-null, but can be Ticker.NO_OP if the strategy
opts out of tracking.@Nonnull default Ticker startLongRunningTimer(MetricKey metricKey)
Note: this optional for strategies to support This is an optional method, not all strategies will support this
metricKey - the key of metricticker that can be used to mark the end of the code block for
which metrics should be calculated. Must be non-null, but can be Ticker.NO_OP if the strategy
opts out of tracking.default void incrementCounter(MetricKey metricKey, long deltaValue)
Called to increment the count of the number of occurences.
metricKey - the key of counterdeltaValue - the amount to add to the counterdefault void incrementGauge(MetricKey metricKey, long deltaValue)
Called to increment the gauge by the value. Starts from 0
metricKey - the key of the gaugedeltaValue - the change in gauge that should be recordedvoid updateHistogram(String metricName, long value)
updated.metricName - the histogram namevalue - the value to recorddefault void updateHistogram(MetricKey metricKey, long value)
updated.metricKey - the histogram keyvalue - the value to recordvoid updateTimer(String metricName, long time, TimeUnit timeUnit)
updated.metricName - the name of metrictime - the time to recordtimeUnit - the time unit of timedefault void updateTimer(MetricKey metricKey, Duration time)
updated.metricKey - the key of timertime - the time to recorddefault void setGauge(MetricKey metricKey, long currentValue)
metricKey - the key of the gaugecurrentValue - the value of gauge that should be recordedCopyright © 2023 Atlassian. All rights reserved.