@SuppressWarnings("deprecation")
  private void writeMemberMetricValues(MemberMXBean memberMxBean, JVMMetrics jvmMetrics,
      TabularResultModel metricsTable, StringBuilder csvBuilder,
      Set<Category> categoriesToDisplay) {
    if (categoriesToDisplay.contains(Category.member)) {
      writeToTableAndCsv(metricsTable, "member", "upTime", memberMxBean.getMemberUpTime(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "cpuUsage", memberMxBean.getCpuUsage(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "currentHeapSize", memberMxBean.getCurrentHeapSize(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "maximumHeapSize", memberMxBean.getMaximumHeapSize(),
          csvBuilder);
    }
    if (categoriesToDisplay.contains(Category.jvm)) {
      writeToTableAndCsv(metricsTable, "jvm", "jvmThreads ", jvmMetrics.getTotalThreads(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "fileDescriptorLimit",
          memberMxBean.getFileDescriptorLimit(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "totalFileDescriptorOpen",
          memberMxBean.getTotalFileDescriptorOpen(), csvBuilder);
    }
    if (categoriesToDisplay.contains(Category.region)) {
      writeToTableAndCsv(metricsTable, "region", "totalRegionCount ",
          memberMxBean.getTotalRegionCount(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "listOfRegions",
          Arrays.stream(memberMxBean.listRegions()).map(s -> s.substring(1)).toArray(String[]::new),
          csvBuilder);

      writeToTableAndCsv(metricsTable, "", "rootRegions", memberMxBean.getRootRegionNames(),
          csvBuilder);

      writeToTableAndCsv(metricsTable, "", "totalRegionEntryCount",
          memberMxBean.getTotalRegionEntryCount(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "totalBucketCount", memberMxBean.getTotalBucketCount(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "totalPrimaryBucketCount",
          memberMxBean.getTotalPrimaryBucketCount(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "getsAvgLatency", memberMxBean.getGetsAvgLatency(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "putsAvgLatency", memberMxBean.getPutsAvgLatency(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "createsRate", memberMxBean.getCreatesRate(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "destroyRate", memberMxBean.getDestroysRate(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "putAllAvgLatency", memberMxBean.getPutAllAvgLatency(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "totalMissCount", memberMxBean.getTotalMissCount(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "totalHitCount", memberMxBean.getTotalHitCount(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "getsRate", memberMxBean.getGetsRate(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "putsRate", memberMxBean.getPutsRate(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "cacheWriterCallsAvgLatency",
          memberMxBean.getCacheWriterCallsAvgLatency(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "cacheListenerCallsAvgLatency",
          memberMxBean.getCacheListenerCallsAvgLatency(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "totalLoadsCompleted",
          memberMxBean.getTotalLoadsCompleted(), csvBuilder);
    }
    if (categoriesToDisplay.contains(Category.serialization)) {
      writeToTableAndCsv(metricsTable, "serialization", "serializationRate",
          memberMxBean.getSerializationRate(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "serializationLatency",
          memberMxBean.getSerializationRate(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "deserializationRate",
          memberMxBean.getDeserializationRate(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "deserializationLatency",
          memberMxBean.getDeserializationLatency(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "deserializationAvgLatency",
          memberMxBean.getDeserializationAvgLatency(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "PDXDeserializationAvgLatency",
          memberMxBean.getPDXDeserializationAvgLatency(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "PDXDeserializationRate",
          memberMxBean.getPDXDeserializationRate(), csvBuilder);
    }
    if (categoriesToDisplay.contains(Category.communication)) {
      writeToTableAndCsv(metricsTable, "communication", "bytesSentRate",
          memberMxBean.getBytesSentRate(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "bytesReceivedRate", memberMxBean.getBytesReceivedRate(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "connectedGatewayReceivers",
          memberMxBean.listConnectedGatewayReceivers(), csvBuilder);

      writeToTableAndCsv(metricsTable, "", "connectedGatewaySenders",
          memberMxBean.listConnectedGatewaySenders(), csvBuilder);
    }
    if (categoriesToDisplay.contains(Category.function)) {
      writeToTableAndCsv(metricsTable, "function", "numRunningFunctions",
          memberMxBean.getNumRunningFunctions(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "functionExecutionRate",
          memberMxBean.getFunctionExecutionRate(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "numRunningFunctionsHavingResults",
          memberMxBean.getNumRunningFunctionsHavingResults(), csvBuilder);
    }
    if (categoriesToDisplay.contains(Category.transaction)) {
      writeToTableAndCsv(metricsTable, "transaction", "totalTransactionsCount",
          memberMxBean.getTotalTransactionsCount(), csvBuilder);

      writeToTableAndCsv(metricsTable, "", "transactionCommitsAvgLatency",
          memberMxBean.getTransactionCommitsAvgLatency(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "transactionCommittedTotalCount",
          memberMxBean.getTransactionCommittedTotalCount(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "transactionRolledBackTotalCount",
          memberMxBean.getTransactionRolledBackTotalCount(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "transactionCommitsRate",
          memberMxBean.getTransactionCommitsRate(), csvBuilder);
    }
    if (categoriesToDisplay.contains(Category.diskstore)) {
      writeToTableAndCsv(metricsTable, "diskstore", "totalDiskUsage",
          memberMxBean.getTotalDiskUsage(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "diskReadsRate", memberMxBean.getDiskReadsRate(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "diskWritesRate", memberMxBean.getDiskWritesRate(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "flushTimeAvgLatency",
          memberMxBean.getDiskFlushAvgLatency(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "totalQueueSize",
          memberMxBean.getTotalDiskTasksWaiting(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "totalBackupInProgress",
          memberMxBean.getTotalBackupInProgress(), csvBuilder);
    }
    if (categoriesToDisplay.contains(Category.lock)) {
      writeToTableAndCsv(metricsTable, "lock", "lockWaitsInProgress",
          memberMxBean.getLockWaitsInProgress(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "totalLockWaitTime", memberMxBean.getTotalLockWaitTime(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "totalNumberOfLockService",
          memberMxBean.getTotalNumberOfLockService(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "requestQueues", memberMxBean.getLockRequestQueues(),
          csvBuilder);
    }
    if (categoriesToDisplay.contains(Category.eviction)) {
      writeToTableAndCsv(metricsTable, "eviction", "lruEvictionRate",
          memberMxBean.getLruEvictionRate(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "lruDestroyRate", memberMxBean.getLruDestroyRate(),
          csvBuilder);
    }
    if (categoriesToDisplay.contains(Category.distribution)) {
      writeToTableAndCsv(metricsTable, "distribution", "getInitialImagesInProgress",
          memberMxBean.getInitialImagesInProgress(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "getInitialImageTime",
          memberMxBean.getInitialImageTime(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "getInitialImageKeysReceived",
          memberMxBean.getInitialImageKeysReceived(), csvBuilder);
    }
    if (categoriesToDisplay.contains(Category.offheap)) {
      writeToTableAndCsv(metricsTable, "offheap", "maxMemory", memberMxBean.getOffHeapMaxMemory(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "freeMemory", memberMxBean.getOffHeapFreeMemory(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "usedMemory", memberMxBean.getOffHeapUsedMemory(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "objects", memberMxBean.getOffHeapObjects(), csvBuilder);
      writeToTableAndCsv(metricsTable, "", "fragmentation", memberMxBean.getOffHeapFragmentation(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "largestFragment",
          memberMxBean.getOffHeapLargestFragment(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "fragments", memberMxBean.getOffHeapFragments(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "freedChunks", memberMxBean.getOffHeapFreedChunks(),
          csvBuilder);
      writeToTableAndCsv(metricsTable, "", "compactionTime",
          memberMxBean.getOffHeapCompactionTime(), csvBuilder);
    }
  }
Gets the metrics of region on a given member

@return ResultData with required Region statistics or ErrorResultData if Region MBean is not
        found to gather metrics
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/ShowMetricsCommand.java