See <a href="https://github.com/etsy/statsd/blob/master/docs/metric_types.md">StatsD Metric Types</a>.

@param result
@return StatsD metric type such as 'c', 'g' or 's'. Default to 'c' if not known, return the metric type itself if its length == 1
506674
protected char getStatsdMetricType(@Nonnull QueryResult result) {
        String metricType = result.getType();
        char statsBucketType;
        if(metricType == null || metricType.equalsIgnoreCase("counter")) {
            statsBucketType = 'c';
        } else if(metricType.equalsIgnoreCase("gauge")) {
            statsBucketType = 'g';
        } else if (metricType.equalsIgnoreCase("set")) {
            statsBucketType = 's';
        } else if(metricType.length() == 1) {
            statsBucketType = metricType.charAt(0);
        } else {
            logger.warn("Unknown metric type for {}, default to 'c'", result);
            statsBucketType = 'c';
        }
        return statsBucketType;
    }
1027653
protected void addHeapMetrics(Collection<Metric<?>> result) {
        MemoryUsage memoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
        result.add(newMemoryMetric("heap.committed", memoryUsage.getCommitted()));
        result.add(newMemoryMetric("heap.init", memoryUsage.getInit()));
        result.add(newMemoryMetric("heap.used", memoryUsage.getUsed()));
        result.add(newMemoryMetric("heap", memoryUsage.getMax()));
    }
891092
public static ResultDescriptor ofResult(final Class<? extends AnalyzerResult> resultClass) {
        ResultDescriptor resultDescriptor = _resultDescriptors.get(resultClass);
        if (resultDescriptor == null) {
            resultDescriptor = new ResultDescriptorImpl(resultClass);
            _resultDescriptors.put(resultClass, resultDescriptor);
        }
        return resultDescriptor;
    }
756514
private function formatUrlStat($result = null)
    {
        $stat = $this->getStatTemplate();
        switch (gettype($result)) {
            case 'NULL':
            case 'string':
                // Directory with 0777 access - see "man 2 stat".
                $stat['mode'] = $stat[2] = 0040777;
                break;
            case 'array':
                // Regular file with 0777 access - see "man 2 stat".
                $stat['mode'] = $stat[2] = 0100777;
                // Pluck the content-length if available.
                if (isset($result['ContentLength'])) {
                    $stat['size'] = $stat[7] = $result['ContentLength'];
                } elseif (isset($result['Size'])) {
                    $stat['size'] = $stat[7] = $result['Size'];
                }
                if (isset($result['LastModified'])) {
                    // ListObjects or HeadObject result
                    $stat['mtime'] = $stat[9] = $stat['ctime'] = $stat[10]
                        = strtotime($result['LastModified']);
                }
        }

        return $stat;
    }
79629
public java.lang.String getResult() {
    java.lang.Object ref = result_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = 
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      if (bs.isValidUtf8()) {
        result_ = s;
      }
      return s;
    }
  }
715546
private Object deserializeOCCColumn(Result result) {
    byte[] versionBytes = result.getValue(Constants.SYS_COL_FAMILY,
        Constants.VERSION_CHECK_COL_QUALIFIER);
    if (versionBytes == null) {
      return null;
    } else {
      return Bytes.toLong(versionBytes);
    }
  }
92827
public GetInstanceMetricDataRequest withStatistics(MetricStatistic... statistics) {
        java.util.ArrayList<String> statisticsCopy = new java.util.ArrayList<String>(statistics.length);
        for (MetricStatistic value : statistics) {
            statisticsCopy.add(value.toString());
        }
        if (getStatistics() == null) {
            setStatistics(statisticsCopy);
        } else {
            getStatistics().addAll(statisticsCopy);
        }
        return this;
    }
845510
public static Object getFloatValue(Result result, int index,
			GeoPackageDataType dataType) {

		Object value = null;

		if (dataType == null) {
			dataType = GeoPackageDataType.DOUBLE;
		}

		switch (dataType) {

		case FLOAT:
			value = result.getFloat(index);
			break;
		case DOUBLE:
		case REAL:
		case INTEGER:
		case INT:
			value = result.getDouble(index);
			break;
		default:
			throw new GeoPackageException("Data Type " + dataType
					+ " is not a float type");
		}

		if (result.wasNull()) {
			value = null;
		}

		return value;
	}
