private MutableMetric NewImpl(Metric.Type metricType) { Type resType = method.ReturnType; switch (metricType) { case Metric.Type.Counter: { return(NewCounter(resType)); } case Metric.Type.Gauge: { return(NewGauge(resType)); } case Metric.Type.Default: { return(resType == typeof(string) ? NewTag(resType) : NewGauge(resType)); } case Metric.Type.Tag: { return(NewTag(resType)); } default: { Contracts.CheckArg(metricType, false, "unsupported metric type"); return(null); } } }
internal MethodMetric(object obj, MethodInfo method, MetricsInfo info, Metric.Type type) { this.obj = Preconditions.CheckNotNull(obj, "object"); this.method = Contracts.CheckArg(method, Runtime.GetParameterTypes(method ).Length == 0, "Metric method should have no arguments"); this.info = Preconditions.CheckNotNull(info, "info"); impl = NewImpl(Preconditions.CheckNotNull(type, "metric type")); }