com.codahale.metrics.jvm.CachedThreadStatesGaugeSet Java Examples

The following examples show how to use com.codahale.metrics.jvm.CachedThreadStatesGaugeSet. 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: StreamingMetrics.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
/**
 * ThreadStatesGaugeSet & ClassLoadingGaugeSet are currently not registered.
 * metricRegistry.register("threads", new ThreadStatesGaugeSet());
 */
private StreamingMetrics() {
    if (METRICS_OPTION != null && !METRICS_OPTION.isEmpty()) {
        metricRegistry.register("gc", new GarbageCollectorMetricSet());
        metricRegistry.register("threads", new CachedThreadStatesGaugeSet(10, TimeUnit.SECONDS));
        metricRegistry.register("memory", new MemoryUsageGaugeSet());
    }
}
 
Example #2
Source File: LocalDataTransferServer.java    From rubix with Apache License 2.0 5 votes vote down vote up
/**
 * Register desired metrics.
 *
 * @param conf The current Hadoop configuration.
 */
private static void registerMetrics(Configuration conf)
{
  bookKeeperMetrics = new BookKeeperMetrics(conf, metrics);

  metrics.register(BookKeeperMetrics.LDTSJvmMetric.LDTS_JVM_GC_PREFIX.getMetricName(), new GarbageCollectorMetricSet());
  metrics.register(BookKeeperMetrics.LDTSJvmMetric.LDTS_JVM_THREADS_PREFIX.getMetricName(), new CachedThreadStatesGaugeSet(CacheConfig.getMetricsReportingInterval(conf), TimeUnit.MILLISECONDS));
  metrics.register(BookKeeperMetrics.LDTSJvmMetric.LDTS_JVM_MEMORY_PREFIX.getMetricName(), new MemoryUsageGaugeSet());
}
 
Example #3
Source File: BookKeeperServer.java    From rubix with Apache License 2.0 5 votes vote down vote up
/**
 * Register desired metrics.
 */
protected void registerMetrics(Configuration conf)
{
  metrics.register(BookKeeperMetrics.BookKeeperJvmMetric.BOOKKEEPER_JVM_GC_PREFIX.getMetricName(), new GarbageCollectorMetricSet());
  metrics.register(BookKeeperMetrics.BookKeeperJvmMetric.BOOKKEEPER_JVM_THREADS_PREFIX.getMetricName(), new CachedThreadStatesGaugeSet(CacheConfig.getMetricsReportingInterval(conf), TimeUnit.MILLISECONDS));
  metrics.register(BookKeeperMetrics.BookKeeperJvmMetric.BOOKKEEPER_JVM_MEMORY_PREFIX.getMetricName(), new MemoryUsageGaugeSet());
}
 
Example #4
Source File: StreamingMetrics.java    From kylin with Apache License 2.0 5 votes vote down vote up
/**
 * ThreadStatesGaugeSet & ClassLoadingGaugeSet are currently not registered.
 * metricRegistry.register("threads", new ThreadStatesGaugeSet());
 */
private StreamingMetrics() {
    if (METRICS_OPTION != null && !METRICS_OPTION.isEmpty()) {
        metricRegistry.register("gc", new GarbageCollectorMetricSet());
        metricRegistry.register("threads", new CachedThreadStatesGaugeSet(10, TimeUnit.SECONDS));
        metricRegistry.register("memory", new MemoryUsageGaugeSet());
    }
}
 
Example #5
Source File: DefaultMetricsService.java    From knox with Apache License 2.0 5 votes vote down vote up
private void registerJvmMetricSets() {
  metrics.registerAll(new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
  metrics.registerAll(new CachedThreadStatesGaugeSet(5, TimeUnit.MINUTES));
  metrics.registerAll(new ClassLoadingGaugeSet());
  metrics.registerAll(new GarbageCollectorMetricSet());
  metrics.registerAll(new JvmAttributeGaugeSet());
  metrics.registerAll(new MemoryUsageGaugeSet());
}
 
Example #6
Source File: AsyncBenchmark.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
AsyncBenchmark(Configuration cfg) {
    client = new AsyncDocumentClient.Builder()
        .withServiceEndpoint(cfg.getServiceEndpoint())
        .withMasterKeyOrResourceToken(cfg.getMasterKey())
        .withConnectionPolicy(cfg.getConnectionPolicy())
        .withConsistencyLevel(cfg.getConsistencyLevel())
        .build();

    logger = LoggerFactory.getLogger(this.getClass());

    Database database = DocDBUtils.getDatabase(client, cfg.getDatabaseId());
    collection = DocDBUtils.getCollection(client, database.getSelfLink(), cfg.getCollectionId());
    nameCollectionLink = String.format("dbs/%s/colls/%s", database.getId(), collection.getId());
    partitionKey = collection.getPartitionKey().getPaths().iterator().next().split("/")[1];
    concurrencyControlSemaphore = new Semaphore(cfg.getConcurrency());
    configuration = cfg;

    ArrayList<Observable<Document>> createDocumentObservables = new ArrayList<>();

    if (configuration.getOperationType() != Operation.WriteLatency
            && configuration.getOperationType() != Operation.WriteThroughput
            && configuration.getOperationType() != Operation.ReadMyWrites) {
        String dataFieldValue = RandomStringUtils.randomAlphabetic(cfg.getDocumentDataFieldSize());
        for (int i = 0; i < cfg.getNumberOfPreCreatedDocuments(); i++) {
            String uuid = UUID.randomUUID().toString();
            Document newDoc = new Document();
            newDoc.setId(uuid);
            newDoc.set(partitionKey, uuid);
            newDoc.set("dataField1", dataFieldValue);
            newDoc.set("dataField2", dataFieldValue);
            newDoc.set("dataField3", dataFieldValue);
            newDoc.set("dataField4", dataFieldValue);
            newDoc.set("dataField5", dataFieldValue);
            Observable<Document> obs = client.createDocument(collection.getSelfLink(), newDoc, null, false)
                    .map(ResourceResponse::getResource);
            createDocumentObservables.add(obs);
        }
    }

    docsToRead = Observable.merge(createDocumentObservables, 100).toList().toBlocking().single();
    init();

    if (configuration.isEnableJvmStats()) {
        metricsRegistry.register("gc", new GarbageCollectorMetricSet());
        metricsRegistry.register("threads", new CachedThreadStatesGaugeSet(10, TimeUnit.SECONDS));
        metricsRegistry.register("memory", new MemoryUsageGaugeSet());
    }

    if (configuration.getGraphiteEndpoint() != null) {
        final Graphite graphite = new Graphite(new InetSocketAddress(configuration.getGraphiteEndpoint(),
            configuration.getGraphiteEndpointPort()));
        reporter = GraphiteReporter.forRegistry(metricsRegistry)
                                   .prefixedWith(configuration.getOperationType().name())
                                   .convertRatesTo(TimeUnit.SECONDS)
                                   .convertDurationsTo(TimeUnit.MILLISECONDS)
                                   .filter(MetricFilter.ALL)
                                   .build(graphite);
    } else {
        reporter = ConsoleReporter.forRegistry(metricsRegistry).convertRatesTo(TimeUnit.SECONDS)
                                  .convertDurationsTo(TimeUnit.MILLISECONDS).build();
    }

    MeterRegistry registry = configuration.getAzureMonitorMeterRegistry();

    if (registry != null) {
        AsyncDocumentClient.monitor(registry);
    }

    registry = configuration.getGraphiteMeterRegistry();

    if (registry != null) {
        AsyncDocumentClient.monitor(registry);
    }
}