Java 类com.codahale.metrics.Timer 实例源码

项目:cruise-control    文件:TrainingFetcher.java   
TrainingFetcher(MetricSampler metricSampler,
                Cluster cluster,
                SampleStore sampleStore,
                Set<TopicPartition> assignedPartitions,
                long startTimeMs,
                long endTimeMs,
                Timer fetcherTimer,
                Meter fetcherFailureRate) {
  _cluster = cluster;
  _sampleStore = sampleStore;
  _metricSampler = metricSampler;
  _startTimeMs = startTimeMs;
  _endTimeMs = endTimeMs;
  _assignedPartitions = assignedPartitions;
  _fetcherTimer = fetcherTimer;
  _fetcherFailureRate = fetcherFailureRate;
}
项目:cruise-control    文件:TrainingFetcher.java   
@Override
protected void fetchMetricsForAssignedPartitions() throws MetricSamplingException {
  final Timer.Context ctx = _fetcherTimer.time();

  try {
    MetricSampler.Samples samples =
        _metricSampler.getSamples(_cluster, _assignedPartitions, _startTimeMs, _endTimeMs, MetricSampler.SamplingMode.BROKER_METRICS_ONLY);
    ModelParameters.addMetricObservation(samples.brokerMetricSamples());

    _sampleStore.storeSamples(samples);
  } catch (Exception e) {
    _fetcherFailureRate.mark();
    throw e;
  } finally {
    ctx.stop();
  }
}
项目:bireme    文件:ChangeLoader.java   
/**
 * Create a new {@code ChangeLoader}.
 *
 * @param cxt the Bireme Context
 * @param pipeLine the {@code PipeLine} belongs to
 * @param mappedTable the target table
 * @param taskIn a queue to get {@code LoadTask}
 */
