Gets a time for a performance measurement. If no measurement with the
specified name exists then it returns -1.

@param name
@return
355983
public long getTime(String name) {
        Long res = stats.get(name);
        return (res == null) ? -1 : res.longValue();
    }
479788
def get_timer(self, name=None):
        '''
        '''
        return self.get_client(name=name, class_=statsd.Timer)
683035
public void stats(String name, float value) {
		for (ICounters counter : _counters)
			counter.stats(name, value);
	}

	/**
	 * Records the last calculated measurement value.
	 * 
	 * Usually this method is used by metrics calculated externally.
	 * 
	 * @param name  a counter name of Last type.
	 * @param value a last value to record.
	 */
	public void last(String name, float value) {
		for (ICounters counter : _counters)
			counter.last(name, value);
	}

	/**
	 * Records the current time as a timestamp.
	 * 
	 * @param name a counter name of Timestamp type.
	 */
	public void timestampNow(String name) {
		timestamp(name, ZonedDateTime.now());
	}

	/**
	 * Records the given timestamp.
	 * 
	 * @param name  a counter name of Timestamp type.
	 * @param value a timestamp to record.
	 */
	public void timestamp(String name, ZonedDateTime value) {
		for (ICounters counter : _counters)
			counter.timestamp(name, value);
	}

	/**
	 * Increments counter by 1.
	 * 
	 * @param name a counter name of Increment type.
	 */
	public void incrementOne(String name) {
		increment(name, 1);
	}

	/**
	 * Increments counter by given value.
	 * 
	 * @param name  a counter name of Increment type.
	 * @param value a value to add to the counter.
	 */
	public void increment(String name, int value) {
		for (ICounters counter : _counters)
			counter.increment(name, value);
	}

}
1095311
public static void collectMetric(
    MetricsRecordBuilder metricsRecordBuilder, String name, Metric metric) {

    if (metric instanceof Timer) {
      Timer t = (Timer) metric;
      metricsRecordBuilder
        .addCounter(new ShuffleServiceMetricsInfo(name + "_count", "Count of timer " + name),
          t.getCount())
        .addGauge(
          new ShuffleServiceMetricsInfo(name + "_rate15", "15 minute rate of timer " + name),
          t.getFifteenMinuteRate())
        .addGauge(
          new ShuffleServiceMetricsInfo(name + "_rate5", "5 minute rate of timer " + name),
          t.getFiveMinuteRate())
        .addGauge(
          new ShuffleServiceMetricsInfo(name + "_rate1", "1 minute rate of timer " + name),
          t.getOneMinuteRate())
        .addGauge(new ShuffleServiceMetricsInfo(name + "_rateMean", "Mean rate of timer " + name),
          t.getMeanRate());
    } else if (metric instanceof Meter) {
      Meter m = (Meter) metric;
      metricsRecordBuilder
        .addCounter(new ShuffleServiceMetricsInfo(name + "_count", "Count of meter " + name),
          m.getCount())
        .addGauge(
          new ShuffleServiceMetricsInfo(name + "_rate15", "15 minute rate of meter " + name),
          m.getFifteenMinuteRate())
        .addGauge(
          new ShuffleServiceMetricsInfo(name + "_rate5", "5 minute rate of meter " + name),
          m.getFiveMinuteRate())
        .addGauge(
          new ShuffleServiceMetricsInfo(name + "_rate1", "1 minute rate of meter " + name),
          m.getOneMinuteRate())
        .addGauge(new ShuffleServiceMetricsInfo(name + "_rateMean", "Mean rate of meter " + name),
          m.getMeanRate());
    } else if (metric instanceof Gauge) {
      final Object gaugeValue = ((Gauge) metric).getValue();
      if (gaugeValue instanceof Integer) {
        metricsRecordBuilder.addGauge(getShuffleServiceMetricsInfo(name), (Integer) gaugeValue);
      } else if (gaugeValue instanceof Long) {
        metricsRecordBuilder.addGauge(getShuffleServiceMetricsInfo(name), (Long) gaugeValue);
      } else if (gaugeValue instanceof Float) {
        metricsRecordBuilder.addGauge(getShuffleServiceMetricsInfo(name), (Float) gaugeValue);
      } else if (gaugeValue instanceof Double) {
        metricsRecordBuilder.addGauge(getShuffleServiceMetricsInfo(name), (Double) gaugeValue);
      } else {
        throw new IllegalStateException(
                "Not supported class type of metric[" + name + "] for value " + gaugeValue);
      }
    } else if (metric instanceof Counter) {
      Counter c = (Counter) metric;
      long counterValue = c.getCount();
      metricsRecordBuilder.addGauge(new ShuffleServiceMetricsInfo(name, "Number of " +
          "connections to shuffle service " + name), counterValue);
    }
  }
935641
public static Aggregator get(final String name) {
    final Aggregator agg = aggregators.get(name);
    if (agg != null) {
      return agg;
    }
    throw new NoSuchElementException("No such aggregator: " + name);
  }
