当前位置: 首页>>代码示例>>Java>>正文


Java RatioGauge类代码示例

本文整理汇总了Java中com.codahale.metrics.RatioGauge的典型用法代码示例。如果您正苦于以下问题:Java RatioGauge类的具体用法?Java RatioGauge怎么用?Java RatioGauge使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RatioGauge类属于com.codahale.metrics包,在下文中一共展示了RatioGauge类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PoolMetricsImpl

import com.codahale.metrics.RatioGauge; //导入依赖的package包/类
public PoolMetricsImpl(MetricRegistry registry, String baseName, int maxSize) {
  super(registry, baseName);
  this.queueSize = counter("queue-size");
  this.queueDelay = timer("queue-delay");
  this.usage = timer("usage");
  this.inUse = counter("in-use");
  if (maxSize > 0) {
    RatioGauge gauge = new RatioGauge() {
      @Override
      protected Ratio getRatio() {
        return Ratio.of(inUse.getCount(), maxSize);
      }
    };
    gauge(gauge, "pool-ratio");
    gauge(() -> maxSize, "max-pool-size");
  }
}
 
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:18,代码来源:PoolMetricsImpl.java

示例2: registerRatioGauge

import com.codahale.metrics.RatioGauge; //导入依赖的package包/类
/**
 * Register a ratio gauge.
 *
 * @param name the name of the gauge
 * @param numerator a function returning a number represents the value of the numerator
 * @param denominator a function returning a number that represents the value of the denominator
 * @param <T> a type of number
 * @return the registered gauge
 */
@Override
public <T extends Number> Gauge<Double> registerRatioGauge(final String name, Supplier<T> numerator, Supplier<T> denominator) {
    com.codahale.metrics.RatioGauge theGauge;
    try {
        theGauge = metricRegistry.register(name, new RatioGauge() {
            @Override
            protected Ratio getRatio() {
                return Ratio.of(numerator.get().doubleValue(), denominator.get().doubleValue());
            }
        });
    } catch (IllegalArgumentException ex) {
        throw new MetricAlreadyExistsException(String.format(EXCEPTION_TEMPLATE, name), ex);
    }
    return new GaugeAdapter<>(theGauge);
}
 
开发者ID:motech,项目名称:modules,代码行数:25,代码来源:MetricRegistryServiceImpl.java

示例3: createUtilizationStats

import com.codahale.metrics.RatioGauge; //导入依赖的package包/类
private void createUtilizationStats() {
    utilizationHistogram = new Histogram(createReservoir());
    metricRegistry.register(
            name(getName(), "utilization-percentage-histogram"),
            utilizationHistogram
    );
    utilizationGauge = new RatioGauge() {

        @Override
        protected Ratio getRatio() {
            return Ratio.of(getThreads() - getIdleThreads(), getThreads());
        }
    };

    metricRegistry.register(name(getName(), "utilization-percentage"), utilizationGauge);
}
 
开发者ID:atlasapi,项目名称:atlas-deer,代码行数:17,代码来源:InstrumentedQueuedThreadPool.java

示例4: ratioOf

import com.codahale.metrics.RatioGauge; //导入依赖的package包/类
public static Gauge<Double> ratioOf(
        final Supplier<? extends Number> numerator,
        final Supplier<? extends Number> denominator
) {
    return new RatioGauge() {
        @Override
        protected Ratio getRatio() {
            return Ratio.of(
                    numerator.get().doubleValue(),
                    denominator.get().doubleValue());
        }
    };
}
 
开发者ID:sproutsocial,项目名称:instrumentor,代码行数:14,代码来源:Gauges.java

示例5: configureMetrics

