public void HistogramUpdate(string key, long value, string unit = "毫秒") { try { Histogram histogram = JMetric.Histogram(key, Unit.Custom(unit), SamplingType.FavourRecent, deafult_tags); histogram.Update(value); } catch { } }
/// <summary> /// /// </summary> /// <param name="moduleName"></param> /// <param name="unitName"></param> /// <returns></returns> private static Histogram GetHistogram(this string moduleName, string unitName) { try { return(JMetric.Histogram(moduleName, Unit.Custom(unitName))); } catch (Exception) { return(null); } }
public static void HistogramUpdate(string name, long num, Unit unit) { if (!dictionaryHistogram.ContainsKey(name)) { lock (lockHistogram) { if (!dictionaryHistogram.ContainsKey(name)) { dictionaryHistogram.Add(name, JMetric.Histogram(name, unit)); } } } dictionaryHistogram[name].Update(num); }
/// <summary> /// 统计单位时间内某一组数据的各项指标,包括:MAX、MIN、AVG、MEAN、SUM、COUNT /// </summary> /// <param name="name">Metrics Key</param> /// <param name="value">数值</param> /// <param name="unit">单位</param> public static void HistogramUpdate(string name, int value, Unit unit) { if (!histogramDictionary.ContainsKey(name)) { lock (lockHistogram) { if (!histogramDictionary.ContainsKey(name)) { histogramDictionary.Add(name, JMetric.Histogram(name, unit)); } } } histogramDictionary[name].Update(value); }
public static void HistogramUpdate(this string key, string userValue, long value, string[] tagArr, string unit = "毫秒") { try { MetricTags tags = DEFAULT_TAGS; if (tagArr != null && tagArr.Length > 0) { List <string> tagList = new List <string>(tags.Tags.Length + DEFAULT_TAGS.Tags.Length); tagList.AddRange(DEFAULT_TAGS.Tags); tagList.AddRange(tagArr); tags = new MetricTags(tagList); } Histogram histogram = JMetric.Histogram(key, Unit.Custom(unit), SamplingType.FavourRecent, tags); if (string.IsNullOrWhiteSpace(userValue)) { histogram.Update(value); } else { histogram.Update(value, userValue); } } catch { } }