本文整理了Java中com.netflix.servo.Metric.getNumberValue()
方法的一些代码示例,展示了Metric.getNumberValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metric.getNumberValue()
方法的具体详情如下:
包路径:com.netflix.servo.Metric
类名称:Metric
方法名:getNumberValue
[英]Returns the value of the metric as a number.
[中]以数字形式返回度量值。
代码示例来源:origin: Netflix/servo
CounterValue(Metric m) {
this(m.getTimestamp(), m.getNumberValue().doubleValue());
}
代码示例来源:origin: Netflix/servo
private static void addMetric(List<Metric> metrics, Metric metric) {
if (metric.getNumberValue().doubleValue() >= 0.0) {
final MonitorConfig c = metric.getConfig();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Adding " + c.getName() + " " + c.getTags() + " "
+ metric.getNumberValue());
}
metrics.add(metric);
} else {
LOGGER.debug("Ignoring {}", metric);
}
}
代码示例来源:origin: Netflix/servo
public double computeRate(Metric m) {
final long currentTimestamp = m.getTimestamp();
final double currentValue = m.getNumberValue().doubleValue();
final long durationMillis = currentTimestamp - timestamp;
final double delta = currentValue - value;
timestamp = currentTimestamp;
value = currentValue;
return computeRate(durationMillis, delta);
}
代码示例来源:origin: Netflix/servo
AtlasMetric(Metric m) {
this(m.getConfig(), m.getTimestamp(), m.getNumberValue());
}
代码示例来源:origin: Netflix/servo
private Metric normalize(Metric m, long stepBoundary) {
NormalizedValue normalizedValue = cache.get(m.getConfig());
if (normalizedValue == null) {
normalizedValue = new NormalizedValue();
cache.put(m.getConfig(), normalizedValue);
}
double value = normalizedValue.updateAndGet(m.getTimestamp(),
m.getNumberValue().doubleValue());
return new Metric(m.getConfig(), stepBoundary, value);
}
代码示例来源:origin: Netflix/servo
private Map<String, Double> mkMap(List<List<Metric>> updates) {
Map<String, Double> map = new HashMap<>();
for (Metric m : updates.get(0)) {
map.put(m.getConfig().getName(), m.getNumberValue().doubleValue());
}
return map;
}
代码示例来源:origin: Netflix/servo
/**
* {@inheritDoc}
*/
public void update(List<Metric> metrics) {
Preconditions.checkNotNull(metrics, "metrics");
LOGGER.debug("received {} metrics", metrics.size());
final List<Metric> newMetrics = new ArrayList<>(metrics.size());
for (Metric m : metrics) {
if (isCounter(m)) {
final MonitorConfig rateConfig = toRateConfig(m.getConfig());
final CounterValue prev = cache.get(rateConfig);
if (prev != null) {
final double rate = prev.computeRate(m);
newMetrics.add(new Metric(rateConfig, m.getTimestamp(), rate));
} else {
CounterValue current = new CounterValue(m);
cache.put(rateConfig, current);
if (intervalMillis > 0L) {
final double delta = m.getNumberValue().doubleValue();
final double rate = current.computeRate(intervalMillis, delta);
newMetrics.add(new Metric(rateConfig, m.getTimestamp(), rate));
}
}
} else {
newMetrics.add(m);
}
}
LOGGER.debug("writing {} metrics to downstream observer", newMetrics.size());
observer.update(newMetrics);
}
代码示例来源:origin: Netflix/servo
static TimeVal from(Metric m) {
return new TimeVal(m.getTimestamp(), m.getNumberValue().doubleValue());
}
代码示例来源:origin: Netflix/servo
MetricDatum createMetricDatum(Metric metric) {
MetricDatum metricDatum = new MetricDatum();
return metricDatum.withMetricName(metric.getConfig().getName())
.withDimensions(createDimensions(metric.getConfig().getTags()))
.withUnit("None")//DataSourceTypeToAwsUnit.getUnit(metric.))
.withTimestamp(new Date(metric.getTimestamp()))
.withValue(truncate(metric.getNumberValue()));
//TODO Need to convert into reasonable units based on DataType
}
代码示例来源:origin: Netflix/servo
double basicCounterVal = o.get(0).getNumberValue().doubleValue();
double stepCounterVal = o.get(1).getNumberValue().doubleValue();
double gaugeVal = o.get(2).getNumberValue().doubleValue();
assertEquals(gaugeVal, (double) i, DELTA);
assertEquals(o.size(), 3);
double basicCounterVal = o.get(0).getNumberValue().doubleValue();
double stepCounterVal = o.get(1).getNumberValue().doubleValue();
double gaugeVal = o.get(2).getNumberValue().doubleValue();
代码示例来源:origin: com.netflix.servo/servo-core
public CounterValue(Metric m) {
this(m.getTimestamp(), m.getNumberValue().doubleValue());
}
代码示例来源:origin: com.netflix.servo/servo-core
public double computeRate(Metric m) {
final long currentTimestamp = m.getTimestamp();
final double currentValue = m.getNumberValue().doubleValue();
final long durationMillis = currentTimestamp - timestamp;
final double delta = currentValue - value;
timestamp = currentTimestamp;
value = currentValue;
return computeRate(durationMillis, delta);
}
代码示例来源:origin: com.netflix.servo/servo-atlas
AtlasMetric(Metric m) {
this(m.getConfig(), m.getTimestamp(), m.getNumberValue());
}
代码示例来源:origin: com.netflix.servo/servo-core
private Metric normalize(Metric m, long stepBoundary) {
NormalizedValue normalizedValue = cache.get(m.getConfig());
if (normalizedValue == null) {
normalizedValue = new NormalizedValue();
cache.put(m.getConfig(), normalizedValue);
}
double value = normalizedValue.updateAndGet(m.getTimestamp(),
m.getNumberValue().doubleValue());
return new Metric(m.getConfig(), stepBoundary, value);
}
代码示例来源:origin: com.netflix.servo/servo-core
/**
* {@inheritDoc}
*/
public void update(List<Metric> metrics) {
Preconditions.checkNotNull(metrics, "metrics");
LOGGER.debug("received {} metrics", metrics.size());
final List<Metric> newMetrics = new ArrayList<>(metrics.size());
for (Metric m : metrics) {
if (isCounter(m)) {
final MonitorConfig rateConfig = toRateConfig(m.getConfig());
final CounterValue prev = cache.get(rateConfig);
if (prev != null) {
final double rate = prev.computeRate(m);
newMetrics.add(new Metric(rateConfig, m.getTimestamp(), rate));
} else {
CounterValue current = new CounterValue(m);
cache.put(rateConfig, current);
if (intervalMillis > 0L) {
final double delta = m.getNumberValue().doubleValue();
final double rate = current.computeRate(intervalMillis, delta);
newMetrics.add(new Metric(rateConfig, m.getTimestamp(), rate));
}
}
} else {
newMetrics.add(m);
}
}
LOGGER.debug("writing {} metrics to downstream observer", newMetrics.size());
observer.update(newMetrics);
}
代码示例来源: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.netflix.servo/servo-aws
MetricDatum createMetricDatum(Metric metric) {
MetricDatum metricDatum = new MetricDatum();
return metricDatum.withMetricName(metric.getConfig().getName())
.withDimensions(createDimensions(metric.getConfig().getTags()))
.withUnit("None")//DataSourceTypeToAwsUnit.getUnit(metric.))
.withTimestamp(new Date(metric.getTimestamp()))
.withValue(truncate(metric.getNumberValue()));
//TODO Need to convert into reasonable units based on DataType
}
代码示例来源: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;
}
内容来源于网络,如有侵权,请联系作者删除!