public StreamAcquireLimiter(StreamManager streamManager, MovingAverageRate serviceRps, double serviceRpsLimit, StatsLogger statsLogger) { this.streamManager = streamManager; this.serviceRps = serviceRps; this.serviceRpsLimit = serviceRpsLimit; this.overlimitCounter = statsLogger.getCounter("overlimit"); }
public Counter requestCounter(String counterName) { return requestStatsLogger.getCounter(counterName); }
public Counter requestDeniedCounter(String counterName) { return requestDeniedStatsLogger.getCounter(counterName); }
public Counter recordsCounter(String counterName) { return recordsStatsLogger.getCounter(counterName); }
public Counter baseCounter(String opName) { return baseStatsLogger.getCounter(opName); }
@Override public Counter getCounter(final String statName) { final Counter firstCounter = first.getCounter(statName); final Counter secondCounter = second.getCounter(statName); return new Counter() { @Override
public ComposableRequestLimiter( RateLimiter limiter, OverlimitFunction<Request> overlimitFunction, CostFunction<Request> costFunction, StatsLogger statsLogger) { Preconditions.checkNotNull(limiter); Preconditions.checkNotNull(overlimitFunction); Preconditions.checkNotNull(costFunction); this.limiter = limiter; this.overlimitFunction = overlimitFunction; this.costFunction = costFunction; this.overlimitCounter = statsLogger.getCounter("overlimit"); }
public StatsFilter(StatsLogger stats) { this.stats = stats; this.outstandingAsync = stats.getCounter("outstandingAsync"); this.serviceExec = stats.getOpStatsLogger("serviceExec"); } }
public Counter streamRequestCounter(String streamName, String opName, String counterName) { return streamRequestScope(streamName, opName).getCounter(counterName); } }
void countException(Throwable t, StatsLogger streamExceptionLogger) { String exceptionName = null == t ? "null" : t.getClass().getName(); Counter counter = exceptionCounters.get(exceptionName); if (null == counter) { counter = exceptionStatLogger.getCounter(exceptionName); Counter oldCounter = exceptionCounters.putIfAbsent(exceptionName, counter); if (null != oldCounter) { counter = oldCounter; } } counter.inc(); streamExceptionLogger.getCounter(exceptionName).inc(); }
public Counter scopedRequestCounter(String opName, String counterName) { return requestScope(opName).getCounter(counterName); }
public Counter getExceptionCounter(int rc) { Counter counter = exceptionCounters.get(rc); if (null != counter) { return counter; } // TODO: it would be better to have BKException.Code.get(rc) synchronized (exceptionCounters) { counter = exceptionCounters.get(rc); if (null != counter) { return counter; } counter = parentLogger.getCounter(getMessage(rc)); exceptionCounters.put(rc, counter); } return counter; } }
public EnvelopedEntry(byte version, StatsLogger statsLogger) throws InvalidEnvelopedEntryException { Preconditions.checkNotNull(statsLogger); if (version < LOWEST_SUPPORTED_VERSION || version > HIGHEST_SUPPORTED_VERSION) { throw new InvalidEnvelopedEntryException("Invalid enveloped entry version " + version + ", expected to be in [ " + LOWEST_SUPPORTED_VERSION + " ~ " + HIGHEST_SUPPORTED_VERSION + " ]"); } this.version = version; this.compressionStat = statsLogger.getOpStatsLogger("compression_time"); this.decompressionStat = statsLogger.getOpStatsLogger("decompression_time"); this.compressedEntryBytes = statsLogger.getCounter("compressed_bytes"); this.decompressedEntryBytes = statsLogger.getCounter("decompressed_bytes"); }
private void countStatusCode(StatusCode code) { Counter counter = statusCodeCounters.get(code); if (null == counter) { counter = statusCodeStatLogger.getCounter(code.name()); Counter oldCounter = statusCodeCounters.putIfAbsent(code, counter); if (null != oldCounter) { counter = oldCounter; } } counter.inc(); statusCodeTotal.inc(); }
@Override public void run() { if (null != dlsn) { requestStat.registerSuccessfulEvent(System.currentTimeMillis() - requestMillis); } else { LOG.error("Failed to publish to {} : ", streamName, cause); requestStat.registerFailedEvent(System.currentTimeMillis() - requestMillis); exceptionsLogger.getCounter(cause.getClass().getName()).inc(); if (cause instanceof DLException) { DLException dle = (DLException) cause; dlErrorCodeLogger.getCounter(dle.getCode().toString()).inc(); } } } }
public SimplePermitLimiter(boolean darkmode, int permitsMax, StatsLogger statsLogger, boolean singleton, Feature disableWriteLimitFeature) { this.permits = new AtomicInteger(0); this.permitsMax = permitsMax; this.darkmode = darkmode; this.disableWriteLimitFeature = disableWriteLimitFeature; // stats if (singleton) { statsLogger.registerGauge("num_permits", new Gauge<Number>() { @Override public Number getDefaultValue() { return 0; } @Override public Number getSample() { return permits.get(); } }); } acquireFailureCounter = statsLogger.getCounter("acquireFailure"); permitsMetric = statsLogger.getOpStatsLogger("permits"); }
public ZKDistributedLock( OrderedScheduler lockStateExecutor, SessionLockFactory lockFactory, String lockPath, long lockTimeout, StatsLogger statsLogger) { this.lockStateExecutor = lockStateExecutor; this.lockPath = lockPath; this.lockTimeout = lockTimeout; this.lockFactory = lockFactory; lockStatsLogger = statsLogger.scope("lock"); acquireStats = lockStatsLogger.getOpStatsLogger("acquire"); reacquireStats = lockStatsLogger.getOpStatsLogger("reacquire"); internalTryRetries = lockStatsLogger.getCounter("internalTryRetries"); }
/** * Create a future pool with stats exposed. * * @param futurePool underlying future pool to execute futures * @param statsLogger stats logger to receive exposed stats * @param traceTaskExecution flag to enable/disable exposing stats about task execution * @param traceTaskExecutionWarnTimeUs flag to enable/disable logging slow tasks * whose execution time is above this value */ public MonitoredFuturePool(FuturePool futurePool, StatsLogger statsLogger, boolean traceTaskExecution, long traceTaskExecutionWarnTimeUs) { this.futurePool = futurePool; this.traceTaskExecution = traceTaskExecution; this.traceTaskExecutionWarnTimeUs = traceTaskExecutionWarnTimeUs; this.statsLogger = statsLogger; this.taskPendingTime = statsLogger.getOpStatsLogger("task_pending_time"); this.taskExecutionTime = statsLogger.getOpStatsLogger("task_execution_time"); this.taskEnqueueTime = statsLogger.getOpStatsLogger("task_enqueue_time"); this.taskPendingCounter = statsLogger.getCounter("tasks_pending"); }
@Override public void configurationChanged(ConfigurationEvent event) { // Note that this method may be called several times if several config options // are changed. The effect is harmless except that we create and discard more // objects than we need to. LOG.debug("Config changed callback invoked with event {} {} {} {}", new Object[] { event.getPropertyName(), event.getPropertyValue(), event.getType(), event.isBeforeUpdate()}); if (!event.isBeforeUpdate()) { limiterStatsLogger.getCounter("config_changed").inc(); LOG.debug("Rebuilding limiter"); limiter = build(); } } };
BKAsyncLogWriter(DistributedLogConfiguration conf, DynamicDistributedLogConfiguration dynConf, BKDistributedLogManager bkdlm, BKLogWriteHandler writeHandler, /** log writer owns the handler **/ FeatureProvider featureProvider, StatsLogger dlmStatsLogger) { super(conf, dynConf, bkdlm); this.writeHandler = writeHandler; this.streamFailFast = conf.getFailFastOnStreamNotReady(); this.disableRollOnSegmentError = conf.getDisableRollingOnLogSegmentError(); // features disableLogSegmentRollingFeature = featureProvider.getFeature(CoreFeatureKeys.DISABLE_LOGSEGMENT_ROLLING.name().toLowerCase()); // stats this.statsLogger = dlmStatsLogger.scope("log_writer"); this.writeOpStatsLogger = statsLogger.getOpStatsLogger("write"); this.markEndOfStreamOpStatsLogger = statsLogger.getOpStatsLogger("mark_end_of_stream"); this.bulkWriteOpStatsLogger = statsLogger.getOpStatsLogger("bulk_write"); this.getWriterOpStatsLogger = statsLogger.getOpStatsLogger("get_writer"); this.pendingRequestDispatch = statsLogger.getCounter("pending_request_dispatch"); }