本文整理了Java中com.netflix.servo.Metric.<init>()
方法的一些代码示例,展示了Metric.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metric.<init>()
方法的具体详情如下:
包路径:com.netflix.servo.Metric
类名称:Metric
方法名:<init>
[英]Creates a new instance.
[中]创建一个新实例。
代码示例来源:origin: Netflix/servo
private List<Metric> mkList(long ts, int value) {
return UnmodifiableList.of(
new Metric("m1", SortedTagList.EMPTY, ts, value),
new Metric("m2", GAUGE, ts, value),
new Metric("m3", COUNTER, ts, value)
);
}
代码示例来源:origin: Netflix/servo
private void addGarbageCollectorMetrics(long timestamp, MetricList metrics) {
final List<GarbageCollectorMXBean> beans = ManagementFactory.getGarbageCollectorMXBeans();
for (GarbageCollectorMXBean bean : beans) {
final Tag id = Tags.newTag("id", bean.getName());
metrics.add(new Metric(COLLECTION_COUNT.withAdditionalTag(id),
timestamp, bean.getCollectionCount()));
metrics.add(new Metric(COLLECTION_TIME.withAdditionalTag(id),
timestamp, bean.getCollectionTime()));
}
}
代码示例来源:origin: Netflix/servo
private void addMemoryUsageMetrics(
TagList tags, long timestamp, MemoryUsage usage, MetricList metrics) {
metrics.add(new Metric(COMMITTED_USAGE.withAdditionalTags(tags),
timestamp, usage.getCommitted()));
metrics.add(new Metric(INIT_USAGE.withAdditionalTags(tags), timestamp, usage.getInit()));
metrics.add(new Metric(ACTUAL_USAGE.withAdditionalTags(tags), timestamp, usage.getUsed()));
metrics.add(new Metric(MAX_USAGE.withAdditionalTags(tags), timestamp, usage.getMax()));
}
代码示例来源:origin: Netflix/servo
private List<Metric> mkList(int v) {
List<Metric> metrics = new ArrayList<>(v);
for (int i = 0; i < v; ++i) {
metrics.add(new Metric("m", TAGS, 0L, i));
}
return metrics;
}
代码示例来源:origin: Netflix/servo
@Test(expectedExceptions = NullPointerException.class)
public void testNullValue() throws Exception {
long now = System.currentTimeMillis();
new Metric("a", tags1, now, null);
}
代码示例来源:origin: Netflix/servo
private static Metric toMetric(long t, ObjectName name, Attribute attribute, Tag dsType) {
Tag id = Tags.newTag("id", name.getKeyProperty("name"));
Tag clazz = Tags.newTag("class", name.getKeyProperty("type"));
TagList list = BasicTagList.of(id, clazz, dsType);
return new Metric(normalizeName(attribute.getName()), list, t, attribute.getValue());
}
代码示例来源:origin: Netflix/servo
@Test(expectedExceptions = NullPointerException.class)
public void testNullName() throws Exception {
long now = System.currentTimeMillis();
new Metric(null, tags1, now, 42);
}
代码示例来源:origin: Netflix/servo
private void addClassLoadingMetrics(long timestamp, MetricList metrics) {
ClassLoadingMXBean bean = ManagementFactory.getClassLoadingMXBean();
metrics.add(new Metric(LOADED_CLASS_COUNT,
timestamp, bean.getLoadedClassCount()));
metrics.add(new Metric(TOTAL_LOADED_CLASS_COUNT,
timestamp, bean.getTotalLoadedClassCount()));
metrics.add(new Metric(UNLOADED_CLASS_COUNT,
timestamp, bean.getUnloadedClassCount()));
}
代码示例来源:origin: Netflix/servo
private void addThreadMetrics(long timestamp, MetricList metrics) {
ThreadMXBean bean = ManagementFactory.getThreadMXBean();
metrics.add(new Metric(DAEMON_THREAD_COUNT, timestamp, bean.getDaemonThreadCount()));
metrics.add(new Metric(TOTAL_STARTED_THREAD_COUNT,
timestamp, bean.getTotalStartedThreadCount()));
addDetailedThreadMetrics(timestamp, metrics);
}
代码示例来源: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
@Test
public void testEquals() throws Exception {
long now = System.currentTimeMillis();
Metric m1 = new Metric("a", tags1, now, 42);
Metric m2 = new Metric("a", tags2, now, 42);
Metric m3 = new Metric("a", tags1, now, 42);
assertNotNull(m1);
assertFalse(m1.toString().equals(m2.toString()));
assertTrue(m1.equals(m1));
assertFalse(m1.equals(m2));
assertTrue(m1.equals(m3));
}
代码示例来源:origin: Netflix/servo
@Test
public void testMetricNamingEmptyTags() throws Exception {
Metric m = new Metric("simpleMonitor", SortedTagList.EMPTY, 0, 1000.0);
GraphiteNamingConvention convention = new BasicGraphiteNamingConvention();
String name = convention.getName(m);
assertEquals(name, "simpleMonitor");
}
代码示例来源: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
@Test
public void testMetricNamingWithTags() throws Exception {
TagList tagList = BasicTagList.of("instance", "GetLogs", DataSourceType.KEY,
"HystrixCommand");
Metric m = new Metric("simpleMonitor", tagList, 0, 1000.0);
GraphiteNamingConvention convention = new BasicGraphiteNamingConvention();
String name = convention.getName(m);
assertEquals(name, "HystrixCommand.GetLogs.simpleMonitor");
}
代码示例来源: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
private List<Metric> mkList() {
return UnmodifiableList.of(
new Metric("m1", SortedTagList.EMPTY, 0L, 0),
new Metric("m2", SortedTagList.builder().withTag("c", "a.b.c.d.M1").build(), 0L, 0),
new Metric("m3", SortedTagList.builder().withTag("c", "a.b.c.c.M3").build(), 0L, 0),
new Metric("m4", SortedTagList.builder().withTag("c", "a.b.c.d.M4").build(), 0L, 0),
new Metric("m5", SortedTagList.builder().withTag("c", "a.a.a.a.M5").build(), 0L, 0)
);
}
代码示例来源:origin: Netflix/servo
private List<Metric> mkList() {
return UnmodifiableList.of(
new Metric("m1", SortedTagList.EMPTY, 0L, 0),
new Metric("m2", SortedTagList.builder().withTag("c", "a.b.c.d.M1").build(), 0L, 0),
new Metric("m3", SortedTagList.builder().withTag("c", "a.b.c.c.M3").build(), 0L, 0),
new Metric("m4", SortedTagList.builder().withTag("c", "a.b.c.d.M4").build(), 0L, 0),
new Metric("m5", SortedTagList.builder().withTag("c", "a.a.a.a.M5").build(), 0L, 0)
);
}
代码示例来源:origin: Netflix/servo
private static Metric metric(String name, double value, Tag metricType) {
MonitorConfig config = MonitorConfig.builder(name).withTag(metricType)
.withTag("class", "ApacheStatusPoller").build();
return new Metric(config, TIMESTAMP, value);
}
代码示例来源:origin: Netflix/servo
private static Metric scoreboard(String state, double value) {
MonitorConfig config = MonitorConfig.builder("Scoreboard")
.withTag(DataSourceType.GAUGE)
.withTag("state", state)
.withTag("class", "ApacheStatusPoller").build();
return new Metric(config, TIMESTAMP, value);
}
内容来源于网络,如有侵权,请联系作者删除!