import com.codahale.metrics.RatioGauge; //导入依赖的package包/类
protected void configureMetrics(QueuedThreadPool pool) {
    // metrics
    metricRegistry.register(name(pool.getName(), "utilization"), new RatioGauge() {
        @Override
        protected Ratio getRatio() {
            return Ratio.of(pool.getThreads() - pool.getIdleThreads(), pool.getThreads());
        }
    });
    metricRegistry.register(name(pool.getName(), "utilization-max"), new RatioGauge() {
        @Override
        protected Ratio getRatio() {
            return Ratio.of(pool.getThreads() - pool.getIdleThreads(), pool.getMaxThreads());
        }
    });
    metricRegistry.register(name(pool.getName(), "size"), new Gauge<Integer>() {
        @Override
        public Integer getValue() {
            return pool.getThreads();
        }
    });
    metricRegistry.register(name(pool.getName(), "jobs"), new Gauge<Integer>() {
        @Override
        public Integer getValue() {
            // This assumes the QueuedThreadPool is using a BlockingArrayQueue or
            // ArrayBlockingQueue for its queue, and is therefore a constant-time operation.
            return pool.getQueueSize();
        }
    });
}
 
开发者ID:fastnsilver,项目名称:xlator,代码行数:30,代码来源:JettyConfig.java

示例6: getUtilization

import com.codahale.metrics.RatioGauge; //导入依赖的package包/类
protected double getUtilization() {

        // utilization is:
        //     (all_acceptor_t + all_selector_t + active_request_t) / maxT

        // This is not readily apparent from the Jetty API below. An explanation:
        //     getThreads()                    == all_acceptor_t + all_selector_t + active_request_t + idle_request_t
        // hence
        //     getThreads() - getIdleThreads() == all_acceptor_t + all_selector_t + active_request_t

        return RatioGauge.Ratio.of(getThreads() - getIdleThreads(), getMaxThreads()).getValue();
    }
 
开发者ID:bootique,项目名称:bootique-jetty,代码行数:13,代码来源:InstrumentedQueuedThreadPool.java

示例7: AbstractFog

import com.codahale.metrics.RatioGauge; //导入依赖的package包/类
/**
 * Instantiates a new Abstract fog.
 */
public AbstractFog() {

    MetricsManager.metrics.register(name(this.getClass(), "hit", "ratio"),
            new RatioGauge() {
                @Override
                protected Ratio getRatio() {
                    return Ratio.of(hits.getCount(), timer.getCount());
                }
            });
}
 
开发者ID:steven-zhc,项目名称:hummingbird-framework,代码行数:14,代码来源:AbstractFog.java

示例8: CQLMetrics

