public void updateRpc(MethodDescriptor method, TableName tableName, Message param,
    CallStats stats, Throwable e) {
    int callsPerServer = stats.getConcurrentCallsPerServer();
    if (callsPerServer > 0) {
      concurrentCallsPerServerHist.update(callsPerServer);
    }
    // Update the counter that tracks RPCs by type.
    StringBuilder methodName = new StringBuilder();
    methodName.append(method.getService().getName()).append("_").append(method.getName());
    // Distinguish mutate types.
    if ("Mutate".equals(method.getName())) {
      final MutationType type = ((MutateRequest) param).getMutation().getMutateType();
      switch (type) {
        case APPEND:
          methodName.append("(Append)");
          break;
        case DELETE:
          methodName.append("(Delete)");
          break;
        case INCREMENT:
          methodName.append("(Increment)");
          break;
        case PUT:
          methodName.append("(Put)");
          break;
        default:
          methodName.append("(Unknown)");
      }
    }
    getMetric(CNT_BASE + methodName, rpcCounters, counterFactory).inc();
    if (e != null) {
      getMetric(FAILURE_CNT_BASE + methodName, rpcCounters, counterFactory).inc();
      getMetric(TOTAL_EXCEPTION_CNT, rpcCounters, counterFactory).inc();
      if (e instanceof RemoteException) {
        String fullClassName = ((RemoteException) e).getClassName();
        String simpleClassName = (fullClassName != null)
          ? fullClassName.substring(fullClassName.lastIndexOf(".") + 1)
          : "unknown";
        getMetric(REMOTE_EXCEPTION_CNT_BASE + simpleClassName, rpcCounters, counterFactory).inc();
      } else {
        getMetric(LOCAL_EXCEPTION_CNT_BASE + e.getClass().getSimpleName(), rpcCounters,
          counterFactory).inc();
      }
    }
    // this implementation is tied directly to protobuf implementation details. would be better
    // if we could dispatch based on something static, ie, request Message type.
    if (method.getService() == ClientService.getDescriptor()) {
      switch (method.getIndex()) {
        case 0:
          assert "Get".equals(method.getName());
          getTracker.updateRpc(stats);
          updateTableMetric(methodName.toString(), tableName, stats, e);
          return;
        case 1:
          assert "Mutate".equals(method.getName());
          final MutationType mutationType = ((MutateRequest) param).getMutation().getMutateType();
          switch (mutationType) {
            case APPEND:
              appendTracker.updateRpc(stats);
              break;
            case DELETE:
              deleteTracker.updateRpc(stats);
              break;
            case INCREMENT:
              incrementTracker.updateRpc(stats);
              break;
            case PUT:
              putTracker.updateRpc(stats);
              break;
            default:
              throw new RuntimeException("Unrecognized mutation type " + mutationType);
          }
          updateTableMetric(methodName.toString(), tableName, stats, e);
          return;
        case 2:
          assert "Scan".equals(method.getName());
          scanTracker.updateRpc(stats);
          updateTableMetric(methodName.toString(), tableName, stats, e);
          return;
        case 3:
          assert "BulkLoadHFile".equals(method.getName());
          // use generic implementation
          break;
        case 4:
          assert "PrepareBulkLoad".equals(method.getName());
          // use generic implementation
          break;
        case 5:
          assert "CleanupBulkLoad".equals(method.getName());
          // use generic implementation
          break;
        case 6:
          assert "ExecService".equals(method.getName());
          // use generic implementation
          break;
        case 7:
          assert "ExecRegionServerService".equals(method.getName());
          // use generic implementation
          break;
        case 8:
          assert "Multi".equals(method.getName());
          numActionsPerServerHist.update(stats.getNumActionsPerServer());
          multiTracker.updateRpc(stats);
          updateTableMetric(methodName.toString(), tableName, stats, e);
          return;
        default:
          throw new RuntimeException("Unrecognized ClientService RPC type " + method.getFullName());
      }
    }
    // Fallback to dynamic registry lookup for DDL methods.
    updateRpcGeneric(methodName.toString(), stats);
  }
Report RPC context to metrics system.
hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetricsConnection.java