Package org.kairosdb.metrics4j
Class MetricThreadHelper
- java.lang.Object
-
- org.kairosdb.metrics4j.MetricThreadHelper
-
public class MetricThreadHelper extends Object
Used to set tags and report time for metrics reported on the current thread.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddTag(String name, String value)Adds a tag to all metrics that will be reported from the current thread.static voidclearReportTime()Clears the report time from the thread.static voidclearTags()Clears all tags from the thread.static InstantgetReportTime()Returns the set report time or Instance.MIN if not set.static StringgetTag(String name)Returns a value of a tag if set on the thread, null otherwise.static Iterator<Map.Entry<String,String>>getTagIterator()Iterator of all tags set on the thread.static voidremoveTag(String name)Removes a single tag from the thread.static voidsetReportTime(Instant time)Sets the time which metrics will be reported with.
-
-
-
Method Detail
-
setReportTime
public static void setReportTime(Instant time)
Sets the time which metrics will be reported with. This only has effect on non aggregated collectors like the BagCollector.- Parameters:
time- Timestamp to report the metric
-
clearReportTime
public static void clearReportTime()
Clears the report time from the thread. It is a good idea to pair this with the setReportTime so you don't accidentally override the metric report time by other metrics this thread may report in the future.
-
getReportTime
public static Instant getReportTime()
Returns the set report time or Instance.MIN if not set.- Returns:
- Report time for metric
-
addTag
public static void addTag(String name, String value)
Adds a tag to all metrics that will be reported from the current thread.- Parameters:
name- Name of tagvalue- Value of tag
-
getTag
public static String getTag(String name)
Returns a value of a tag if set on the thread, null otherwise.- Parameters:
name- Name of tag- Returns:
- Value of tag
-
removeTag
public static void removeTag(String name)
Removes a single tag from the thread.- Parameters:
name- Name of tag
-
clearTags
public static void clearTags()
Clears all tags from the thread. It is a good idea to add this to the end of any calls a thread is making to make sure the thread doesn't take the tags with it when doing other work.
-
-