public ChangeLoader(Context cxt, PipeLine pipeLine, String mappedTable,
    LinkedBlockingQueue<Future<LoadTask>> taskIn) {
  this.cxt = cxt;
  this.conf = cxt.conf;
  this.conn = null;
  this.mappedTable = mappedTable;
  this.table = cxt.tablesInfo.get(mappedTable);
  this.taskIn = taskIn;
  this.copyThread = Executors.newFixedThreadPool(1);

  // add statistics
  Timer[] timers = pipeLine.stat.addTimerForLoader(mappedTable);
  copyForDeleteTimer = timers[0];
  deleteTimer = timers[1];
  copyForInsertTimer = timers[2];

  logger = pipeLine.logger;
}
项目:verify-hub    文件:MatchingServiceHealthCheckClient.java   
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());
}
项目:redisson-benchmark    文件:AtomicLongIncBenchmark.java   
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("incr").time();
            jedis.incr("incr_" + threadNumber + "_" + iteration);
            time.stop();

            jedis.close();
        }
    };

    Benchmark benchmark = new Benchmark(bench);
    benchmark.run(args);
}
项目:outland    文件:DefaultGroupService.java   
private void removeGraphRelation(
    Group group,
    String relation,
    String subjectType,
    String subjectKey,
    String objectType,
    String objectKey,
    Timer timer
) {
  final String rel = REL_MARK;
  final String inv = INV_MARK;

  final String relationHashKey = subjectType + "." + subjectKey;
  final String relationRangeKey = rel + relation + "." + objectType + "." + objectKey;
  timed(timer,
      () -> groupStorage.removeRelation(group, relationHashKey, relationRangeKey));

  final String inverseRelationHashKey = objectType + "." + objectKey;
  final String inverseRelationRangeKey = inv + relation + "." + subjectType + "." + subjectKey;
  timed(timer,
      () -> groupStorage.removeRelation(group, inverseRelationHashKey, inverseRelationRangeKey));
}
项目:jboot    文件:JbootMetricTimerAopInterceptor.java   
@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {

    EnableMetricTimer annotation = methodInvocation.getThis().getClass().getAnnotation(EnableMetricTimer.class);

    String name = StringUtils.isBlank(annotation.value())
            ? methodInvocation.getThis().getClass().getName() + "." + methodInvocation.getMethod().getName()
            : annotation.value();

    Timer meter = Jboot.me().getMetric().timer(name);
    Timer.Context timerContext = meter.time();
    try {
        return methodInvocation.proceed();
    } finally {
        timerContext.stop();
    }

}
项目:redisson-benchmark    文件:SetAddBenchmark.java   
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("set").time();
            String key = "set_" + threadNumber;
            jedis.sadd(key, data);
            time.stop();

            jedis.close();
        }
    };

    Benchmark benchmark = new Benchmark(bench);
    benchmark.run(args);
}
项目:redisson-benchmark    文件:ListAddBenchmark.java   
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);
}
项目:retrofit-metrics    文件:TimedCallAdapterFactoryTest.java   
@Test
public void rxJava() throws Exception {
    CountDownLatch latch = new CountDownLatch(1);

    RxJavaClient client = retrofit.create(RxJavaClient.class);
    client.timed()
            .subscribe(response -> {
                try {
                    assertThat(response.code()).isEqualTo(HttpURLConnection.HTTP_OK);
                    assertThat(response.body()).isEqualTo(RESPONSE_OBJECT);
                } finally {
                    latch.countDown();
                }
            }, error -> {
                throw new RuntimeException("Test failed");
            });
    latch.await(1L, TimeUnit.SECONDS);

    Timer timer = metrics.timer(TIMER_NAME);
    assertThat(timer).isNotNull();
    assertThat(timer.getCount()).isEqualTo(1);
    assertThat(timer.getMeanRate()).isGreaterThan(0);
}
项目:hashsdn-controller    文件:TransactionRateLimiter.java   
private void adjustRateLimit() {
    final long count = acquireCount.incrementAndGet();
    if (count >= pollOnCount) {
        final Timer commitTimer = actorContext.getOperationTimer(ActorContext.COMMIT);
        double newRateLimit = calculateNewRateLimit(commitTimer, commitTimeoutInSeconds);

        if (newRateLimit < 1.0) {
            newRateLimit = getRateLimitFromOtherDataStores();
        }

        if (newRateLimit >= 1.0) {
            txRateLimiter.setRate(newRateLimit);
            pollOnCount = count + (long) newRateLimit / 2;
        }
    }
}
项目:ja-micro    文件:JsonHandlerTest.java   
@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);
}
项目:metrics-feign    文件:FeignOutboundMetricsMethodHandlerTest.java   
private void assertMetrics() {
    Timer timer = metricRegistry.getTimers().values().iterator().next();
    assertEquals("wrong number of invocations in metric.", 1, timer.getCount());

    assertTrue("wrong value of mean in metric.", timer.getMeanRate() > 0);

    assertEquals("wrong number of meter metrics.", 2, metricRegistry.getMeters().values().size());

    Set<Map.Entry<String, Meter>> entries = metricRegistry.getMeters().entrySet();

    entries.forEach(entry -> {
        if (entry.getKey().endsWith("Metered")) {
            assertEquals(String.format("wrong number of invocations in metric %s", entry.getKey()), 1,
                    entry.getValue().getCount());
        }
    });

}
项目:JInsight    文件:SpymemcachedRuleHelper.java   
public void onCallbackComplete(Operation operation) {
  Long startTime = removeObjectProperty(operation, OPERATION_PROPERTY_NAME);
  if (startTime == null) {
    return;//re-entrant
  }

  String op = Operations.getOperationName(operation);

  long t = clock.getTick() - startTime;
  Timer timer = opVsTimer.computeIfAbsent(op, s -> {
    String metricName = ROOT_NAME.withTags("command", op).toString();
    return RegistryService.getMetricRegistry().timer(metricName);
  });
  timer.update(t, TimeUnit.NANOSECONDS);

}
项目:JInsight    文件:HttpAsyncClientRuleHelper.java   
public void onResponseReceived(HttpRequest request, HttpResponse response) {
  Long startTime = removeObjectProperty(request, START_TIME_PROPERTY_NAME);
  if (startTime == null) {
    return;
  }

  long t = Clock.defaultClock().getTick() - startTime;

  String method = request.getRequestLine().getMethod();
  int statusCode = response.getStatusLine().getStatusCode();

  String metricName = ROOT_NAME.withTags(
      "method", method,
      "status", "" + statusCode).toString();
  Timer timer = RegistryService.getMetricRegistry().timer(metricName);
  timer.update(t, TimeUnit.NANOSECONDS);

}
项目:JInsight    文件:UrlConnectionRuleHelper.java   
public void onGetInputStream(HttpURLConnection urlConnection, int statusCode) {
  Long startTime = removeObjectProperty(urlConnection, START_TIME_PROPERTY_NAME);
  if (startTime == null) {
    return;
  }

  long t = Clock.defaultClock().getTick() - startTime;
  String method = urlConnection.getRequestMethod();
  String status = "" + statusCode;
  Timer timer = timers.computeIfAbsent(status + method, s -> {
    TagEncodedMetricName metricName = ROOT_NAME.withTags(
        "method", method,
        "status", status);
    return getTimer(metricName);
  });

  timer.update(t, TimeUnit.NANOSECONDS);
}
项目:hashsdn-controller    文件:ThreePhaseCommitCohortProxyTest.java   
@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);

    actorContext = new ActorContext(getSystem(), actorFactory.createActor(Props.create(DoNothingActor.class)),
            new MockClusterWrapper(), new MockConfiguration(), DatastoreContext.newBuilder().build(),
            new PrimaryShardInfoFutureCache()) {
        @Override
        public Timer getOperationTimer(final String operationName) {
            return commitTimer;
        }

        @Override
        public double getTxCreationLimit() {
            return 10.0;
        }
    };

    doReturn(commitTimerContext).when(commitTimer).time();
    doReturn(commitSnapshot).when(commitTimer).getSnapshot();
    for (int i = 1; i < 11; i++) {
        // Keep on increasing the amount of time it takes to complete transaction for each tenth of a
        // percentile. Essentially this would be 1ms for the 10th percentile, 2ms for 20th percentile and so on.
        doReturn(TimeUnit.MILLISECONDS.toNanos(i) * 1D).when(commitSnapshot).getValue(i * 0.1);
    }
}
项目:JInsight    文件:RuleHelper.java   
public static void stop(OperationId id, Supplier<Timer> timerSupplier) {
  OperationId lastId = lastId();
  if (lastId != id) {
    //TODO better error handling
    LOGGER.error("Operation Context Mismatch. Expected: " + id + " got " + lastId);
    return;
  }

  OperationContext context = CONTEXT_STACK.get().pop();
  if (context == RENTRANT) {
    return;
  }

  Timer timer = timerSupplier.get();
  if (timer != null) {
    long t = clock.getTick() - context.getStartTime();
    timer.update(t, TimeUnit.NANOSECONDS);
  }
}
项目:dropwizard-influxdb-reporter    文件:InfluxDbMeasurementReporter.java   
@Override
public void report(final SortedMap<String, Gauge> gauges,
                   final SortedMap<String, Counter> counters,
                   final SortedMap<String, Histogram> histograms,
                   final SortedMap<String, Meter> meters,
                   final SortedMap<String, Timer> timers) {
  final long timestamp = clock.instant().toEpochMilli();

  final ImmutableList<InfluxDbMeasurement> influxDbMeasurements = ImmutableList.<InfluxDbMeasurement>builder()
    .addAll(transformer.fromGauges(gauges, timestamp))
    .addAll(transformer.fromCounters(counters, timestamp))
    .addAll(transformer.fromHistograms(histograms, timestamp))
    .addAll(transformer.fromMeters(meters, timestamp))
    .addAll(transformer.fromTimers(timers, timestamp))
    .build();

  sender.send(influxDbMeasurements);
}
项目:logistimo-web-service    文件:MessageService.java   
public ServiceResponse send(List<IUserAccount> users, String message, int messageType,
                            String subject, String port, String logMessage, Integer notif,
                            String eventType) throws MessageHandlingException, IOException {
  xLogger.fine("Entered send");

  // Get the address list
  List<String> addresses = getAddresses(users);
  final Timer.Context context = SMS.equals(type) ? smsTimer.time() : emailTimer.time();
  ServiceResponse resp = null;
  try {
    // Send the message and get response
    resp = doSend(addresses, message, messageType, subject, port, domainId);
  } finally {
    context.stop();
  }
  // Store the response
  if (logging) {
    logMessage(domainId, sendingUserId, logMessage != null ? logMessage : message, users, resp,
        notif, eventType);
  }
  xLogger.fine("Exiting send");
  return resp;
}
项目:QDrill    文件:BlockMapBuilder.java   
/**
 * Builds a mapping of block locations to file byte range
 */
