com.spotify.metrics.core.MetricId Java Examples
The following examples show how to use
com.spotify.metrics.core.MetricId.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SemanticFutureReporter.java From heroic with Apache License 2.0 | 6 votes |
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.counter(id.tagged("what", what + "-failed", "unit", Units.COUNT)); this.resolved = registry.counter(id.tagged("what", what + "-resolved", "unit", Units.COUNT)); this.cancelled = registry.counter(id.tagged("what", what + "-cancelled", "unit", Units.COUNT)); this.pending = registry.counter(id.tagged("what", what + "-pending", "unit", Units.COUNT)); }
Example #2
Source File: SemanticAggregatorMetricBuilder.java From semantic-metrics with Apache License 2.0 | 6 votes |
@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)); } }; }
Example #3
Source File: FastForwardHttpReporter.java From semantic-metrics with Apache License 2.0 | 6 votes |
private FastForwardHttpReporter( SemanticMetricRegistry registry, MetricId prefix, TimeUnit unit, long duration, HttpClient client, Set<Percentile> histogramPercentiles, Clock clock, TagExtractor tagExtractor, ScheduledExecutorService executorService, boolean executorOwner ) { this.registry = registry; this.prefix = prefix; this.unit = unit; this.duration = duration; this.client = client; this.histogramPercentiles = new HashSet<>(histogramPercentiles); this.clock = clock; this.tagExtractor = tagExtractor; this.executorService = executorService; this.executorOwner = executorOwner; }
Example #4
Source File: FastForwardHttpReporter.java From semantic-metrics with Apache License 2.0 | 6 votes |
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(); }
Example #5
Source File: FastForwardHttpReporterTest.java From semantic-metrics with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { registry = new SemanticMetricRegistry(); fixedClock = new Clock.Fixed(0L); commonTags = of("foo", "bar"); executorService = new DeterministicScheduler(); reporter = FastForwardHttpReporter .forRegistry(registry, httpClient) .schedule(REPORTING_PERIOD, TimeUnit.MILLISECONDS) .prefix(MetricId.build("prefix").tagged(commonTags)) .clock(fixedClock) .executorService(executorService) .build(); }
Example #6
Source File: FastForwardAgent.java From ffwd with Apache License 2.0 | 6 votes |
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); }
Example #7
Source File: SemanticCoreStatistics.java From ffwd with Apache License 2.0 | 6 votes |
@Override public InputManagerStatistics newInputManager() { final MetricId m = metric.tagged("component", "input-manager"); return new InputManagerStatistics() { private final Meter receivedMetrics = registry.meter(m.tagged("what", "received-metrics", "unit", "metric")); private final Meter metricsDroppedByFilter = registry.meter(m.tagged("what", "metrics-dropped-by-filter", "unit", "metric")); @Override public void reportReceivedMetrics(int received) { receivedMetrics.mark(received); } @Override public void reportMetricsDroppedByFilter(int dropped) { metricsDroppedByFilter.mark(dropped); } }; }
Example #8
Source File: SemanticSuggestBackendReporter.java From heroic with Apache License 2.0 | 6 votes |
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.counter( base.tagged("what", "writes-dropped-by-cache-hit", "unit", Units.COUNT)); writesDroppedByDuplicate = registry.counter( base.tagged("what", "writes-dropped-by-duplicate", "unit", Units.COUNT)); }
Example #9
Source File: JvmExample.java From semantic-metrics with Apache License 2.0 | 6 votes |
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(); }
Example #10
Source File: MemoryUsageGaugeSet.java From semantic-metrics with Apache License 2.0 | 5 votes |
private void putGauges( final Map<MetricId, Metric> gauges, final MetricId nonHeap, final MemoryUsageSupplier memoryUsageSupplier ) { gauges.put(nonHeap.tagged("memory_category", "init"), new Gauge<Long>() { @Override public Long getValue() { return memoryUsageSupplier.get().getInit(); } }); gauges.put(nonHeap.tagged("memory_category", "used"), new Gauge<Long>() { @Override public Long getValue() { return memoryUsageSupplier.get().getUsed(); } }); gauges.put(nonHeap.tagged("memory_category", "max"), new Gauge<Long>() { @Override public Long getValue() { return memoryUsageSupplier.get().getMax(); } }); gauges.put(nonHeap.tagged("memory_category", "committed"), new Gauge<Long>() { @Override public Long getValue() { return memoryUsageSupplier.get().getCommitted(); } }); }
Example #11
Source File: FastForwardReporter.java From semantic-metrics with Apache License 2.0 | 5 votes |
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); }
Example #12
Source File: FastForwardReporter.java From semantic-metrics with Apache License 2.0 | 5 votes |
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())); }
Example #13
Source File: FastForwardReporter.java From semantic-metrics with Apache License 2.0 | 5 votes |
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()); }
Example #14
Source File: FastForwardReporter.java From semantic-metrics with Apache License 2.0 | 5 votes |
private void reportGauge( MetricId key, @SuppressWarnings("rawtypes") Gauge value ) { 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()))); }
Example #15
Source File: SemanticAggregatorMetricBuilder.java From semantic-metrics with Apache License 2.0 | 5 votes |
@Override public RemoteMeter newMetric( final MetricId id, final List<String> shardKey, final Remote remote) { final Map<String, String> allAttributes = SemanticAggregator.buildAttributes(id, "meter"); final String shard = Sharder.buildShardKey(shardKey, allAttributes); return new RemoteMeter() { @Override public ListenableFuture<Integer> mark() { return mark(1); } @Override public ListenableFuture<Integer> mark(long n) { return remote.post( "/", shard, SemanticAggregator.buildDocument( Long.toString(n), id.getKey(), allAttributes)); } }; }
Example #16
Source File: SemanticAggregatorMetricBuilder.java From semantic-metrics with Apache License 2.0 | 5 votes |
@Override public RemoteDerivingMeter newMetric( final MetricId id, final List<String> shardKey, final Remote remote) { final Map<String, String> allAttributes = SemanticAggregator.buildAttributes(id, "deriving_meter"); final String shard = Sharder.buildShardKey(shardKey, allAttributes); return new RemoteDerivingMeter() { @Override public ListenableFuture<Integer> mark() { return mark(1); } @Override public ListenableFuture<Integer> mark(long n) { return remote.post( "/", shard, SemanticAggregator.buildDocument( Long.toString(n), id.getKey(), allAttributes)); } }; }
Example #17
Source File: SemanticPredictorMetrics.java From zoltar with Apache License 2.0 | 5 votes |
static Metrics create(final SemanticMetricRegistry registry, final MetricId metricId) { final MetricId predictDurationId = metricId.tagged("what", PREDICT_DURATION.tag()); final MetricId predictRateId = metricId.tagged("what", PREDICT_RATE.tag()); final MetricId extractDuration = metricId.tagged("what", FEATURE_EXTRACT_DURATION.tag()); final MetricId extractRate = metricId.tagged("what", FEATURE_EXTRACT_RATE.tag()); final Timer predictTimer = registry.timer(predictDurationId); final Meter predictMeter = registry.meter(predictRateId); final Timer extractTimer = registry.timer(extractDuration); final Meter extractMeter = registry.meter(extractRate); return new AutoValue_SemanticPredictorMetrics_Metrics( predictTimer, predictMeter, extractTimer, extractMeter); }
Example #18
Source File: SemanticAggregatorTimer.java From semantic-metrics with Apache License 2.0 | 5 votes |
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); }
Example #19
Source File: GarbageCollectorMetricSet.java From semantic-metrics with Apache License 2.0 | 5 votes |
@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); }
Example #20
Source File: FileDescriptorGaugeSet.java From semantic-metrics with Apache License 2.0 | 5 votes |
@Override public Map<MetricId, Metric> getMetrics() { final Map<MetricId, Metric> gauges = new HashMap<MetricId, Metric>(); final MetricId metricId = MetricId.build().tagged("what", "file-descriptor-ratio", "unit", "%"); gauges.put(metricId, new Gauge<Object>() { @Override public Object getValue() { return fileDescriptorRatioGauge.getValue(); } }); return Collections.unmodifiableMap(gauges); }
Example #21
Source File: SemanticMetricBackendReporter.java From heroic with Apache License 2.0 | 5 votes |
public SemanticMetricBackendReporter(SemanticMetricRegistry registry) { final MetricId base = MetricId.build().tagged("component", COMPONENT); this.write = new SemanticFutureReporter(registry, base.tagged("what", "write", "unit", Units.WRITE)); this.fetch = new SemanticFutureReporter(registry, base.tagged("what", "fetch", "unit", Units.QUERY)); this.deleteKey = new SemanticFutureReporter(registry, base.tagged("what", "delete-key", "unit", Units.DELETE)); this.countKey = new SemanticFutureReporter(registry, base.tagged("what", "count-key", "unit", Units.QUERY)); this.fetchRow = new SemanticFutureReporter(registry, base.tagged("what", "fetch-row", "unit", Units.QUERY)); this.findSeries = new SemanticFutureReporter(registry, base.tagged("what", "find-series", "unit", Units.QUERY)); this.queryMetrics = new SemanticFutureReporter(registry, base.tagged("what", "query-metrics", "unit", Units.QUERY)); sampleSizeLive = registry.counter( base.tagged("what", "sample-size-live", "unit", Units.SAMPLE)); sampleSizeAccumulated = registry.counter( base.tagged("what", "sample-size-accumulated", "unit", Units.SAMPLE)); querySamplesRead = registry.histogram( base.tagged("what", "query-metrics-samples-read", "unit", Units.COUNT)); queryRowsAccessed = registry.histogram( base.tagged("what", "query-metrics-rows-accessed", "unit", Units.COUNT)); queryMaxLiveSamples = registry.histogram( base.tagged("what", "query-metrics-max-live-samples", "unit", Units.COUNT)); queryReadRate = registry.histogram( base.tagged("what", "query-metrics-read-rate", "unit", Units.COUNT)); queryRowMsBetweenSamples = registry.histogram( base.tagged("what", "query-metrics-row-metric-distance", "unit", Units.MILLISECOND)); queryRowDensity = registry.histogram( base.tagged("what", "query-metrics-row-density", "unit", Units.COUNT)); }
Example #22
Source File: FastForwardHttpReporter.java From semantic-metrics with Apache License 2.0 | 5 votes |
private BatchBuilder createBuilder( final List<Batch.Point> points, final long timestamp, final MetricId id, final String metricType ) { final String key = joinKeys(prefix, id); final String unit = getUnit(id.getTags()); return new BatchBuilder(points, timestamp, key, id.getTags(), unit, metricType); }
Example #23
Source File: SemanticAnalyticsReporter.java From heroic with Apache License 2.0 | 5 votes |
public SemanticAnalyticsReporter(SemanticMetricRegistry registry) { final MetricId id = MetricId.build().tagged("component", COMPONENT); this.droppedFetchSeries = registry.counter(id.tagged("what", "dropped-fetch-series", "unit", Units.DROP)); this.failedFetchSeries = registry.counter(id.tagged("what", "failed-fetch-series", "unit", Units.FAILURE)); }
Example #24
Source File: SemanticIngestionManagerReporter.java From heroic with Apache License 2.0 | 5 votes |
public SemanticIngestionManagerReporter(SemanticMetricRegistry registry) { final MetricId id = MetricId.build().tagged("component", COMPONENT); this.concurrentWritesCounter = registry.counter(id.tagged("what", "concurrent-writes", "unit", Units.WRITE)); this.droppedByFilter = registry.counter(id.tagged("what", "dropped-by-filter", "unit", Units.COUNT)); }
Example #25
Source File: SemanticCacheStatistics.java From ffwd with Apache License 2.0 | 5 votes |
@Override public Map<MetricId, Metric> getMetrics() { final Map<MetricId, Metric> gauges = new HashMap<>(); final MetricId m = MetricId.EMPTY.tagged("subcomponent", "cache"); gauges.put(m.tagged("what", "hit-count"), (Gauge<Long>) () -> cache.stats().hitCount()); gauges.put(m.tagged("what", "miss-count"), (Gauge<Long>) () -> cache.stats().missCount()); gauges.put( m.tagged("what", "eviction-count"), (Gauge<Long>) () -> cache.stats().evictionCount()); gauges.put(m.tagged("what", "size"), (Gauge<Long>) cache::size); return Collections.unmodifiableMap(gauges); }
Example #26
Source File: SemanticMetadataBackendReporter.java From heroic with Apache License 2.0 | 5 votes |
public SemanticMetadataBackendReporter(SemanticMetricRegistry registry) { final MetricId base = MetricId.build().tagged("component", COMPONENT); findTags = new SemanticFutureReporter(registry, base.tagged("what", "find-tags", "unit", Units.QUERY)); findSeries = new SemanticFutureReporter(registry, base.tagged("what", "find-series", "unit", Units.QUERY)); findSeriesIds = new SemanticFutureReporter(registry, base.tagged("what", "find-series-ids", "unit", Units.QUERY)); countSeries = new SemanticFutureReporter(registry, base.tagged("what", "count-series", "unit", Units.QUERY)); deleteSeries = new SemanticFutureReporter(registry, base.tagged("what", "delete-series", "unit", Units.QUERY)); findKeys = new SemanticFutureReporter(registry, base.tagged("what", "find-keys", "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)); entries = registry.counter(base.tagged("what", "entries", "unit", Units.COUNT)); writesDroppedByCacheHit = registry.counter( base.tagged("what", "writes-dropped-by-cache-hit", "unit", Units.COUNT)); writesDroppedByDuplicate = registry.counter( base.tagged("what", "writes-dropped-by-duplicate", "unit", Units.COUNT)); // only relevant to es backend. failedShards = registry.counter( base.tagged("what", "failed-es-shards", "unit", Units.COUNT)); }
Example #27
Source File: SemanticQueryReporter.java From heroic with Apache License 2.0 | 5 votes |
public SemanticQueryReporter(final SemanticMetricRegistry registry) { final MetricId base = MetricId.build().tagged("component", COMPONENT); query = new SemanticFutureReporter(registry, base.tagged("what", "query", "unit", Units.QUERY)); smallQueryLatency = registry.histogram( base.tagged("what", "small-query-latency", "unit", Units.MILLISECOND)); queryReadRate = registry.histogram(base.tagged("what", "query-read-rate", "unit", Units.COUNT)); rpcError = registry.counter(base.tagged("what", "cluster-rpc-error", "unit", Units.COUNT)); rpcCancellation = registry.counter(base.tagged("what", "cluster-rpc-cancellation", "unit", Units.COUNT)); }
Example #28
Source File: SemanticMemcachedReporter.java From heroic with Apache License 2.0 | 5 votes |
public SemanticMemcachedReporter(SemanticMetricRegistry registry, final String consumerType) { final MetricId id = MetricId.build().tagged("component", COMPONENT, "consumer", consumerType); memcachedHit = registry.counter(id.tagged("what", "memcached-performance", "result", "hit")); memcachedMiss = registry.counter(id.tagged("what", "memcached-performance", "result", "miss")); memcachedTimeout = registry.counter(id.tagged("what", "memcached-performance", "result", "timeout")); memcachedError = registry.counter(id.tagged("what", "memcached-performance", "result", "error")); }
Example #29
Source File: SemanticConsumerReporter.java From heroic with Apache License 2.0 | 5 votes |
public SemanticConsumerReporter(SemanticMetricRegistry registry, String id) { this.base = MetricId.build().tagged("component", COMPONENT, "id", id); messageIn = registry.counter(base.tagged("what", "message-in", "unit", Units.COUNT)); metricsIn = registry.counter(base.tagged("what", "metrics-in", "unit", Units.COUNT)); messageError = registry.counter(base.tagged("what", "message-error", "unit", Units.COUNT)); messageRetry = registry.counter(base.tagged("what", "message-retry", "unit", Units.COUNT)); consumerSchemaError = registry.counter(base.tagged("what", "consumer-schema-error", "unit", Units.COUNT)); consumerThreadsLiveRatio = new SemanticRatioGauge(); registry.register(base.tagged("what", "consumer-threads-live-ratio", "unit", Units.RATIO), consumerThreadsLiveRatio); messageSize = registry.histogram(base.tagged("what", "message-size", "unit", Units.BYTE)); messageDrift = registry.histogram(base.tagged("what", "message-drift", "unit", Units.MILLISECOND)); consumer = new SemanticFutureReporter(registry, base.tagged("what", "consumer", "unit", Units.WRITE)); consumerCommitWholeOperationTimer = registry.register(base.tagged("what", "consumer-commit-latency"), new SemanticHeroicTimerGauge()); consumerCommitPhase1Timer = registry.register(base.tagged("what", "consumer-commit-phase1-latency"), new SemanticHeroicTimerGauge()); consumerCommitPhase2Timer = registry.register(base.tagged("what", "consumer-commit-phase2-latency"), new SemanticHeroicTimerGauge()); }
Example #30
Source File: SemanticConsumerReporter.java From heroic with Apache License 2.0 | 5 votes |
@java.beans.ConstructorProperties({ "base", "messageIn", "metricsIn", "messageError", "messageRetry", "consumerSchemaError", "consumerThreadsLiveRatio", "messageSize", "messageDrift", "consumer", "consumerCommitWholeOperationTimer", "consumerCommitPhase1Timer", "consumerCommitPhase2Timer" }) public SemanticConsumerReporter( final MetricId base, final Counter messageIn, final Counter metricsIn, final Counter messageError, final Counter messageRetry, final Counter consumerSchemaError, final SemanticRatioGauge consumerThreadsLiveRatio, final Histogram messageSize, final Histogram messageDrift, final SemanticFutureReporter consumer, final SemanticHeroicTimerGauge consumerCommitWholeOperationTimer, final SemanticHeroicTimerGauge consumerCommitPhase1Timer, final SemanticHeroicTimerGauge consumerCommitPhase2Timer ) { this.base = base; this.messageIn = messageIn; this.metricsIn = metricsIn; this.messageError = messageError; this.messageRetry = messageRetry; this.consumerSchemaError = consumerSchemaError; this.consumerThreadsLiveRatio = consumerThreadsLiveRatio; this.messageSize = messageSize; this.messageDrift = messageDrift; this.consumer = consumer; this.consumerCommitWholeOperationTimer = consumerCommitWholeOperationTimer; this.consumerCommitPhase1Timer = consumerCommitPhase1Timer; this.consumerCommitPhase2Timer = consumerCommitPhase2Timer; }