918807
@SuppressWarnings("fallthrough")
  private void getAggregatedMetrics(List<MetricTimeRangeValue> metricValue,
                                    long startTime, long endTime, long bucketId,
                                    MetricsFilter.MetricAggregationType type,
                                    MetricGranularity granularity) {
    LOG.fine("getAggregatedMetrics " + startTime + " " + endTime);
    // per request
    long outterCountAvg = 0;

    // prepare range value
    long outterStartTime = Long.MAX_VALUE;
    long outterEndTime = 0;
    String outterValue = null;

    double outterResult = 0;
    Long startKey = cacheMetric.floorKey(startTime);
    for (Long key = startKey != null ? startKey : cacheMetric.firstKey();
         key != null && key <= endTime;
         key = cacheMetric.higherKey(key)) {
      LinkedList<MetricDatapoint> bucket = cacheMetric.get(key).get(bucketId);

      if (bucket != null) {
        // per bucket
        long innerCountAvg = 0;

        // prepare range value
        long innerStartTime = Long.MAX_VALUE;
        long innerEndTime = 0;
        String innerValue = null;

        double innerResult = 0;
        for (MetricDatapoint datapoint : bucket) {
          if (datapoint.inRange(startTime, endTime)) {
            switch (type) {
              case AVG:
                outterCountAvg++;
                innerCountAvg++;
              case SUM:
                outterResult += Double.parseDouble(datapoint.getValue());
                innerResult += Double.parseDouble(datapoint.getValue());
                break;
              case LAST:
                if (outterEndTime < datapoint.getTimestamp()) {
                  outterValue = datapoint.getValue();
                }
                if (innerEndTime < datapoint.getTimestamp()) {
                  innerValue = datapoint.getValue();
                }
                break;
              case UNKNOWN:
              default:
                LOG.warning(
                    "Unknown metric type, CacheCore does not know how to aggregate " + type);
                return;
            }
            outterStartTime = Math.min(outterStartTime, datapoint.getTimestamp());
            outterEndTime = Math.max(outterEndTime, datapoint.getTimestamp());
            innerStartTime = Math.min(innerStartTime, datapoint.getTimestamp());
            innerEndTime = Math.max(innerEndTime, datapoint.getTimestamp());
          }
        } // end bucket

        if (type.equals(MetricsFilter.MetricAggregationType.AVG) && innerCountAvg > 0) {
          innerValue = String.valueOf(innerResult / innerCountAvg);
        } else if (type.equals(MetricsFilter.MetricAggregationType.SUM)) {
          innerValue = String.valueOf(innerResult);
        }
        if (innerValue != null && granularity.equals(MetricGranularity.AGGREGATE_BY_BUCKET)) {
          metricValue.add(new MetricTimeRangeValue(innerStartTime, innerEndTime, innerValue));
        }
      }

    } // end tree

    if (type.equals(MetricsFilter.MetricAggregationType.AVG) && outterCountAvg > 0) {
      outterValue = String.valueOf(outterResult / outterCountAvg);
    } else if (type.equals(MetricsFilter.MetricAggregationType.SUM)) {
      outterValue = String.valueOf(outterResult);
    }
    if (outterValue != null && granularity.equals(MetricGranularity.AGGREGATE_ALL_METRICS)) {
      metricValue.add(new MetricTimeRangeValue(outterStartTime, outterEndTime, outterValue));
    }
  }
1128259
public static String getKeyString(Query query, Result result, List<String> typeNames) {
		StringBuilder sb = new StringBuilder();
		addMBeanIdentifier(query, result, sb);
		addSeparator(sb);
		addTypeName(query, result, typeNames, sb);
		addKeyString(query, result, sb);
		return sb.toString();
	}
569702
public com.google.privacy.dlp.v2.AnalyzeDataSourceRiskDetails.NumericalStatsResultOrBuilder
      getNumericalStatsResultOrBuilder() {
    if (resultCase_ == 3) {
      return (com.google.privacy.dlp.v2.AnalyzeDataSourceRiskDetails.NumericalStatsResult) result_;
    }
    return com.google.privacy.dlp.v2.AnalyzeDataSourceRiskDetails.NumericalStatsResult
        .getDefaultInstance();
  }
190468
public com.google.protobuf.ByteString
      getMetricBytes() {
    java.lang.Object ref = metric_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      metric_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }
1317138
public <G extends Serializable> Metric<G> getMetric(CxxMetricsFactory.Key metricKey) {
    Metric<G> metric = (Metric<G>) this.langSpecificMetrics.get(metricKey);
    if (metric == null) {
      throw new IllegalStateException("Requested metric " + metricKey + " couldn't be found");
    }
    return metric;
  }
756676
public MetricRegistry registerMetrics(final MetricRegistry registry) {
      registry.register(MetricRegistry.name(ConnectionPool.class, name), metrics);
      return registry;
   }
1373918
public String getType() {
		if (this.type == null)
			this.type = this.resultHandler.getRelationType(getId(), this.rowIndex);
		return this.type;
	}
291509
public static String toPrettyPrintedString(final TabularResult result) {
    ArgumentChecker.notNull(result, "result");
    StringBuilder sb = new StringBuilder();
    int[] maxWidths = maximumWidths(result);
    separator(sb, maxWidths);
    header(sb, maxWidths, result.getHeaderDefinition());
    separator(sb, maxWidths);
    for (final Row row : result) {
      row(sb, maxWidths, row);
    }
    separator(sb, maxWidths);
    return sb.toString();
  }
924622
private long getDuration(Set<ITestResult> results)
    {
        long duration = 0;
        for (ITestResult result : results)
        {
            duration += (result.getEndMillis() - result.getStartMillis());
        }
        return duration;
    }