本文整理汇总了Java中com.spotify.metrics.core.MetricId类的典型用法代码示例。如果您正苦于以下问题:Java MetricId类的具体用法?Java MetricId怎么用?Java MetricId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MetricId类属于com.spotify.metrics.core包,在下文中一共展示了MetricId类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
registry.register(MetricId.build("jvm-memory"), new MemoryUsageGaugeSet());
registry.register(MetricId.build("jvm-gc"), new GarbageCollectorMetricSet());
registry.register(MetricId.build("jvm-threads"), new ThreadStatesMetricSet());
registry.register(MetricId.build("jvm-cpu"), CpuGaugeSet.create());
registry.register(MetricId.build("jvm-fd-ratio"), new FileDescriptorGaugeSet());
final FastForwardReporter reporter = FastForwardReporter
.forRegistry(registry)
.prefix(APP_PREFIX)
.schedule(TimeUnit.SECONDS, 5)
.build();
reporter.start();
System.out.println("Sending jvm metrics...");
System.in.read();
reporter.stop();
}
开发者ID:spotify,项目名称:semantic-metrics,代码行数:21,代码来源:JvmExample.java
示例2: reportGauge
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
private void reportGauge(
MetricId key, @SuppressWarnings("rawtypes") Gauge value
) {
if (value == null) {
return;
}
key = MetricId.join(prefix, key);
final Metric m = FastForward
.metric(key.getKey())
.attributes(key.getTags())
.attribute(METRIC_TYPE, "gauge");
send(m.value(convert(value.getValue())));
}
开发者ID:spotify,项目名称:semantic-metrics,代码行数:17,代码来源:FastForwardReporter.java
示例3: newMetric
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
@Override
public RemoteHistogram newMetric(
final MetricId id,
final List<String> shardKey,
final Remote remote) {
final Map<String, String> allAttributes =
SemanticAggregator.buildAttributes(id, "histogram");
final String shard =
Sharder.buildShardKey(shardKey, allAttributes);
return new RemoteHistogram() {
@Override
public ListenableFuture<Integer> update(long value) {
return remote.post(
"/",
shard,
SemanticAggregator.buildDocument(
Long.toString(value),
id.getKey(),
allAttributes));
}
};
}
开发者ID:spotify,项目名称:semantic-metrics,代码行数:25,代码来源:SemanticAggregatorMetricBuilder.java
示例4: joinKeys
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
private String joinKeys(MetricId... parts) {
final StringBuilder key = new StringBuilder();
for (final MetricId part : parts) {
final String name = part.getKey();
if (name != null && !name.isEmpty()) {
if (key.length() > 0) {
key.append('.');
}
key.append(name);
}
}
return key.toString();
}
开发者ID:spotify,项目名称:semantic-metrics,代码行数:18,代码来源:FastForwardHttpReporter.java
示例5: setupStatistics
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
private static Statistics setupStatistics() throws IOException {
final String key = System.getProperty("ffwd.key", "ffwd-java");
final SemanticMetricRegistry registry = new SemanticMetricRegistry();
final SemanticCoreStatistics statistics = new SemanticCoreStatistics(registry);
final MetricId gauges = MetricId.build();
registry.register(gauges, new ThreadStatesMetricSet());
registry.register(gauges, new GarbageCollectorMetricSet());
registry.register(gauges, new MemoryUsageGaugeSet());
final MetricId metric = MetricId.build(key);
final FastForwardReporter ffwd = FastForwardReporter
.forRegistry(registry)
.schedule(TimeUnit.SECONDS, 30)
.prefix(metric)
.build();
ffwd.start();
return new Statistics(ffwd, statistics);
}
开发者ID:spotify,项目名称:ffwd,代码行数:25,代码来源:FastForwardAgent.java
示例6: SemanticSuggestBackendReporter
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
public SemanticSuggestBackendReporter(SemanticMetricRegistry registry) {
final MetricId base = MetricId.build().tagged("component", COMPONENT);
tagValuesSuggest = new SemanticFutureReporter(registry,
base.tagged("what", "tag-values-suggest", "unit", Units.QUERY));
tagKeyCount = new SemanticFutureReporter(registry,
base.tagged("what", "tag-key-count", "unit", Units.QUERY));
tagSuggest = new SemanticFutureReporter(registry,
base.tagged("what", "tag-suggest", "unit", Units.QUERY));
keySuggest = new SemanticFutureReporter(registry,
base.tagged("what", "key-suggest", "unit", Units.QUERY));
tagValueSuggest = new SemanticFutureReporter(registry,
base.tagged("what", "tag-value-suggest", "unit", Units.QUERY));
write =
new SemanticFutureReporter(registry, base.tagged("what", "write", "unit", Units.WRITE));
backendWrite = new SemanticFutureReporter(registry,
base.tagged("what", "backend-write", "unit", Units.WRITE));
writesDroppedByCacheHit =
registry.meter(base.tagged("what", "writes-dropped-by-cache-hit", "unit", Units.DROP));
writesDroppedByRateLimit =
registry.meter(base.tagged("what", "writes-dropped-by-rate-limit", "unit", Units.DROP));
writesDroppedByDuplicate =
registry.meter(base.tagged("what", "writes-dropped-by-duplicate", "unit", Units.DROP));
}
开发者ID:spotify,项目名称:heroic,代码行数:26,代码来源:SemanticSuggestBackendReporter.java
示例7: SemanticFutureReporter
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
public SemanticFutureReporter(SemanticMetricRegistry registry, MetricId id) {
final String what = id.getTags().get("what");
if (what == null) {
throw new IllegalArgumentException("id does not provide the tag 'what'");
}
this.timer = new SemanticHeroicTimer(registry.timer(id.tagged("what", what + "-latency")));
this.failed =
registry.meter(id.tagged("what", what + "-failure-rate", "unit", Units.FAILURE));
this.resolved =
registry.meter(id.tagged("what", what + "-resolve-rate", "unit", Units.RESOLVE));
this.cancelled =
registry.meter(id.tagged("what", what + "-cancel-rate", "unit", Units.CANCEL));
this.pending =
registry.counter(id.tagged("what", what + "-pending", "unit", Units.COUNT));
}
开发者ID:spotify,项目名称:heroic,代码行数:18,代码来源:SemanticFutureReporter.java
示例8: main
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
final MetricId base = MetricId.build("current-thing");
final FastForwardReporter reporter = FastForwardReporter
.forRegistry(registry)
.prefix(APP_PREFIX)
.schedule(TimeUnit.SECONDS, 5)
.build();
reporter.start();
final String[] things = {
"shoe", "bucket", "chair"
};
for (int i = 0; i < things.length; i++) {
final String thing = things[i];
Thread.sleep(1000);
final Meter meter =
registry.meter(base.tagged("thing", thing).tagged("index", Integer.toString(i)));
meter.mark(10 * i);
}
System.out.println("Sending dynamic metrics...");
System.in.read();
reporter.stop();
}
开发者ID:spotify,项目名称:semantic-metrics,代码行数:29,代码来源:DynamicMetricExample.java
示例9: get
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
@Override
public MetricId get(final MetricId base, final T key) throws ExecutionException {
return cache.get(key, new Callable<MetricId>() {
@Override
public MetricId call() throws Exception {
return loader.load(base, key);
}
});
}
开发者ID:spotify,项目名称:semantic-metrics,代码行数:10,代码来源:GuavaCache.java
示例10: testSomeCached
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
@Test
public void testSomeCached() {
Assert.assertEquals(MetricId.EMPTY.tagged("endpoint", "foo"), endpointCache.get("foo"));
Assert.assertEquals(MetricId.EMPTY.tagged("endpoint", "foo"), endpointCache.get("foo"));
Assert.assertEquals(1, callCount.get());
Assert.assertEquals(MetricId.EMPTY.tagged("endpoint", "bar"), endpointCache.get("bar"));
Assert.assertEquals(2, callCount.get());
}
开发者ID:spotify,项目名称:semantic-metrics,代码行数:10,代码来源:GuavaCacheTest.java
示例11: FastForwardReporter
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
private FastForwardReporter(
SemanticMetricRegistry registry, MetricId prefix, TimeUnit unit, long duration,
FastForward client, Set<Percentile> histogramPercentiles
) {
this.registry = registry;
this.prefix = prefix;
this.unit = unit;
this.duration = duration;
this.client = client;
this.histogramPercentiles = new HashSet<>(histogramPercentiles);
}
开发者ID:spotify,项目名称:semantic-metrics,代码行数:12,代码来源:FastForwardReporter.java
示例12: reportCounter
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
private void reportCounter(MetricId key, Counting value) {
key = MetricId.join(prefix, key);
final Metric m = FastForward
.metric(key.getKey())
.attributes(key.getTags())
.attribute(METRIC_TYPE, "counter");
send(m.value(value.getCount()));
}
开发者ID:spotify,项目名称:semantic-metrics,代码行数:11,代码来源:FastForwardReporter.java
示例13: reportHistogram
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
private void reportHistogram(MetricId key, Histogram value) {
key = MetricId.join(prefix, key);
final Metric m = FastForward
.metric(key.getKey())
.attributes(key.getTags())
.attribute(METRIC_TYPE, "histogram");
reportHistogram(m, value.getSnapshot());
}
开发者ID:spotify,项目名称:semantic-metrics,代码行数:11,代码来源:FastForwardReporter.java
示例14: reportMetered
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
private void reportMetered(MetricId key, Meter value) {
key = MetricId.join(prefix, key);
final Metric m = FastForward
.metric(key.getKey())
.attributes(key.getTags())
.attribute(METRIC_TYPE, "meter");
reportMetered(m, value);
reportCounter(key, value);
}
开发者ID:spotify,项目名称:semantic-metrics,代码行数:12,代码来源:FastForwardReporter.java
示例15: reportTimer
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
private void reportTimer(MetricId key, Timer value) {
key = MetricId.join(prefix, key);
final Metric m = FastForward
.metric(key.getKey())
.attributes(key.getTags())
.attribute(METRIC_TYPE, "timer")
.attribute("unit", "ns");
reportMetered(m, value);
reportHistogram(m, value.getSnapshot());
}
开发者ID:spotify,项目名称:semantic-metrics,代码行数:13,代码来源:FastForwardReporter.java
示例16: reportDerivingMeter
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
private void reportDerivingMeter(MetricId key, DerivingMeter value) {
key = MetricId.join(prefix, key);
final Metric m = FastForward
.metric(key.getKey())
.attributes(key.getTags())
.attribute(METRIC_TYPE, "deriving-meter");
reportMetered(m, value);
}
开发者ID:spotify,项目名称:semantic-metrics,代码行数:11,代码来源:FastForwardReporter.java
示例17: setUp
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
registry = new SemanticMetricRegistry();
fastForward = mock(FastForward.class);
reporter = FastForwardReporter
.forRegistry(registry)
.schedule(TimeUnit.MILLISECONDS, REPORTING_PERIOD)
.fastForward(fastForward)
.build();
registry.counter(MetricId.build("hi"));
}
开发者ID:spotify,项目名称:semantic-metrics,代码行数:14,代码来源:FastForwardReporterTest.java
示例18: getOrAdd
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
public <T extends RemoteMetric> T getOrAdd(
final MetricId name,
final List<String> shardKey,
final SemanticAggregatorMetricBuilder<T> builder
) {
final RemoteMetric metric = metrics.get(name);
if (metric != null) {
if (!builder.isInstance(metric)) {
throw new IllegalArgumentException(
name + " is already used for a different type of metric");
}
return (T) metric;
}
final T addition = builder.newMetric(name, shardKey, remote);
final RemoteMetric previous = metrics.putIfAbsent(name, addition);
if (previous == null) {
return addition;
}
if (!builder.isInstance(previous)) {
throw new IllegalArgumentException(
name + " is already used for a different type of metric");
}
return (T) previous;
}
开发者ID:spotify,项目名称:semantic-metrics,代码行数:32,代码来源:SemanticAggregatorMetricRegistry.java
示例19: SemanticAggregatorTimer
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
public SemanticAggregatorTimer(
final MetricId id,
final List<String> shardKey,
final Remote remote,
final TimeSource timeSource) {
this.key = id.getKey();
this.remote = remote;
this.timeSource = timeSource;
allAttributes = SemanticAggregator.buildAttributes(id, "timer");
shard = Sharder.buildShardKey(shardKey, allAttributes);
}
开发者ID:spotify,项目名称:semantic-metrics,代码行数:12,代码来源:SemanticAggregatorTimer.java
示例20: getMetrics
import com.spotify.metrics.core.MetricId; //导入依赖的package包/类
@Override
public Map<MetricId, Metric> getMetrics() {
final Map<MetricId, Metric> gauges = new HashMap<MetricId, Metric>();
final MetricId base = MetricId.build();
for (final GarbageCollectorMXBean m : garbageCollectors) {
final MetricId gc = base.tagged("gc", m.getName());
final MetricId collectionCount =
gc.tagged("what", "jvm-gc-collections", "unit", "collection/s");
final MetricId collectionTime =
gc.tagged("what", "jvm-gc-collection-time", "unit", "ms/s");
gauges.put(collectionCount, new DerivedLongGauge() {
@Override
public Long getNext() {
return m.getCollectionCount();
}
});
gauges.put(collectionTime, new DerivedLongGauge() {
@Override
public Long getNext() {
return m.getCollectionTime();
}
});
}
return Collections.unmodifiableMap(gauges);
}
开发者ID:spotify,项目名称:semantic-metrics,代码行数:31,代码来源:GarbageCollectorMetricSet.java
注:本文中的com.spotify.metrics.core.MetricId类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论