1034277
public static SerializationFormat getOutputFormat(String name) {
        for (SerializationFormat ft : Instance.serializationFormats) {
            if (ft.isAcceptedAsOutput(name)) {
                return ft;
            }
        }
        return null;
    }
827323
public int getIntHeader(String name)
    {
        HeaderField f = getHeaderField(name);
        if (f != null)
        {
            return f.getIntValue();
        }
        else
        {
            return -1;
        }
    }
235216
public long getDurationInHours(String name, long defaultValue) {
        TimeUnit timeUnit = extractTimeUnit(name, defaultValue + " HOURS");
        long duration = getLong(name, defaultValue);

        return timeUnit.toHours(duration);
    }
1329456
@SuppressWarnings("unchecked")
    @Override
    public <T> T get(String name) {
        return (T) super.get(name);
    }
121019
public long pauseTimer(String name) {
        StopWatch sw = getStopWatch(name);
        sw.suspend();
        return sw.getTime();
    }
220592
public long getLong(String name)
    {
        long val = 0;
        try {
            val = Long.valueOf(request.getParameter(name));
        } catch (NumberFormatException e) {}
        
        return val;
    }
462209
public static AsmMetric find(String name) {
        for (AsmMetricRegistry registry : allRegistries) {
            AsmMetric metric = registry.getMetric(name);
            if (metric != null) {
                return metric;
            }
        }
        return null;
    }
160640
private void reportTimer(String name, Timer timer) {
        final Snapshot snapshot = timer.getSnapshot();
        String prefixedName = prefix(name);
        if (!snapshots.hasDescriptor(prefixedName)) {

            MetricItem.Builder builder = MetricItem.Builder.create();
            builder.duration("max", durationUnit);
            builder.duration("mean", durationUnit);
            builder.duration("min", durationUnit);
            builder.duration("stddev", durationUnit);

            builder.duration("p50", durationUnit);
            builder.duration("p75", durationUnit);
            builder.duration("p95", durationUnit);
            builder.duration("p98", durationUnit);
            builder.duration("p99", durationUnit);
            builder.duration("p95", durationUnit);
            builder.duration("p999", durationUnit);

            builder.calls("calls");

            builder.calls("m1_rate", 1, rateUnit);
            builder.calls("m5_rate", 1, rateUnit);
            builder.calls("m15_rate", 1, rateUnit);
            builder.calls("mean_rate", rateUnit);

            snapshots.setDescriptor(prefixedName, builder.build());

        }

        Map<String, Number> values = new HashMap<>();

        values.put("max", convertDuration(snapshot.getMax()));
        values.put("mean", convertDuration(snapshot.getMean()));
        values.put("min", convertDuration(snapshot.getMin()));
        values.put("stddev", convertDuration(snapshot.getStdDev()));

        values.put("p50", convertDuration(snapshot.getMedian()));
        values.put("p75", convertDuration(snapshot.get75thPercentile()));
        values.put("p95", convertDuration(snapshot.get95thPercentile()));
        values.put("p98", convertDuration(snapshot.get98thPercentile()));
        values.put("p99", convertDuration(snapshot.get99thPercentile()));
        values.put("p999", convertDuration(snapshot.get999thPercentile()));

        addMetered(timer, values, "calls");

        snapshots.addSnapshot(prefixedName, getTimestamp(), values);

    }
209056
public static TimeZone getTimeZone(String name)
    {
        TimeZone ret = null;
        if(timezones != null)
        {
            for(int i = 0; i < timezones.length && ret == null; i++)
            {
                if(timezones[i].getName().equals(name))
                    ret = timezones[i].getTimeZone();
            }
        }
        return ret;
    }
1127090
private Long calculateRequestLatency(TimingInfo timingInfo) {
        if (timingInfo == null) {
            return null;
        }

        TimingInfo httpClientSendRequestTime = timingInfo.getLastSubMeasurement(AWSRequestMetrics.Field.HttpClientSendRequestTime
                                                                                    .name());
        TimingInfo httpClientReceiveResponseTime = timingInfo.getLastSubMeasurement(AWSRequestMetrics.Field
                                                                                        .HttpClientReceiveResponseTime.name());
        if (httpClientSendRequestTime != null && httpClientSendRequestTime.getTimeTakenMillisIfKnown() != null &&
            httpClientReceiveResponseTime != null && httpClientReceiveResponseTime.getTimeTakenMillisIfKnown() != null) {
            return httpClientSendRequestTime.getTimeTakenMillisIfKnown().longValue()
                   + httpClientReceiveResponseTime.getTimeTakenMillisIfKnown().longValue();
        }
        return null;
    }
403045
private static String getWorkerMetricName(String name) {
    String result = CACHED_METRICS.get(name);
    if (result != null) {
      return result;
    }
    return CACHED_METRICS.computeIfAbsent(name,
        n -> getMetricNameWithUniqueId(InstanceType.WORKER, name));
  }
37513
public final synchronized L[] get(String name) {
        return (this.map != null)
                ? this.map.get(name)
                : null;
    }