本文整理了Java中com.netflix.servo.Metric.hasNumberValue()
方法的一些代码示例,展示了Metric.hasNumberValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metric.hasNumberValue()
方法的具体详情如下:
包路径:com.netflix.servo.Metric
类名称:Metric
方法名:hasNumberValue
[英]Returns true if the value for this metric is numeric.
[中]如果此指标的值为数字,则返回true。
代码示例来源:origin: Netflix/servo
/**
* @param metrics The list of metrics you want to send to CloudWatch
*/
@Override
public void updateImpl(List<Metric> metrics) {
Preconditions.checkNotNull(metrics, "metrics");
List<Metric> batch = new ArrayList<>(batchSize);
for (final Metric m : metrics) {
if (m.hasNumberValue()) {
batch.add(m);
if (batch.size() % batchSize == 0) {
putMetricData(batch);
batch.clear();
}
}
}
if (!batch.isEmpty()) {
putMetricData(batch);
}
}
代码示例来源:origin: Netflix/servo
/**
* Create an UpdateRequest to be sent to atlas.
*
* @param tags common tags for all metrics in the request.
* @param metricsToSend Array of metrics to send.
* @param numMetrics How many metrics in the array metricsToSend should be sent. Note
* that this value needs to be lower or equal to metricsToSend.length
*/
public UpdateRequest(TagList tags, Metric[] metricsToSend, int numMetrics) {
Preconditions.checkArgument(metricsToSend.length > 0, "metricsToSend is empty");
Preconditions.checkArgument(numMetrics > 0 && numMetrics <= metricsToSend.length,
"numMetrics is 0 or out of bounds");
this.metrics = new ArrayList<>(numMetrics);
for (int i = 0; i < numMetrics; ++i) {
Metric m = metricsToSend[i];
if (m.hasNumberValue()) {
metrics.add(new AtlasMetric(m));
}
}
this.tags = tags;
}
代码示例来源:origin: com.netflix.servo/servo-aws
/**
* @param metrics The list of metrics you want to send to CloudWatch
*/
@Override
public void updateImpl(List<Metric> metrics) {
Preconditions.checkNotNull(metrics, "metrics");
List<Metric> batch = new ArrayList<>(batchSize);
for (final Metric m : metrics) {
if (m.hasNumberValue()) {
batch.add(m);
if (batch.size() % batchSize == 0) {
putMetricData(batch);
batch.clear();
}
}
}
if (!batch.isEmpty()) {
putMetricData(batch);
}
}
代码示例来源:origin: com.netflix.servo/servo-atlas
/**
* Create an UpdateRequest to be sent to atlas.
*
* @param tags common tags for all metrics in the request.
* @param metricsToSend Array of metrics to send.
* @param numMetrics How many metrics in the array metricsToSend should be sent. Note
* that this value needs to be lower or equal to metricsToSend.length
*/
public UpdateRequest(TagList tags, Metric[] metricsToSend, int numMetrics) {
Preconditions.checkArgument(metricsToSend.length > 0, "metricsToSend is empty");
Preconditions.checkArgument(numMetrics > 0 && numMetrics <= metricsToSend.length,
"numMetrics is 0 or out of bounds");
this.metrics = new ArrayList<>(numMetrics);
for (int i = 0; i < numMetrics; ++i) {
Metric m = metricsToSend[i];
if (m.hasNumberValue()) {
metrics.add(new AtlasMetric(m));
}
}
this.tags = tags;
}
代码示例来源:origin: com.sap.cloud.yaas.service-sdk/service-sdk-monitoring
@Override
public void updateImpl(final List<Metric> metrics)
{
for (final Metric metric : metrics)
{
Object metricValue = metric.getValue();
if (metricValue instanceof Double
&& (((Double) metricValue) == Double.POSITIVE_INFINITY || ((Double) metricValue) == Double.NEGATIVE_INFINITY))
{
metricValue = null;
}
else if (metricValue instanceof Float
&& (((Float) metricValue) == Float.POSITIVE_INFINITY || ((Float) metricValue) == Float.NEGATIVE_INFINITY))
{
metricValue = null;
}
MetricLogger
.newInstance()
.metric(namingConvention.getName(metric))
.type(metric.hasNumberValue() ? MetricType.NUMBER : MetricType.STRING)
.log(metricValue);
}
LOG.debug("Wrote {} metrics to logger", metrics.size());
}
}
代码示例来源:origin: com.redhat.lightblue/lightblue-core-hystrix
@Override
public void updateImpl(List<Metric> metrics) {
// The statsd client doesn't do any checks on the underlying socket's state
// and the socket connects only once, so we cannot trust the socket to stay
// open over a period of time. If this is changed/fixed we could reuse the
// client but until then it cannot be safely reused.
StatsDClient statsd = createClient();
LOGGER.debug("sending data");
try {
for (Metric metric : metrics) {
String aspect = namingConvention.getName(metric);
if (metric.getConfig().getTags().getTag(DataSourceType.COUNTER.getValue()) != null) {
statsd.count(aspect, metric.getNumberValue().longValue());
} else if (metric.hasNumberValue()) {
statsd.gauge(aspect, metric.getNumberValue().longValue());
} else {
statsd.set(aspect, metric.getValue().toString());
}
statsd.time(aspect, metric.getTimestamp() / 1000);
}
} finally {
statsd.stop();
}
}
代码示例来源:origin: com.sap.cloud.yaas.service-sdk/service-sdk-monitoring
private Event buildEvent(final Metric metric)
{
final EventDSL eventBuilder = client.event()//
.host(observerPrefix)//
.service(namingConvention.getName(metric))//
.state("ok")//
.description(null)//
.time(metric.getTimestamp() / SECOND_AS_MILLI);
if (metric.hasNumberValue())
{
eventBuilder.metric(metric.getNumberValue().doubleValue());
}
else if (metric.getValue() != null)
{
eventBuilder.attribute("value", metric.getValue().toString());
}
for (final Tag tag : metric.getConfig().getTags())
{
eventBuilder.tag(tag.getValue());
}
final Event event = eventBuilder.build();
LOG.debug("Creating metric for '{}.{}' with timestamp '{}' and metric '{}' and attributes '{}'", event.getHost(),
event.getService(), event.getTime(), event.getMetricD(), event.getAttributesList());
return event;
}
内容来源于网络,如有侵权,请联系作者删除!