private ImmutableRangeMap<Long,BlockLocation> buildBlockMap(FileStatus status) throws IOException {
  final Timer.Context context = metrics.timer(BLOCK_MAP_BUILDER_TIMER).time();
  BlockLocation[] blocks;
  ImmutableRangeMap<Long,BlockLocation> blockMap;
  blocks = fs.getFileBlockLocations(status, 0 , status.getLen());
  ImmutableRangeMap.Builder<Long, BlockLocation> blockMapBuilder = new ImmutableRangeMap.Builder<Long,BlockLocation>();
  for (BlockLocation block : blocks) {
    long start = block.getOffset();
    long end = start + block.getLength();
    Range<Long> range = Range.closedOpen(start, end);
    blockMapBuilder = blockMapBuilder.put(range, block);
  }
  blockMap = blockMapBuilder.build();
  blockMapMap.put(status.getPath(), blockMap);
  context.stop();
  return blockMap;
}
项目:redisson-benchmark    文件:ListAddBenchmark.java   
public static void main(String[] args) throws InterruptedException {
    Bench<RedissonClient> bench = new RedissonBench() {
        @Override
        public void executeOperation(String data, RedissonClient benchInstance, int threadNumber, int iteration,
                MetricRegistry metrics) {
            RList<String> list = benchInstance.getList("list_" + threadNumber);

            Timer.Context time = metrics.timer("list").time();
            list.add(data);
            time.stop();
        }
    };

    Benchmark benchmark = new Benchmark(bench);
    benchmark.run(args);
}
项目:stdds-monitor    文件:STDDSController.java   
@RequestMapping("/all-links")
public String allLinks(Model model) {
    Timer timer = metricRegistry.timer("all-links");
    Context context = timer.time();
    try {
        List<Link> asdex = linkRepo.findByNameContainingOrderByNameAsc("ASDE-X");
        model.addAttribute("asdex", asdex);
        List<Link> assc = linkRepo.findByNameContainingOrderByNameAsc("ASSC");
        model.addAttribute("assc", assc);
        List<Link> tdls = linkRepo.findByNameContainingOrderByNameAsc("TDLS");
        model.addAttribute("tdls", tdls);
        List<Link> efsts = linkRepo.findByNameContainingOrderByNameAsc("EFSTS");
        model.addAttribute("efsts", efsts);
        List<Link> stars = linkRepo.findByNameContainingOrderByNameAsc("STARS");
        model.addAttribute("stars", stars);
        List<Link> rvr = linkRepo.findByNameContainingOrderByNameAsc("RVR");
        model.addAttribute("rvr", rvr);

        return "all-links";
    } finally {
        context.stop();
    }
}
项目:cruise-control    文件:SamplingFetcher.java   
/**
 * Execute one iteration of metric sampling for all the assigned partitions.
 */
