internal virtual bool AddProviderMetric <T>(MetricName name, Func <T> provider, MetricConfig config = null) { if (!NoRunnable) { if (!metrics.ContainsKey(name)) { StreamMetric metric = new StreamMetric(name, new ProviderMetricValue <T>(provider), config ?? this.config); metrics.Add(name, metric); return(true); } return(false); } return(false); }
internal virtual bool AddStatMetric(MetricName name, IMeasurableStat stat, MetricConfig config = null) { if (!NoRunnable) { if (!metrics.ContainsKey(name)) { StreamMetric metric = new StreamMetric(name, stat, config ?? this.config); metrics.Add(name, metric); stats.Add(stat); return(true); } return(false); } return(false); }
internal virtual bool AddImmutableMetric <T>(MetricName name, T value, MetricConfig config = null) { if (!NoRunnable) { if (!metrics.ContainsKey(name)) { StreamMetric metric = new StreamMetric(name, new ImmutableMetricValue <T>(value), config ?? this.config); metrics.Add(name, metric); if (value is IMeasurableStat stat) { stats.Add(stat); } return(true); } return(false); } return(false); }