Report a timer using fields max/mean/min/stddev,p50/p75/p95/p98/p99/p999/calls/m1_rate/m5_rate/m15_rate/mean_rate

@param name
@param timer
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);

    }
658794
public void setFieldName(final String name)
    {
        if (!isInStruct())
        {
            throw new IllegalStateException("IonWriter.setFieldName() must be called before writing a value into a struct.");
        }
        if (name == null)
        {
            throw new NullPointerException("Null field name is not allowed.");
        }
        final SymbolToken token = intern(name);
        user.setFieldNameSymbol(token);
    }
243786
@Override
  public void onTimer(String timerName) {
    if (timerName.equals(IDLE_SESSION_TIMER_NAME)) {
      checkIdleAppSession();
    }
    else if (timerName.equals(TIMER_NAME_INTERIM)) {
      if (context != null) {
        try {
          Request interimRecord = createInterimRecord();
          context.interimIntervalElapses(this, interimRecord);
          sendAndStateLock.lock();
          session.send(interimRecord, ClientRfSessionImpl.this);
          setState(PENDING_INTERIM);
          sessionData.setTsTimerId(null);
        }
        catch (Exception e) {
          logger.debug("Can not process Interim Interval AVP", e);
        }
        finally {
          sendAndStateLock.unlock();
        }
      }
    }
    else {
      logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId());
    }
  }
670384
public void setName(String name)
    {
        super.setName(name);
        m_tf.setName(name);
        if (m_button != null)
            m_button.setName(name);
        if (m_buttonTime != null)
            m_buttonTime.setName(name);
    }
752578
public void stopHkTimer(final Stat name) {
        timers.get(GuiceyTime).stop();
        if (!HKTime.equals(name)) {
            timers.get(HKTime).stop();
        }
        timers.get(name).stop();
    }
1103993
private long stop(long time, String name){
		m_total.stop(time);
		TimerGroupItem timer = m_timers.get(getName(name));
		long elapsedTime = 0;
		if (timer != null){
			elapsedTime = timer.stop(time);
		}
		checkLog(time);
		return elapsedTime;
	}
745304
public static synchronized <T> void registerGaugeIfAbsent(String name, Gauge<T> metric) {
    if (!METRIC_REGISTRY.getGauges().containsKey(name)) {
      METRIC_REGISTRY.register(name, metric);
    }
  }
1089770
public function clearTimerByName(string $name): bool
    {
        if (!isset($this->timers[$name])) {
            return true;
        }
        \Swoole\Timer::clear($this->timers[$name]['tid']);
        unset($this->timers[$name]);

        return true;
    }
1197685
public static Timer newTimer(String name, TaggingContext context) {
    return newTimer(name, TimeUnit.MILLISECONDS, context);
  }
60432
@Override
    public String name(String name, Meter.Type type, @Nullable String baseUnit) {
        String conventionName = NamingConvention.snakeCase.name(name, type, baseUnit);

        switch (type) {
            case COUNTER:
            case DISTRIBUTION_SUMMARY:
            case GAUGE:
                if (baseUnit != null && !conventionName.endsWith("_" + baseUnit))
                    conventionName += "_" + baseUnit;
                break;
        }

        switch (type) {
            case COUNTER:
                if (!conventionName.endsWith("_total"))
                    conventionName += "_total";
                break;
            case TIMER:
            case LONG_TASK_TIMER:
                if (conventionName.endsWith(timerSuffix)) {
                    conventionName += "_seconds";
                } else if (!conventionName.endsWith("_seconds"))
                    conventionName += timerSuffix + "_seconds";
                break;
        }

        String sanitized = nameChars.matcher(conventionName).replaceAll("_");
        if (!Character.isLetter(sanitized.charAt(0))) {
            sanitized = "m_" + sanitized;
        }
        return sanitized;
    }
531417
public void report() {
        if (log.isTraceEnabled()) {
            log.trace(String.format("Timers avg (ms): model=%.1f inf=%.1f val=%.1f grad=%.1f", 
                    updTimer.avgMs(), infTimer.avgMs(), valTimer.avgMs(), gradTimer.avgMs()));
        }
        double sum = initTimer.totMs() + updTimer.totMs() + infTimer.totMs() + valTimer.totMs() + gradTimer.totMs();
        double mult = 100.0 / sum;
        log.debug(String.format("Timers: init=%.1f%% model=%.1f%% inf=%.1f%% val=%.1f%% grad=%.1f%% avg(ms)=%.1f max(ms)=%.1f stddev(ms)=%.1f", 
                initTimer.totMs()*mult, updTimer.totMs()*mult, infTimer.totMs()*mult, valTimer.totMs()*mult, gradTimer.totMs()*mult,
                tot.avgMs(), tot.maxSplitMs(), tot.stdDevMs()));
    }
879127
@SuppressWarnings("unchecked")
  public static void registerTopologyTimerEvents(Map<String, Object> conf,
                                                 String name, Duration interval,
                                                 Runnable task) {
    if (interval.isZero() || interval.isNegative()) {
      throw new IllegalArgumentException("Timer duration needs to be positive");
    }
    if (!conf.containsKey(Config.TOPOLOGY_TIMER_EVENTS)) {
      conf.put(Config.TOPOLOGY_TIMER_EVENTS, new HashMap<String, Pair<Duration, Runnable>>());
    }

    Map<String, Pair<Duration, Runnable>> timers
        = (Map<String, Pair<Duration, Runnable>>) conf.get(Config.TOPOLOGY_TIMER_EVENTS);

    if (timers.containsKey(name)) {
      throw new IllegalArgumentException("Timer with name " + name + " already exists");
    }
    timers.put(name, Pair.of(interval, task));
  }
904152
public static Timer.Builder prepareTimerFor(final MethodDescriptor<?, ?> method,
            final String name, final String description) {
        return Timer.builder(name)
                .description(description)
                .tag(TAG_SERVICE_NAME, extractServiceName(method))
                .tag(TAG_METHOD_NAME, extractMethodName(method));
    }
76492
public static Timer timer(String name, String... tags) {
        return globalRegistry.timer(name, tags);
    }
1149374
public void declareRequestedFieldname(String name) {
        if (name.endsWith(".*")) {
            stringSetValues.put(name, new HashMap<>());
            stringSetPrefixes.put(name.substring(0, name.length() - 1), name);
        }
    }
981964
@Deprecated
    public static Timer timerWithDefaultQuantiles(MeterRegistry registry, String name, Iterable<Tag> tags) {
        requireNonNull(registry, "registry");
        requireNonNull(name, "name");
        requireNonNull(tags, "tags");
        return Timer.builder(name)
                    .tags(tags)
                    .publishPercentiles(PERCENTILES)
                    .register(registry);
    }
1156016
public void setTime( String parameterName, Time value ) throws OdaException
	{
		// only applies to named input parameter
		parameters.put(parameterName, value);
	}