@Override
protected void fetchMetricsForAssignedPartitions() throws MetricSamplingException {
  final Timer.Context ctx = _fetchTimer.time();

  try {
    MetricSampler.Samples samples = fetchSamples();
    _sampleStore.storeSamples(samples);
  } catch (Exception e) {
    _fetchFailureRate.mark();
    throw e;
  } finally {
    ctx.stop();
  }
}
项目:snowflake    文件:ZKInt32IdGenerator.java   
@Override
public Integer generateId() {
    final Timer.Context context = timer.time();
    try {
        return (int) rangeSequence.incrementAndGet();
    } catch (Exception e) {
        throw e;
    } finally {
        context.stop();
    }
}
项目:drinkwater-java    文件:TracerBean.java   
public void stop(Object exchange) {
    if (exchange != null && exchange instanceof Exchange) {
        Exchange exchange1 = (Exchange) exchange;
        Object timerContext = exchange1.getIn().getHeader(MetricsOperationTimer);
        if (timerContext != null) {
            ((Timer.Context) timerContext).stop();
        }
    }
}
项目:bireme    文件:PipeLineStat.java   
/**
 * Add {@code Timer}s for a {@link ChangeLoader}. Each {@code ChangeLoader} has three Timer.
 * <ul>
 * <li>Record the time of copy followed by delete</li>
 * <li>Record the time of delete</li>
 * <li>Record the time of insert in copy way</li>
 * </ul>
 *
 * @param table the {@code ChangeLoader}'s table
 * @return the registered Timer
 */
