本文整理汇总了Java中com.codahale.metrics.MetricRegistry类的典型用法代码示例。如果您正苦于以下问题:Java MetricRegistry类的具体用法?Java MetricRegistry怎么用?Java MetricRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MetricRegistry类属于com.codahale.metrics包,在下文中一共展示了MetricRegistry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLimitAcrossBatches
import com.codahale.metrics.MetricRegistry; //导入依赖的package包/类
@Test
@Ignore
// The testcase is not valid. "test4.json" using increasingBigInt(0) to generate a list of increasing number starting from 0, and verify the sum.
// However, when evaluate the increasingBitInt(0), if the outgoing batch could not hold the new value, doEval() return false, and start the
// next batch. But the value has already been increased by 1 in the prior failed try. Therefore, the sum of the generated number could be different,
// depending on the size of each outgoing batch, and when the batch could not hold any more values.
public void testLimitAcrossBatches(@Injectable final DrillbitContext bitContext, @Injectable UserServer.UserClientConnection connection) throws Throwable {
new NonStrictExpectations(){{
bitContext.getMetrics(); result = new MetricRegistry();
bitContext.getAllocator(); result = RootAllocatorFactory.newRoot(c);
bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
bitContext.getConfig(); result = c;
bitContext.getCompiler(); result = CodeCompiler.getTestCompiler(c);
}};
verifyLimitCount(bitContext, connection, "test2.json", 69999);
final long start = 30000;
final long end = 100000;
final long expectedSum = (end - start) * (end + start - 1) / 2; //Formula for sum of series
verifySum(bitContext, connection, "test4.json", 70000, expectedSum);
}
示例2: KafkaCruiseControl
import com.codahale.metrics.MetricRegistry; //导入依赖的package包/类
/**
* Construct the Cruise Control
*
* @param config the configuration of Cruise Control.
*/
public KafkaCruiseControl(KafkaCruiseControlConfig config) {
_config = config;
_time = new SystemTime();
// initialize some of the static state of Kafka Cruise Control;
Load.init(config);
ModelUtils.init(config);
ModelParameters.init(config);
_dropwizardMetricRegistry = new MetricRegistry();
_reporter = JmxReporter.forRegistry(_dropwizardMetricRegistry).inDomain(_metricsPrefix).build();
// Instantiate the components.
_loadMonitor = new LoadMonitor(config, _time, _dropwizardMetricRegistry);
_goalOptimizerExecutor =
Executors.newSingleThreadExecutor(new KafkaCruiseControlThreadFactory("GoalOptimizerExecutor", true, null));
_goalOptimizer = new GoalOptimizer(config, _loadMonitor, _time, _dropwizardMetricRegistry);
_executor = new Executor(config, _time, _dropwizardMetricRegistry);
_anomalyDetector = new AnomalyDetector(config, _loadMonitor, this, _time, _dropwizardMetricRegistry);
}
示例3: defaultGraphiteReporter
import com.codahale.metrics.MetricRegistry; //导入依赖的package包/类
private static GraphiteReporter defaultGraphiteReporter(GraphiteConfig config, MetricRegistry metricRegistry) {
GraphiteSender sender;
switch (config.protocol()) {
case Plaintext:
sender = new Graphite(new InetSocketAddress(config.host(), config.port()));
break;
case Udp:
sender = new GraphiteUDP(new InetSocketAddress(config.host(), config.port()));
break;
case Pickled:
default:
sender = new PickledGraphite(new InetSocketAddress(config.host(), config.port()));
}
return GraphiteReporter.forRegistry(metricRegistry)
.convertRatesTo(config.rateUnits())
.convertDurationsTo(config.durationUnits())
.build(sender);
}
示例4: doTest
import com.codahale.metrics.MetricRegistry; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private SimpleRootExec doTest(final DrillbitContext bitContext, UserClientConnection connection, String plan_path) throws Exception{
new NonStrictExpectations() {{
bitContext.getMetrics(); result = new MetricRegistry();
bitContext.getAllocator(); result = RootAllocatorFactory.newRoot(c);
bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
bitContext.getConfig(); result = c;
bitContext.getCompiler(); result = CodeCompiler.getTestCompiler(c);
}};
final PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
final PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile(plan_path), Charsets.UTF_8));
final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
final FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
return exec;
}
示例5: enableDatadogMetrics
import com.codahale.metrics.MetricRegistry; //导入依赖的package包/类
private DatadogReporter enableDatadogMetrics(MetricRegistry registry) {
log.info("Initializing Datadog reporter on host: {} with period: {} seconds",
getHost() == null ? "localhost" : getHost(), getPeriod());
Transport transport = getApiKey() == null ?
new UdpTransport.Builder().build() : new HttpTransport.Builder().withApiKey(getApiKey()).build();
DatadogReporter reporter = DatadogReporter.forRegistry(registry)
.withHost(getHost())
.withTransport(transport)
.withExpansions(expansions())
.withTags(getTags())
.withPrefix(getPrefix())
.filter(getFilter())
.withMetricNameFormatter(new CustomMetricNameFormatter())
.build();
reporter.start(getPeriod(), TimeUnit.SECONDS);
log.info("Datadog reporter successfully initialized");
return reporter;
}
示例6: setup
import com.codahale.metrics.MetricRegistry; //导入依赖的package包/类
@Before
public void setup() throws RpcCallException {
handlerDictionary = new MethodHandlerDictionary();
handlerDictionary.put("a", null);
ServiceMethodHandlerUnderTest mockHandlerThrowsRpcCallEx = new ServiceMethodHandlerUnderTest();
handlerDictionary.put("jsonRpcWithException", mockHandlerThrowsRpcCallEx);
metricRegistry = mock(MetricRegistry.class);
when(metricRegistry.counter(anyString())).thenReturn(mock(Counter.class));
when(metricRegistry.timer(anyString())).thenReturn(mock(Timer.class));
handlerMetrics = mock(RpcHandlerMetrics.class);
when(handlerMetrics.getMethodTimer(any(), any(), any())).thenReturn(mock(GoTimer.class));
servlet = new JsonHandler(handlerDictionary, metricRegistry, handlerMetrics, new ServiceProperties(), null);
}
示例7: report
import com.codahale.metrics.MetricRegistry; //导入依赖的package包/类
@Override
public void report(MetricRegistry metricRegistry) {
JbootMetricsCVRReporterConfig cvrReporterConfig = Jboot.config(JbootMetricsCVRReporterConfig.class);
if (StringUtils.isBlank(cvrReporterConfig.getPath())) {
throw new NullPointerException("csv reporter path must not be null, please config jboot.metrics.reporter.cvr.path in you properties.");
}
final CsvReporter reporter = CsvReporter.forRegistry(metricRegistry)
.formatFor(Locale.US)
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build(new File(cvrReporterConfig.getPath()));
reporter.start(1, TimeUnit.SECONDS);
}
示例8: sendHealthCheckRequest
import com.codahale.metrics.MetricRegistry; //导入依赖的package包/类
public MatchingServiceHealthCheckResponseDto sendHealthCheckRequest(
final Element matchingServiceHealthCheckRequest,
final URI matchingServiceUri) {
// Use a custom timer so that we get separate metrics for each matching service
final String scope = matchingServiceUri.toString().replace(':','_').replace('/', '_');
final Timer timer = metricsRegistry.timer(MetricRegistry.name(MatchingServiceHealthCheckClient.class, "sendHealthCheckRequest", scope));
final Timer.Context context = timer.time();
HealthCheckResponse healthCheckResponse;
try {
healthCheckResponse = client.makeSoapRequestForHealthCheck(matchingServiceHealthCheckRequest, matchingServiceUri);
} catch(ApplicationException ex) {
final String errorMessage = MessageFormat.format("Failed to complete matching service health check to {0}.", matchingServiceUri);
LOG.warn(errorMessage, ex);
return new MatchingServiceHealthCheckResponseDto(Optional.<String>absent(), Optional.<String>absent());
} finally {
context.stop();
}
return new MatchingServiceHealthCheckResponseDto(
Optional.of(XmlUtils.writeToString(healthCheckResponse.getResponseElement())),
healthCheckResponse.getVersionNumber());
}
示例9: DefaultGroupStorage
import com.codahale.metrics.MetricRegistry; //导入依赖的package包/类
@Inject
public DefaultGroupStorage(
AmazonDynamoDB amazonDynamoDB,
TableConfiguration tableConfiguration,
@Named("dynamodbGroupWriteHystrix") HystrixConfiguration dynamodbGroupWriteHystrix,
@Named("dynamodbGraphWriteHystrix") HystrixConfiguration dynamodbGraphWriteHystrix,
@Named("dynamodbNamespaceGraphQueryHystrix")
HystrixConfiguration dynamodbNamespaceGraphQueryHystrix,
MetricRegistry metrics
) {
this.amazonDynamoDB = amazonDynamoDB;
this.dynamoDB = new DynamoDB(this.amazonDynamoDB);
this.groupTableName = tableConfiguration.outlandGroupsTable;
this.groupGraphTableName = tableConfiguration.outlandAppGraphTable;
this.dynamodbGroupWriteHystrix = dynamodbGroupWriteHystrix;
this.dynamodbGraphWriteHystrix = dynamodbGraphWriteHystrix;
this.dynamodbNamespaceGraphQueryHystrix = dynamodbNamespaceGraphQueryHystrix;
this.metrics = metrics;
}
示例10: main
import com.codahale.metrics.MetricRegistry; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
Bench<JedisPool> bench = new JedisBench() {
@Override
public void executeOperation(String data, JedisPool benchInstance, int threadNumber, int iteration,
MetricRegistry metrics) {
Jedis jedis = benchInstance.getResource();
Timer.Context time = metrics.timer("list").time();
String key = "list_" + threadNumber;
jedis.rpush(key, data);
time.stop();
jedis.close();
}
};
Benchmark benchmark = new Benchmark(bench);
benchmark.run(args);
}
示例11: RaftLogWorker
import com.codahale.metrics.MetricRegistry; //导入依赖的package包/类
RaftLogWorker(RaftPeerId selfId, RaftServerImpl raftServer, RaftStorage storage,
RaftProperties properties) {
this.name = selfId + "-" + getClass().getSimpleName();
LOG.info("new {} for {}", name, storage);
this.raftServer = raftServer;
this.stateMachine = raftServer != null? raftServer.getStateMachine(): null;
this.storage = storage;
this.segmentMaxSize =
RaftServerConfigKeys.Log.segmentSizeMax(properties).getSize();
this.preallocatedSize =
RaftServerConfigKeys.Log.preallocatedSize(properties).getSize();
this.bufferSize =
RaftServerConfigKeys.Log.writeBufferSize(properties).getSizeInt();
this.forceSyncNum = RaftServerConfigKeys.Log.forceSyncNum(properties);
this.workerThread = new Thread(this, name);
// Server Id can be null in unit tests
Supplier<String> serverId = () -> raftServer == null || raftServer.getId() == null
? "null" : raftServer.getId().toString();
this.logFlushTimer = JavaUtils.memoize(() -> RatisMetricsRegistry.getRegistry()
.timer(MetricRegistry.name(RaftLogWorker.class, serverId.get(),
"flush-time")));
}
示例12: DistCpCopier
import com.codahale.metrics.MetricRegistry; //导入依赖的package包/类
public DistCpCopier(
Configuration conf,
Path sourceDataBaseLocation,
List<Path> sourceDataLocations,
Path replicaDataLocation,
Map<String, Object> copierOptions,
MetricRegistry registry) {
this(conf, sourceDataBaseLocation, sourceDataLocations, replicaDataLocation, copierOptions, DistCpExecutor.DEFAULT,
registry);
}
示例13: setup
import com.codahale.metrics.MetricRegistry; //导入依赖的package包/类
@Before
public void setup() {
servletContext = spy(new MockServletContext());
doReturn(new MockFilterRegistration())
.when(servletContext).addFilter(anyString(), any(Filter.class));
doReturn(new MockServletRegistration())
.when(servletContext).addServlet(anyString(), any(Servlet.class));
env = new MockEnvironment();
props = new JHipsterProperties();
webConfigurer = new WebConfigurer(env, props, new MockHazelcastInstance());
metricRegistry = new MetricRegistry();
webConfigurer.setMetricRegistry(metricRegistry);
}
示例14: checkForMatchAndAdd
import com.codahale.metrics.MetricRegistry; //导入依赖的package包/类
private void checkForMatchAndAdd(StatisticsType type, String[] statsRegularExpression, Statistics currStatistics, StatisticDescriptor currDesciptor) {
for (String currRegex : statsRegularExpression) {
if (Pattern.matches(currRegex, currDesciptor.getName())) {
MyInternalGauge gauge = new MyInternalGauge(currStatistics, currDesciptor);
metricRegistry.register(MetricRegistry.name(type.getName(), currStatistics.getTextId(), currDesciptor.getName()), gauge);
}
}
}
示例15: build
import com.codahale.metrics.MetricRegistry; //导入依赖的package包/类
@Override
public ManagedDataSource build(final MetricRegistry metricRegistry, final String name) {
final Properties properties = new Properties();
for (final Map.Entry<String, String> property : this.properties.entrySet()) {
properties.setProperty(property.getKey(), property.getValue());
}
final HikariConfig config = new HikariConfig();
config.setMetricRegistry(metricRegistry);
if (healthCheckRegistry != null) {
config.setHealthCheckRegistry(healthCheckRegistry);
}
config.setAutoCommit(autoCommit);
config.setDataSourceProperties(properties);
if (datasourceClassName != null) {
config.setDataSourceClassName(datasourceClassName);
} else {
config.setDriverClassName(driverClass);
}
config.setMaximumPoolSize(maxSize);
minSize.ifPresent(config::setMinimumIdle);
config.setPoolName(name);
config.setUsername(user);
config.setPassword(user != null && password == null ? "" : password);
return new HikariManagedPooledDataSource(config);
}