本文整理了Java中com.netflix.servo.Metric.getConfig()
方法的一些代码示例,展示了Metric.getConfig()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metric.getConfig()
方法的具体详情如下:
包路径:com.netflix.servo.Metric
类名称:Metric
方法名:getConfig
[英]Returns the config settings associated with the metric.
[中]返回与指标关联的配置设置。
代码示例来源:origin: Netflix/servo
public void add(Metric m) {
if (filter.matches(m.getConfig())) {
list.add(m);
}
}
代码示例来源:origin: Netflix/servo
/**
* {@inheritDoc}
*/
public final List<Metric> poll(MetricFilter filter, boolean reset) {
Preconditions.checkNotNull(filter, "filter");
List<Metric> metrics = pollImpl(reset);
List<Metric> retained = metrics.stream().filter(m -> filter.matches(m.getConfig()))
.collect(Collectors.toList());
logger.debug("received {} metrics, retained {} metrics", metrics.size(), retained.size());
return Collections.unmodifiableList(retained);
}
}
代码示例来源: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 boolean isCounter(Metric m) {
final TagList tags = m.getConfig().getTags();
final String value = tags.getValue(DataSourceType.KEY);
return COUNTER_VALUE.equals(value);
}
代码示例来源: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
private static String getDataSourceType(Metric m) {
final TagList tags = m.getConfig().getTags();
final String value = tags.getValue(DataSourceType.KEY);
if (value != null) {
return value;
} else {
return DEFAULT_DSTYPE;
}
}
代码示例来源:origin: Netflix/servo
protected static boolean isCounter(Metric m) {
final TagList tags = m.getConfig().getTags();
final String value = tags.getValue(DataSourceType.KEY);
return value != null && value.equals(DataSourceType.COUNTER.name());
}
代码示例来源:origin: Netflix/servo
/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof Metric)) {
return false;
}
Metric m = (Metric) obj;
return config.equals(m.getConfig())
&& timestamp == m.getTimestamp()
&& value.equals(m.getValue());
}
代码示例来源:origin: Netflix/servo
protected static boolean isGauge(Metric m) {
final TagList tags = m.getConfig().getTags();
final String value = tags.getValue(DataSourceType.KEY);
return value != null && value.equals(DataSourceType.GAUGE.name());
}
代码示例来源:origin: Netflix/servo
protected static boolean isRate(Metric m) {
final TagList tags = m.getConfig().getTags();
final String value = tags.getValue(DataSourceType.KEY);
return DataSourceType.RATE.name().equals(value)
|| DataSourceType.NORMALIZED.name().equals(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
private Map<String, String> mkTypeMap(List<List<Metric>> updates) {
Map<String, String> map = new HashMap<>();
for (Metric m : updates.get(0)) {
map.put(m.getConfig().getName(), m.getConfig().getTags().getValue(DataSourceType.KEY));
}
return map;
}
代码示例来源:origin: Netflix/servo
@Override
public String getName(Metric metric) {
MonitorConfig config = metric.getConfig();
TagList tags = config.getTags();
Tag domainTag = tags.getTag(JMX_DOMAIN_KEY);
if (domainTag != null) { // jmx metric
return handleJmxMetric(config, tags);
} else {
return handleMetric(config, tags);
}
}
代码示例来源:origin: Netflix/servo
protected static Metric asGauge(Metric m) {
return new Metric(m.getConfig().withAdditionalTag(ATLAS_GAUGE_TAG),
m.getTimestamp(), m.getValue());
}
代码示例来源:origin: Netflix/servo
protected static Metric asCounter(Metric m) {
return new Metric(m.getConfig().withAdditionalTag(ATLAS_COUNTER_TAG),
m.getTimestamp(), m.getValue());
}
代码示例来源:origin: Netflix/servo
@Test
public void testNullTags() throws Exception {
long now = System.currentTimeMillis();
Metric m = new Metric("a", null, now, 42);
assertEquals(m.getConfig(), new MonitorConfig.Builder("a").build());
}
代码示例来源: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
@Test
public void testAccessors() throws Exception {
long now = System.currentTimeMillis();
Metric m1 = new Metric("a", tags1, now, 42);
assertEquals(m1.getConfig(), new MonitorConfig.Builder("a").withTags(tags1).build());
assertEquals(m1.getTimestamp(), now);
assertEquals(m1.getValue(), 42);
}
代码示例来源:origin: Netflix/servo
@Test
public void testDefaultTags() throws Exception {
MetricPoller poller = new JmxMetricPoller(
new LocalJmxConnector(),
Collections.singletonList(new ObjectName("java.lang:type=OperatingSystem")),
MATCH_ALL,
true,
Collections.singletonList(Tags.newTag("HostName", "localhost")));
List<Metric> metrics = poller.poll(MATCH_ALL);
for (Metric m : metrics) {
Map<String, String> tags = m.getConfig().getTags().asMap();
assertEquals(tags.get("HostName"), "localhost");
}
}
代码示例来源:origin: Netflix/servo
@Test
public void testBasic() throws Exception {
MonitorRegistry registry = new BasicMonitorRegistry();
registry.register(Monitors.newCounter("test"));
MetricPoller poller = new MonitorRegistryMetricPoller(registry);
Metric metric = poller.poll(MATCH_ALL).get(0);
MonitorConfig expected = MonitorConfig.builder("test")
.withTag(DataSourceType.COUNTER)
.build();
assertEquals(metric.getConfig(), expected);
}
内容来源于网络,如有侵权,请联系作者删除!