io.micrometer.core.instrument.Counter.increment()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(202)

本文整理了Java中io.micrometer.core.instrument.Counter.increment()方法的一些代码示例,展示了Counter.increment()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Counter.increment()方法的具体详情如下:
包路径:io.micrometer.core.instrument.Counter
类名称:Counter
方法名:increment

Counter.increment介绍

暂无

代码示例

代码示例来源:origin: line/armeria

void onRequestRejected() {
    rejectedRequests.increment();
  }
}

代码示例来源:origin: relayrides/pushy

/**
 * 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();
}

代码示例来源:origin: alibaba/nacos

@Override
  public void onThrowable(Throwable t) {
    Loggers.RAFT.error("NACOS-RAFT error while sending heart-beat to peer: {} {}", server, t);
    MetricsMonitor.getLeaderSendBeatFailedException().increment();
  }
});

代码示例来源:origin: alibaba/nacos

@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();
  }
}

代码示例来源:origin: alibaba/nacos

@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();
    }
  }
}

代码示例来源:origin: alibaba/nacos

/**
 * 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");
  }
}

代码示例来源:origin: alibaba/nacos

/**
 * 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");
  }
}

代码示例来源:origin: reactor/reactor-core

@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();
}

代码示例来源:origin: alibaba/nacos

/**
 * For DataAccessException
 *
 * @throws DataAccessException
 */
@ExceptionHandler(DataAccessException.class)
public void handleDataAccessException(HttpServletResponse response, DataAccessException ex) throws DataAccessException {
  MetricsMonitor.getDbException().increment();
  throw new CannotGetJdbcConnectionException(ex.getMessage());
}

代码示例来源:origin: reactor/reactor-core

@Override
public void onComplete() {
  if (done) {
    this.malformedSourceCounter.increment();
    return;
  }
  done = true;
  this.subscribeToTerminateSample.stop(subscribeToCompleteTimer);
  actual.onComplete();
}

代码示例来源:origin: micrometer-metrics/micrometer

@Benchmark
public int countSum() {
  counter.increment();
  return sum();
}

代码示例来源:origin: micrometer-metrics/micrometer

@Benchmark
public void micrometerCounterTags(MicrometerState state) {
  state.registry.counter("dynamicTags", "key1", "value1", "key2", "value2").increment();
}

代码示例来源:origin: alibaba/nacos

@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;
}

代码示例来源:origin: reactor/reactor-core

@Override
public void onNext(T t) {
  if (done) {
    this.malformedSourceCounter.increment();
    Operators.onNextDropped(t, actual.currentContext());
    return;
  }
  actual.onNext(t);
}

代码示例来源:origin: reactor/reactor-core

@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);
}

代码示例来源:origin: reactor/reactor-core

@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);
  }
}

代码示例来源:origin: micrometer-metrics/micrometer

@Benchmark
public int countSumWithRegistryLookup() {
  registry.counter("counter").increment();
  return sum();
}

代码示例来源:origin: alibaba/nacos

@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();
}

代码示例来源:origin: reactor/reactor-core

@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);
  }
}

代码示例来源:origin: reactor/reactor-core

@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);
}

相关文章