import com.codahale.metrics.RatioGauge; //导入依赖的package包/类
public CQLMetrics()
{
    regularStatementsExecuted = Metrics.counter(factory.createMetricName("RegularStatementsExecuted"));
    preparedStatementsExecuted = Metrics.counter(factory.createMetricName("PreparedStatementsExecuted"));
    preparedStatementsEvicted = Metrics.counter(factory.createMetricName("PreparedStatementsEvicted"));

    preparedStatementsCount = Metrics.register(factory.createMetricName("PreparedStatementsCount"), new Gauge<Integer>()
    {
        public Integer getValue()
        {
            return QueryProcessor.preparedStatementsCount();
        }
    });
    preparedStatementsRatio = Metrics.register(factory.createMetricName("PreparedStatementsRatio"), new RatioGauge()
    {
        public Ratio getRatio()
        {
            return Ratio.of(getNumerator(), getDenominator());
        }

        public double getNumerator()
        {
            return preparedStatementsExecuted.getCount();
        }

        public double getDenominator()
        {
            return regularStatementsExecuted.getCount() + preparedStatementsExecuted.getCount();
        }
    });
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:32,代码来源:CQLMetrics.java

示例9: registerPooledResource

import com.codahale.metrics.RatioGauge; //导入依赖的package包/类
public static void registerPooledResource(final PooledResource pooledResource, Metric2Registry registry) {
	MetricName name = pooledResource.getName();
	registry.register(name.withTag("type", "active"), new Gauge<Integer>() {
		@Override
		public Integer getValue() {
			return pooledResource.getPoolNumActive();
		}
	});
	registry.register(name.withTag("type", "count"), new Gauge<Integer>() {
		@Override
		public Integer getValue() {
			return pooledResource.getActualPoolSize();
		}
	});
	registry.register(name.withTag("type", "max"), new Gauge<Integer>() {
		@Override
		public Integer getValue() {
			return pooledResource.getMaxPoolSize();
		}
	});
	if (pooledResource.getNumTasksPending() != null) {
		registry.register(name.withTag("type", "queued"), new Gauge<Integer>() {
			@Override
			public Integer getValue() {
				return pooledResource.getNumTasksPending();
			}
		});
	}
	registry.register(name.withTag("type", "usage"), new RatioGauge() {
		@Override
		protected Ratio getRatio() {
			return Ratio.of(pooledResource.getPoolNumActive() * 100.0, pooledResource.getMaxPoolSize());
		}
	});
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:36,代码来源:PooledResourceMetricsRegisterer.java

示例10: getMetrics

import com.codahale.metrics.RatioGauge; //导入依赖的package包/类
@Override
public Map<MetricName, Metric> getMetrics() {
	final Map<MetricName, Metric> metrics = new HashMap<MetricName, Metric>();

	metrics.put(name("cache_hit_ratio").tag("cache_name", cacheName).tier("All").build(), new RatioGauge() {
		@Override
		public Ratio getRatio() {
			return cacheUsageListener.getHitRatio1Min();
		}
	});

	metrics.put(name("cache_size_count").tag("cache_name", cacheName).tier("All").build(), new Gauge<Long>() {
		@Override
		public Long getValue() {
			return cache.getLiveCacheStatistics().getSize();
		}
	});

	metrics.put(name("cache_size_bytes").tag("cache_name", cacheName).tier("All").build(), new Gauge<Long>() {
		@Override
		public Long getValue() {
			return cache.getLiveCacheStatistics().getLocalDiskSizeInBytes() +
					cache.getLiveCacheStatistics().getLocalHeapSizeInBytes() +
					cache.getLiveCacheStatistics().getLocalOffHeapSizeInBytes();
		}
	});

	return metrics;
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:30,代码来源:EhCacheMetricSet.java

示例11: setupGauges

import com.codahale.metrics.RatioGauge; //导入依赖的package包/类
/**
 * Register global gauges.
 */
protected final void setupGauges() {
    // Gauges are registered here since they should be configured only once at startup.
    MetricRegistry metricRegistry = MetricRegistryFactory.getRegistry();
    Map<String, Metric> metrics = metricRegistry.getMetrics();

    if (!metrics.containsKey(METER_CACHE_HIT_RATIO)) {
        metricRegistry.register(
                METER_CACHE_HIT_RATIO,
                new RatioGauge() {
                    @Override
                    protected Ratio getRatio() {
                        return CACHE_REQUESTS.getCount() != 0
                                ? Ratio.of(CACHE_HITS.getCount(), CACHE_REQUESTS.getCount())
                                : Ratio.of(0, 1);
                    }
                }
        );
    }

    if (!metrics.containsKey(METER_SPLITS_TOTAL_RATIO)) {
        metricRegistry.register(
                METER_SPLITS_TOTAL_RATIO,
                new RatioGauge() {
                    @Override
                    protected Ratio getRatio() {
                        return QUERY_REQUEST_TOTAL.getCount() != 0
                                ? Ratio.of(SPLIT_QUERIES.getCount(), QUERY_REQUEST_TOTAL.getCount())
                                : Ratio.of(0, 1);
                    }
                }
        );
    }

    if (!metrics.containsKey(METER_SPLITS_RATIO)) {
        metricRegistry.register(
                METER_SPLITS_RATIO,
                new RatioGauge() {
                    @Override
                    protected Ratio getRatio() {
                        return SPLITS.getCount() != 0
                                ? Ratio.of(SPLIT_QUERIES.getCount(), SPLITS.getCount())
                                : Ratio.of(0, 1);
                    }
                }
        );
    }

    if (!metrics.containsKey(JVM_UPTIME)) {
        metricRegistry.register(
                JVM_UPTIME,
                (Gauge<Long>) () -> ManagementFactory.getRuntimeMXBean().getUptime()
        );
    }
}
 
开发者ID:yahoo,项目名称:fili,代码行数:58,代码来源:AbstractBinderFactory.java

示例12: instrumentHttpCache

import com.codahale.metrics.RatioGauge; //导入依赖的package包/类
private void instrumentHttpCache() {
  if (cache() == null) return;

  registry.register(metricId("cache-request-count"), new Gauge<Integer>() {
    @Override public Integer getValue() {
      // The number of HTTP requests issued since this cache was created.
      return rawClient.cache().requestCount();
    }
  });
  registry.register(metricId("cache-hit-count"), new Gauge<Integer>() {
    @Override public Integer getValue() {
      // ... the number of those requests that required network use.
      return rawClient.cache().hitCount();
    }
  });
  registry.register(metricId("cache-network-count"), new Gauge<Integer>() {
    @Override public Integer getValue() {
      // ... the number of those requests whose responses were served by the cache.
      return rawClient.cache().networkCount();
    }
  });
  registry.register(metricId("cache-write-success-count"), new Gauge<Integer>() {
    @Override public Integer getValue() {
      return rawClient.cache().writeSuccessCount();
    }
  });
  registry.register(metricId("cache-write-abort-count"), new Gauge<Integer>() {
    @Override public Integer getValue() {
      return rawClient.cache().writeAbortCount();
    }
  });
  final Gauge<Long> currentCacheSize = new Gauge<Long>() {
    @Override public Long getValue() {
      try {
        return rawClient.cache().size();
      } catch (IOException ex) {
        LOG.error(ex.getMessage(), ex);
        return -1L;
      }
    }
  };
  final Gauge<Long> maxCacheSize = new Gauge<Long>() {
    @Override public Long getValue() {
      return rawClient.cache().maxSize();
    }
  };
  registry.register(metricId("cache-current-size"), currentCacheSize);
  registry.register(metricId("cache-max-size"), maxCacheSize);
  registry.register(metricId("cache-size"), new RatioGauge() {
    @Override protected Ratio getRatio() {
      return Ratio.of(currentCacheSize.getValue(), maxCacheSize.getValue());
    }
  });
}
 
开发者ID:raskasa,项目名称:metrics-okhttp,代码行数:55,代码来源:InstrumentedOkHttpClient.java

示例13: SemanticFolsomMetrics

import com.codahale.metrics.RatioGauge; //导入依赖的package包/类
public SemanticFolsomMetrics(final SemanticMetricRegistry registry, final MetricId baseMetricId) {

    this.registry = registry;

    this.id = baseMetricId.tagged("what", "memcache-results",
                                  "component", "memcache-client");

    final MetricId meterId = id.tagged("unit", "operations");

    MetricId getId = id.tagged("operation", "get");
    this.gets = registry.timer(getId);
    // successful gets are broken down by whether a result was found in the cache or not.
    // the two meters can be summed to count total number of successes.
    MetricId getMetersId = MetricId.join(getId, meterId);
    this.getHits = registry.meter(getMetersId.tagged("result", "success", "cache-result", "hit"));
    this.getMisses = registry.meter(
            getMetersId.tagged("result", "success", "cache-result", "miss"));
    this.getFailures = registry.meter(getMetersId.tagged("result", "failure"));

    // ratio of cache hits to total attempts
    hitRatio = new RatioGauge() {
      @Override
      protected Ratio getRatio() {
        return Ratio.of(getHits.getFiveMinuteRate(),
            gets.getFiveMinuteRate() + multigetItems.getFiveMinuteRate());
      }
    };
    // overwrite the 'what' as this metric doesn't make sense to be aggregated against any of the
    // other metrics
    registry.register(getId.tagged("what", "memcache-hit-ratio", "unit", "%"), hitRatio);

    MetricId setId = id.tagged("operation", "set");
    this.sets = registry.timer(setId);
    MetricId setMetersId = MetricId.join(setId, meterId);
    this.setSuccesses = registry.meter(setMetersId.tagged("result", "success"));
    this.setFailures = registry.meter(setMetersId.tagged("result", "failure"));

    MetricId multigetId = id.tagged("operation", "multiget");
    this.multigets = registry.timer(multigetId);
    MetricId multigetMetersId = MetricId.join(multigetId, meterId);
    this.multigetSuccesses = registry.meter(multigetMetersId.tagged("result", "success"));
    this.multigetFailures = registry.meter(multigetMetersId.tagged("result", "failure"));

    // doesn't seem useful to export
    this.multigetItems = new Meter();

    MetricId deleteId = id.tagged("operation", "delete");
    this.deletes = registry.timer(deleteId);
    MetricId deleteMetersId = MetricId.join(deleteId, meterId);
    this.deleteSuccesses = registry.meter(deleteMetersId.tagged("result", "success"));
    this.deleteFailures = registry.meter(deleteMetersId.tagged("result", "failure"));

    MetricId incrDecrId = id.tagged("operation", "incr-decr");
    this.incrDecrs = registry.timer(incrDecrId);
    MetricId incrDecrMetersId = MetricId.join(incrDecrId, meterId);
    this.incrDecrSuccesses = registry.meter(incrDecrMetersId.tagged("result", "success"));
    this.incrDecrFailures = registry.meter(incrDecrMetersId.tagged("result", "failure"));

    MetricId touchId = id.tagged("operation", "touch");
    this.touches = registry.timer(touchId);
    MetricId touchMetersId = MetricId.join(touchId, meterId);
    this.touchSuccesses = registry.meter(touchMetersId.tagged("result", "success"));
    this.touchFailures = registry.meter(touchMetersId.tagged("result", "failure"));

    createConnectionCounterGauge();
  }
 
开发者ID:spotify,项目名称:folsom,代码行数:67,代码来源:SemanticFolsomMetrics.java

示例14: getHitRatio

import com.codahale.metrics.RatioGauge; //导入依赖的package包/类
public RatioGauge getHitRatio() {
  return hitRatio;
}
 
开发者ID:spotify,项目名称:folsom,代码行数:4,代码来源:SemanticFolsomMetrics.java

示例15: CacheMetrics

import com.codahale.metrics.RatioGauge; //导入依赖的package包/类
/**
 * Create metrics for given cache.
 *
 * @param type Type of Cache to identify metrics.
 * @param cache Cache to measure metrics
 */
public CacheMetrics(String type, final ICache cache)
{
    MetricNameFactory factory = new DefaultNameFactory("Cache", type);

    capacity = Metrics.register(factory.createMetricName("Capacity"), new Gauge<Long>()
    {
        public Long getValue()
        {
            return cache.capacity();
        }
    });
    hits = Metrics.meter(factory.createMetricName("Hits"));
    requests = Metrics.meter(factory.createMetricName("Requests"));
    hitRate = Metrics.register(factory.createMetricName("HitRate"), new RatioGauge()
    {
        @Override
        public Ratio getRatio()
        {
            return Ratio.of(hits.getCount(), requests.getCount());
        }
    });
    oneMinuteHitRate = Metrics.register(factory.createMetricName("OneMinuteHitRate"), new RatioGauge()
    {
        protected Ratio getRatio()
        {
            return Ratio.of(hits.getOneMinuteRate(), requests.getOneMinuteRate());
        }
    });
    fiveMinuteHitRate = Metrics.register(factory.createMetricName("FiveMinuteHitRate"), new RatioGauge()
    {
        protected Ratio getRatio()
        {
            return Ratio.of(hits.getFiveMinuteRate(), requests.getFiveMinuteRate());
        }
    });
    fifteenMinuteHitRate = Metrics.register(factory.createMetricName("FifteenMinuteHitRate"), new RatioGauge()
    {
        protected Ratio getRatio()
        {
            return Ratio.of(hits.getFifteenMinuteRate(), requests.getFifteenMinuteRate());
        }
    });
    size = Metrics.register(factory.createMetricName("Size"), new Gauge<Long>()
    {
        public Long getValue()
        {
            return cache.weightedSize();
        }
    });
    entries = Metrics.register(factory.createMetricName("Entries"), new Gauge<Integer>()
    {
        public Integer getValue()
        {
            return cache.size();
        }
    });
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:64,代码来源:CacheMetrics.java


注:本文中的com.codahale.metrics.RatioGauge类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。