@ParametersAreNonnullByDefault public static class Metrics.Builder extends Object
Metrics.metric(String).| Modifier and Type | Method and Description |
|---|---|
Metrics.Builder |
collect(Iterable<String> metricTagKeys)
Collects
MetricTag.OptionalMetricTag that may exist in a MetricTagContext |
Metrics.Builder |
collect(String... metricTagKeys)
Collects
MetricTag.OptionalMetricTag that may exist in a MetricTagContext |
Metrics.Builder |
fromPluginKey(String pluginKey)
Attribute a plugin for providing a module that is measured
|
Histogram |
histogram()
Creates a
Histogram with information in the builder. |
void |
incrementCounter(Long deltaValue)
Does not guarantee safety from lost-updates, check implementations.
|
void |
incrementGauge(Long deltaValue)
Does not guarantee safety from lost-updates, check implementations.
|
Metrics.Builder |
invokerPluginKey(String pluginKey)
Attribute the plugin for invoking measured code
|
LongRunningMetricTimer |
longRunningTimer()
Creates a
LongRunningMetricTimer with information in the builder. |
Metrics.Builder |
optionalTag(String key,
boolean value)
Adds an optional tag to the metric.
|
Metrics.Builder |
optionalTag(String key,
int value)
Adds an optional tag to the metric.
|
Metrics.Builder |
optionalTag(String key,
String value)
Adds an optional tag to the metric.
|
Metrics.Builder |
optionalTags(Iterable<MetricTag.OptionalMetricTag> optionalMetricTags)
Adds optional tags to the metric.
|
Metrics.Builder |
optionalTags(MetricTag.OptionalMetricTag... optionalMetricTags)
Adds optional tags to the metric.
|
void |
setGauge(Long currentValue)
Called to set the gauge by the value
|
Ticker |
startLongRunningTimer()
Starts a
LongRunningMetricTimer with information in the builder. |
Ticker |
startTimer()
Starts a
MetricTimer with information in the builder. |
Metrics.Builder |
tag(String key,
boolean value)
Adds a tag to the metric.
|
Metrics.Builder |
tag(String key,
int value)
Adds a tag to the metric.
|
Metrics.Builder |
tag(String key,
String value)
Adds a tag to the metric.
|
Metrics.Builder |
tags(Iterable<MetricTag.RequiredMetricTag> requiredMetricTags)
Adds tags to the metric.
|
Metrics.Builder |
tags(MetricTag.RequiredMetricTag... tags)
Adds tags to the metric.
|
MetricTimer |
timer()
Creates a
MetricTimer with information in the builder. |
Metrics.Builder |
withAnalytics()
Mark any created metrics to be sent to analytics.
|
Metrics.Builder |
withInvokerPluginKey()
Attribute the plugin at the top of the call stack for invoking measured code
|
@Nonnull public Metrics.Builder collect(String... metricTagKeys)
MetricTag.OptionalMetricTag that may exist in a MetricTagContext@Nonnull public Metrics.Builder collect(Iterable<String> metricTagKeys)
MetricTag.OptionalMetricTag that may exist in a MetricTagContext@Nonnull public Metrics.Builder tag(String key, boolean value)
See tags(Iterable) for more information about tag behaviour.
@Nonnull public Metrics.Builder tag(String key, int value)
See tags(Iterable) for more information about tag behaviour.
@Nonnull public Metrics.Builder tag(String key, @Nullable String value)
See tags(Iterable) for more information about tag behaviour.
@Nonnull public Metrics.Builder tags(MetricTag.RequiredMetricTag... tags)
See tags(Iterable) for more information about tag behaviour.
@Nonnull public Metrics.Builder tags(Iterable<MetricTag.RequiredMetricTag> requiredMetricTags)
Note: If there is an existing tag with the same key, the new value will replace the old.
Note: If multiple tags with the same key are passed, the last one will win.
Note: There is no guarantee in the order of tags in the output, that is the responsibility
of each MetricStrategy strategy used.
@Nonnull public Metrics.Builder optionalTag(String key, boolean value)
See optionalTags(Iterable) for more information about optional tag behaviour.
@Nonnull public Metrics.Builder optionalTag(String key, int value)
See optionalTags(Iterable) for more information about optional tag behaviour.
@Nonnull public Metrics.Builder optionalTag(String key, @Nullable String value)
See optionalTags(Iterable) for more information about optional tag behaviour.
@Nonnull public Metrics.Builder optionalTags(MetricTag.OptionalMetricTag... optionalMetricTags)
See optionalTags(Iterable) for more information about optional tag behaviour.
@Nonnull public Metrics.Builder optionalTags(Iterable<MetricTag.OptionalMetricTag> optionalMetricTags)
Note: If there is an existing MetricTag.OptionalMetricTag with the same key, the new value will replace the old.
Note: If there is a MetricTag.RequiredMetricTag with the same key it will win, regardless of order.
Note: If there is an MetricTag.OptionalMetricTag with same key in a MetricTagContext
then those provided to the builder will take priority
Note: There is no guarantee in the order of tags in the output, that is the responsibility
of each MetricStrategy strategy used.
@Nonnull public Metrics.Builder fromPluginKey(@Nullable String pluginKey)
@Nonnull public Metrics.Builder invokerPluginKey(@Nullable String pluginKey)
@Nonnull public Metrics.Builder withInvokerPluginKey()
No guarantee, that the call stack will be able to be traversed, i.e if work is delegated to another thread.
@Nonnull public Metrics.Builder withAnalytics()
Reminder: add any tags to the appropriate analytics allow-list.
@Nonnull public Histogram histogram()
Histogram with information in the builder.Histogrampublic void incrementCounter(@Nullable Long deltaValue)
Called to increment to count the number of occurrences with information in the builder. The delta, must be positive.
deltaValue - the change in gauge that should be recordedpublic void incrementGauge(@Nullable Long deltaValue)
Called to increment the gauge by the value. Starts from 0
public void setGauge(@Nullable Long currentValue)
@Nonnull public MetricTimer timer()
MetricTimer with information in the builder.MetricTimer@Nonnull public LongRunningMetricTimer longRunningTimer()
LongRunningMetricTimer with information in the builder.LongRunningMetricTimer@Nonnull public Ticker startTimer()
MetricTimer with information in the builder.Ticker to stop the created and started MetricTimer@Nonnull public Ticker startLongRunningTimer()
LongRunningMetricTimer with information in the builder.Ticker to stop the created and started LongRunningMetricTimerCopyright © 2023 Atlassian. All rights reserved.