public Timer[] addTimerForLoader(String table) {
  Timer[] timers = new Timer[3];
  timers[0] = register.timer(MetricRegistry.name(pipeLineName, table, "Loader", "CopyForDelete"));
  timers[1] = register.timer(MetricRegistry.name(pipeLineName, table, "Loader", "Delete"));
  timers[2] = register.timer(MetricRegistry.name(pipeLineName, table, "Loader", "Insert"));

  copyForDelete.put(table, timers[0]);
  delete.put(table, timers[1]);
  insert.put(table, timers[2]);
  return timers;
}
项目:metrics-tutorials    文件:TimersDemo.java   
public String handleRequest() {
    final Timer.Context context = responses.time();
    try {
        // etc;
        waitForMillis(new Random().nextInt(500));
        return "OK";
    } finally {
        context.stop();
    }
}
项目:outland    文件:MetricsTimer.java   
default <T> T timed(Timer timer, Supplier<T> supplier) {
  Timer.Context time = timer.time();
  try {
    return supplier.get();
  } finally {
    time.stop();
  }
}
项目:retrofit-metrics    文件:TimedCallAdapterFactoryTest.java   
@Test
public void synchronous() throws IOException {
    TimedClient client = retrofit.create(TimedClient.class);
    Response<NamedObject> response = client.timed().execute();
    assertThat(response.code()).isEqualTo(HttpURLConnection.HTTP_OK);
    assertThat(response.body()).isEqualTo(RESPONSE_OBJECT);

    Timer timer = metrics.timer(TIMER_NAME);
    assertThat(timer).isNotNull();
    assertThat(timer.getCount()).isEqualTo(1);
    assertThat(timer.getMeanRate()).isGreaterThan(0);
}
项目:metrics-feign    文件:FeignOutboundMetricsDecorator.java   
@Override
public Object invoke(Object[] argv) throws Throwable {
    try {

        final Meter meter = this.meters.get(method);
        if (meter != null) {
            meter.mark();
        }

        final Timer timer = this.timers.get(method);
        if (timer != null) {
            this.context = timer.time();
        }

        return methodHandler.invoke(argv);

    } catch (Exception e) {

        final FeignOutboundMetricsDecorator.ExceptionMeterMetric metric =
                (method != null) ? this.exceptionMeters.get(method) : null;

        if (metric != null && (metric.cause.isAssignableFrom(e.getClass()) || (e.getCause() != null
                && metric.cause.isAssignableFrom(e.getCause().getClass())))) {
            metric.meter.mark();
        }

        throw e;
    } finally {
        if (this.context != null) {
            this.context.close();
        }
    }
}
项目:mokka7    文件:MonitoredS7Client.java   
@Override
public int readArea(AreaType area, int db, int start, int amount, DataType type, byte[] buffer) throws S7Exception {
    final Timer.Context context = reads.time();
    try {
        return super.readArea(area, db, start, amount, type, buffer);
    } finally {
        context.stop();
    }
}
项目:mokka7    文件:MonitoredS7Client.java   
@Override
public boolean writeArea(AreaType area, int db, int start, int amount, DataType type, byte[] buffer) throws S7Exception {
    final Timer.Context context = writes.time();
    try {
        return super.writeArea(area, db, start, amount, type, buffer);
    } finally {
        context.stop();
    }
}
项目:redisson-benchmark    文件:BinaryBenchmark.java   
public static void main(String[] args) throws InterruptedException {
    Bench<RedissonClient> bench = new RedissonBench() {
        @Override
        public void executeOperation(String data, RedissonClient benchInstance, int threadNumber, int iteration,
                MetricRegistry metrics) {
            RBucket<Object> bucket = benchInstance.getBucket("bucket_" + threadNumber + "_" + iteration);
            Timer.Context time = metrics.timer("bucket").time();
            bucket.set(value);
            time.stop();
        }
    };

    Benchmark benchmark = new Benchmark(bench);
    benchmark.run(args);
}
项目:mokka7    文件:MonitoredS7Client.java   
@Override
public boolean readMultiVars(S7DataItem[] items, int itemsCount) throws S7Exception {
    final Timer.Context context = multiReads.time();
    try {
        return super.readMultiVars(items, itemsCount);
    } finally {
        context.stop();
    }
}
项目:JInsight    文件:ApptuitReporter.java   
@Override
public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters,
    SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters,
    SortedMap<String, Timer> timers) {

  DataPointCollector collector = new DataPointCollector(System.currentTimeMillis() / 1000);

  buildReportTimer.time(() -> {
    debug("################");

    debug(">>>>>>>> Guages <<<<<<<<<");
    gauges.forEach(collector::collectGauge);
    debug(">>>>>>>> Counters <<<<<<<<<");
    counters.forEach(collector::collectCounter);
    debug(">>>>>>>> Histograms <<<<<<<<<");
    histograms.forEach(collector::collectHistogram);
    debug(">>>>>>>> Meters <<<<<<<<<");
    meters.forEach(collector::collectMeter);
    debug(">>>>>>>> Timers <<<<<<<<<");
    timers.forEach(collector::collectTimer);

    debug("################");
  });

  sendReportTimer.time(() -> {
    Collection<DataPoint> dataPoints = collector.dataPoints;
    dataPointsReporter.put(dataPoints);
    //dataPoints.forEach(System.out::println);
  });
}
项目:JInsight    文件:ContextMetricsHelper.java   
private Timer getTimer(String method, int status) {
  String key = String.valueOf(status) + method;
  return timers.computeIfAbsent(key, s -> {
    TagEncodedMetricName metric = requestCountRootMetric;
    if (method != null) {
      metric = metric.withTags("method", method, "status", String.valueOf(status));
    }
    return registry.timer(metric.toString());
  });
}
项目:JInsight    文件:WhalinmemcachedRuleHelper.java   
private Timer getTimerForOp(String op) {
  switch (op) {
    case "set":
    case "cas":
      return SET_OPERATION_TIMER;
    case "get":
    case "gets":
      return GET_OPERATION_TIMER;
    case "delete":
      return DELETE_OPERATION_TIMER;
    case "add":
      return ADD_OPERATION_TIMER;
    case "replace":
      return REPLACE_OPERATION_TIMER;
    case "append":
      return APPEND_OPERATION_TIMER;
    case "prepend":
      return PREPEND_OPERATION_TIMER;
    case "addOrIncr":
    case "incr":
      return INCR_OPERATION_TIMER;
    case "addOrDecr":
    case "decr":
      return DECR_OPERATION_TIMER;
    default:
      throw new IllegalArgumentException("Unsupported op: " + op);
  }
}
项目:JInsight    文件:JedisRuleHelper.java   
private Timer getTimer(String methName) {
  String op = commands.get(methName);
  return timers.computeIfAbsent(op, s -> {
    String metric = COMMANDS_BASE_NAME.withTags("command", op).toString();
    return RegistryService.getMetricRegistry().timer(metric);
  });
}
项目:redisson-benchmark    文件:BucketSetBenchmark.java   
public static void main(String[] args) throws InterruptedException {
    Bench<RedissonClient> bench = new RedissonBench() {
        @Override
        public void executeOperation(String data, RedissonClient benchInstance, int threadNumber, int iteration,
                MetricRegistry metrics) {
            RBucket<String> bucket = benchInstance.getBucket("bucket_" + threadNumber + "_" + iteration);
            Timer.Context time = metrics.timer("bucket").time();
            bucket.set(data);
            time.stop();
        }
    };

    Benchmark benchmark = new Benchmark(bench);
    benchmark.run(args);
}