@Override public void increment(String label, int delta, String topic) { Stats.incr(label, delta); }
@Override public void metric(String label, double value, String topic) { Stats.addMetric(label, (int) value); }
@Override public void gauge(String label, double value, String topic) { Stats.setGauge(label, value); } }
@Override public Future<PinLaterDequeueResponse> dequeueJobs( RequestContext context, final PinLaterDequeueRequest request) { if (!queueConfig.allowDequeue(request.getQueueName(), request.getLimit())) { Stats.incr(request.getQueueName() + "_dequeue_requests_rate_limited"); return Future.exception(new PinLaterException(ErrorCode.DEQUEUE_RATE_LIMITED, "Dequeue rate limit exceeded for queue: " + request.getQueueName())); } return Stats.timeFutureMillis( "PinLaterService.dequeueJobs", backend.dequeueJobs(context.getSource(), request).onSuccess( new Function<PinLaterDequeueResponse, BoxedUnit>() { @Override public BoxedUnit apply(PinLaterDequeueResponse response) { Stats.incr(request.getQueueName() + "_dequeue", response.getJobsSize()); return null; } }).rescue(new LogAndWrapException<PinLaterDequeueResponse>( context, "dequeueJobs", request.toString()))); }
@Override public StatsLogger getStatsLogger(String scope) { return new OstrichStatsLoggerImpl(scope, com.twitter.ostrich.stats.Stats.get(collectionName)); } });
public static void clearLabel(String name) { long threadId = Thread.currentThread().getId(); name += "." + threadId; Stats.clearLabel(name); }
public void succeed(Map<String, String> additionalTags) { this.watch.stop(); if (tags == null) { this.tags = additionalTags; } else { this.tags.putAll(additionalTags); } Stats .incr(StatsUtil .getStatsName(this.methodName, this.statsName, StatsUtil.StatsType.SUCCESS, tags)); Stats.addMetric( StatsUtil.getStatsName(this.methodName, this.statsName, StatsUtil.StatsType.TIME, tags), (int) watch.getTime()); }
public static void main(String[] args) { try { String serverHostName = InetAddress.getLocalHost().getHostName(); PinLaterQueueConfig queueConfig = new PinLaterQueueConfig(CONFIGURATION); queueConfig.initialize(); String backend = CONFIGURATION.getString("PINLATER_BACKEND"); PinLaterBackendIface backendIFace = getBackendIface(backend, serverHostName); PinLaterServiceImpl serviceImpl = new PinLaterServiceImpl(backendIFace, queueConfig); PinLater.Service service = new PinLater.Service(serviceImpl, new TBinaryProtocol.Factory()); ServiceShutdownHook.register(ServerBuilder.safeBuild( service, ServerBuilder.get() .name("PinLaterService") .codec(ThriftServerFramedCodec.get()) .hostConnectionMaxIdleTime(Duration.fromTimeUnit( CONFIGURATION.getInt("SERVER_CONN_MAX_IDLE_TIME_MINUTES"), TimeUnit.MINUTES)) .maxConcurrentRequests(CONFIGURATION.getInt("MAX_CONCURRENT_REQUESTS")) .reportTo(new OstrichStatsReceiver(Stats.get(""))) .bindTo(new InetSocketAddress(CONFIGURATION.getInt("THRIFT_PORT"))))); new OstrichAdminService(CONFIGURATION.getInt("OSTRICH_PORT")).start(); LOG.info("\n#######################################" + "\n# Ready To Serve Requests. #" + "\n#######################################"); } catch (Exception e) { LOG.error("Failed to start the pinlater server", e); System.exit(1); } } }
@Override public void increment(String label, String topic) { Stats.incr(label); }
@Test public void metric() throws Exception { metricCollector.metric("expectedLabel", 42.0, "ignored"); PowerMockito.verifyStatic(); Stats.addMetric("expectedLabel", 42); }
@Test public void gauge() throws Exception { metricCollector.gauge("expectedLabel", 4.2, "ignored"); PowerMockito.verifyStatic(); Stats.setGauge("expectedLabel", 4.2); } }
public static void incr(String name) { Stats.incr(name); }
public void failed(Map<String, String> additionalTags) { this.watch.stop(); if (tags == null) { this.tags = additionalTags; } else { this.tags.putAll(additionalTags); } Stats .incr(StatsUtil .getStatsName(this.methodName, this.statsName, StatsUtil.StatsType.FAILURE, tags)); Stats.addMetric( StatsUtil.getStatsName(this.methodName, this.statsName, StatsUtil.StatsType.TIME, tags), (int) watch.getTime()); }
public static void addMetric(String name, int value) { Stats.addMetric(name, value); }
public static void gauge(String name, double value) { Stats.setGauge(name, value); }
@Test public void incrementByOne() throws Exception { metricCollector.increment("expectedLabel", "ignored"); PowerMockito.verifyStatic(); Stats.incr("expectedLabel"); }
Stats.incr("mysql-unhealthy-shard-dequeue"); return shardResponse; long createdAtMillis = tuple._5().getTime(); if (attemptsAllowed == attemptsRemaining) { Stats.addMetric(String.format("%s_first_dequeue_delay_ms", queueName), (int) (currentTimeMillis - createdAtMillis)); Stats.addMetric(String.format("%s_dequeue_delay_ms", queueName), (int) (currentTimeMillis - updatedAtMillis)); if (shouldRetry && numAutoRetries > 0) { Stats.incr("dequeue-failures-retry"); return dequeueJobsFromShard(queueName, shardName, priority, claimDescriptor, jobsNeeded, numAutoRetries - 1, dryRun);
public static void addMetric(String name, int value) { Stats.addMetric(name, value); }