void onRequestRejected() { rejectedRequests.increment(); } }
/** * Records a failed attempt to send a notification and updates metrics accordingly. * * @param apnsClient the client that failed to write the notification; note that this is ignored by * {@code MicrometerApnsClientMetricsListener} instances, which should always be used for exactly one client * @param notificationId an opaque, unique identifier for the notification that could not be written */ @Override public void handleWriteFailure(final ApnsClient apnsClient, final long notificationId) { this.notificationStartTimes.remove(notificationId); this.writeFailures.increment(); }
@Override public void onThrowable(Throwable t) { Loggers.RAFT.error("NACOS-RAFT error while sending heart-beat to peer: {} {}", server, t); MetricsMonitor.getLeaderSendBeatFailedException().increment(); } });
@Override public void failed(Exception ex) { Integer failCount = serverIp2unhealthCount.get(serverIp); failCount = failCount == null ? Integer.valueOf(0) : failCount; failCount++; serverIp2unhealthCount.put(serverIp, failCount); if (failCount > maxFailCount) { if (!serverListUnhealth.contains(serverIp)) { serverListUnhealth.add(serverIp); } defaultLog.error("unhealthIp:{}, unhealthCount:{}", serverIp, failCount); MetricsMonitor.getUnhealthException().increment(); } }
@Override public void cancelled() { Integer failCount = serverIp2unhealthCount.get(serverIp); failCount = failCount == null ? Integer.valueOf(0) : failCount; failCount++; serverIp2unhealthCount.put(serverIp, failCount); if (failCount > maxFailCount) { if (!serverListUnhealth.contains(serverIp)) { serverListUnhealth.add(serverIp); } defaultLog.error("unhealthIp:{}, unhealthCount:{}", serverIp, failCount); MetricsMonitor.getUnhealthException().increment(); } } }
/** * For IllegalArgumentException, we are returning void with status code as 400, so our error-page will be used in * this case. * * @throws IllegalArgumentException */ @ExceptionHandler(IllegalArgumentException.class) public void handleIllegalArgumentException(HttpServletResponse response, Exception ex) throws IOException { MetricsMonitor.getIllegalArgumentException().increment(); response.setStatus(400); if (ex.getMessage() != null) { response.getWriter().println(ex.getMessage()); } else { response.getWriter().println("invalid param"); } }
/** * For NacosException * * @throws NacosException */ @ExceptionHandler(NacosException.class) public void handleNacosException(HttpServletResponse response, NacosException ex) throws IOException { MetricsMonitor.getNacosException().increment(); response.setStatus(ex.getErrCode()); if (ex.getErrMsg() != null) { response.getWriter().println(ex.getErrMsg()); } else { response.getWriter().println("unknown exception"); } }
@Override public void onComplete() { if (done) { this.malformedSourceCounter.increment(); return; } done = true; //we don't record the time between last onNext and onComplete, // because it would skew the onNext count by one this.subscribeToTerminateSample.stop(subscribeToCompleteTimer); actual.onComplete(); }
/** * For DataAccessException * * @throws DataAccessException */ @ExceptionHandler(DataAccessException.class) public void handleDataAccessException(HttpServletResponse response, DataAccessException ex) throws DataAccessException { MetricsMonitor.getDbException().increment(); throw new CannotGetJdbcConnectionException(ex.getMessage()); }
@Override public void onComplete() { if (done) { this.malformedSourceCounter.increment(); return; } done = true; this.subscribeToTerminateSample.stop(subscribeToCompleteTimer); actual.onComplete(); }
@Benchmark public int countSum() { counter.increment(); return sum(); }
@Benchmark public void micrometerCounterTags(MicrometerState state) { state.registry.counter("dynamicTags", "key1", "value1", "key2", "value2").increment(); }
@Override public Integer onCompleted(Response response) throws Exception { if (response.getStatusCode() != HttpURLConnection.HTTP_OK) { Loggers.RAFT.error("NACOS-RAFT beat failed: {}, peer: {}", response.getResponseBody(), server); MetricsMonitor.getLeaderSendBeatFailedException().increment(); return 1; } peers.update(JSON.parseObject(response.getResponseBody(), RaftPeer.class)); Loggers.RAFT.info("receive beat response from: {}", url); return 0; }
@Override public void onNext(T t) { if (done) { this.malformedSourceCounter.increment(); Operators.onNextDropped(t, actual.currentContext()); return; } actual.onNext(t); }
@Override public void onError(Throwable e) { if (done) { this.malformedSourceCounter.increment(); Operators.onErrorDropped(e, actual.currentContext()); return; } done = true; //register a timer for that particular exception Timer timer = subscribeToErrorTimerFactory.apply(e); //record error termination this.subscribeToTerminateSample.stop(timer); actual.onError(e); }
@Override public void onSubscribe(Subscription s) { if (Operators.validate(this.s, s)) { this.subscribedCounter.increment(); this.subscribeToTerminateSample = Timer.start(clock); if (s instanceof Fuseable.QueueSubscription) { //noinspection unchecked this.qs = (Fuseable.QueueSubscription<T>) s; } this.s = s; actual.onSubscribe(this); } }
@Benchmark public int countSumWithRegistryLookup() { registry.counter("counter").increment(); return sum(); }
@Override public void cancelled() { LogUtil.notifyLog.error( "[notify-exception] target:{} dataid:{} group:{} ts:{}", new Object[] {task.target, task.getGroup(), task.getGroup(), task.getLastModified()}, "CANCELED"); //get delay time and set fail count to the task int delay = getDelayTime(task); Queue<NotifySingleTask> queue = new LinkedList<NotifySingleTask>(); queue.add(task); AsyncTask asyncTask = new AsyncTask(httpclient, queue); ((ScheduledThreadPoolExecutor)EXCUTOR).schedule(asyncTask, delay, TimeUnit.MILLISECONDS); LogUtil.notifyLog.error( "[notify-retry] target:{} dataid:{} group:{} ts:{}", new Object[] {task.target, task.getDataId(), task.getGroup(), task.getLastModified()}); MetricsMonitor.getConfigNotifyException().increment(); }
@Override public void onSubscribe(Subscription s) { if (Operators.validate(this.s, s)) { this.subscribedCounter.increment(); this.subscribeToTerminateSample = Timer.start(clock); this.lastNextEventNanos = clock.monotonicTime(); if (s instanceof Fuseable.QueueSubscription) { //noinspection unchecked this.qs = (Fuseable.QueueSubscription<T>) s; } this.s = s; actual.onSubscribe(this); } }
@Override public void onNext(T t) { if (done) { this.malformedSourceCounter.increment(); Operators.onNextDropped(t, actual.currentContext()); return; } //record the delay since previous onNext/onSubscribe. This also records the count. long last = this.lastNextEventNanos; this.lastNextEventNanos = clock.monotonicTime(); this.onNextIntervalTimer.record(lastNextEventNanos - last, TimeUnit.NANOSECONDS); actual.onNext(t); }