public final class Metric extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
static String |
TAG_SEPARATOR |
Constructor and Description |
---|
Metric(MetricsSystem.InstanceType instanceType,
String hostname,
MetricType metricType,
String name,
Double value)
Constructs a
Metric instance. |
Metric(MetricsSystem.InstanceType instanceType,
String hostname,
String id,
MetricType metricType,
String name,
Double value)
Constructs a
Metric instance. |
Modifier and Type | Method and Description |
---|---|
void |
addTag(String name,
String value)
Adds a new tag.
|
void |
addValue(double delta)
Add metric value delta to the existing value.
|
boolean |
equals(Object other) |
static Metric |
from(String fullName,
double value,
MetricType metricType)
Creates the metric from the full name and the value.
|
static Metric |
fromProto(Metric metric)
Constructs the metric object from the proto format.
|
String |
getFullMetricName() |
String |
getHostname() |
String |
getInstanceId() |
MetricsSystem.InstanceType |
getInstanceType() |
static String |
getMetricNameWithTags(String name,
String... tags)
Gets the metric name with the appendix of tags.
|
static String |
getMetricNameWithUserTag(String metricName,
String userName)
Gets a metric name with a specific user tag.
|
MetricType |
getMetricType() |
String |
getName() |
Map<String,String> |
getTags() |
double |
getValue() |
int |
hashCode() |
void |
setInstanceId(String instanceId)
Sets the instance id.
|
void |
setValue(double value)
Set the metric value.
|
Metric |
toProto() |
String |
toString() |
public static final String TAG_SEPARATOR
public Metric(MetricsSystem.InstanceType instanceType, String hostname, MetricType metricType, String name, Double value)
Metric
instance.instanceType
- the instance typehostname
- the hostnamemetricType
- the type of the metricname
- the metric namevalue
- the valuepublic Metric(MetricsSystem.InstanceType instanceType, String hostname, String id, MetricType metricType, String name, Double value)
Metric
instance.instanceType
- the instance typehostname
- the hostnameid
- the instance idmetricType
- the type of the metricname
- the metric namevalue
- the valuepublic void addValue(double delta)
MetricsStore
delta
- value to addpublic void setValue(double value)
MetricsStore
value
- value to setpublic double getValue()
public MetricsSystem.InstanceType getInstanceType()
public void addTag(String name, String value)
name
- the tag namevalue
- the tag valuepublic String getHostname()
public MetricType getMetricType()
public String getName()
public String getInstanceId()
public void setInstanceId(String instanceId)
instanceId
- the instance id;public String getFullMetricName()
public Metric toProto()
public static String getMetricNameWithTags(String name, String... tags)
name
- the metric nametags
- the tag name and tag value pairspublic static String getMetricNameWithUserTag(String metricName, String userName)
metricName
- the name of the metricuserName
- the userpublic static Metric from(String fullName, double value, MetricType metricType)
fullName
- the full namevalue
- the valuemetricType
- the type of metric that is being createdpublic static Metric fromProto(Metric metric)
metric
- the metric in proto formatCopyright © 2023. All Rights Reserved.