public void can_determine_if_are_same() { var first = new CounterValue(10L); var second = new CounterValue(10L); first.Should().Be(second); }
public void Can_determine_if_diff_using_operator() { var first = new CounterValue(10L); var second = new CounterValue(1L); Assert.True(first != second); }
public void can_determine_if_diff() { var first = new CounterValue(10L); var second = new CounterValue(1L); first.Should().NotBe(second); }
public void can_determine_if_same_using_operator() { var first = new CounterValue(10L); var second = new CounterValue(10L); Assert.True(first == second); }
public void hash_codes_same_for_same_instance() { var first = new CounterValue(1); var second = first; Assert.Equal(first.GetHashCode(), second.GetHashCode()); }
public void hash_codes_differ_between_instances() { var first = new CounterValue(10L).GetHashCode(); var second = new CounterValue(1L).GetHashCode(); Assert.NotEqual(first, second); }
void UpdateListValues() { TreeIter it; if (seriesStore.GetIterFirst(out it)) { do { ChartSerieInfo ci = (ChartSerieInfo)seriesStore.GetValue(it, 3); if (ci.Counter == null) { continue; } CounterValue val = ci.Counter.LastValue; seriesStore.SetValue(it, 4, val.Value.ToString()); if (countChart.ActiveCursor != null) { val = ci.Counter.GetValueAt(new DateTime((long)countChart.ActiveCursor.Value)); seriesStore.SetValue(it, 5, val.Value.ToString()); } val = ci.Counter.GetValueAt(new DateTime((long)countChart.SelectionStart.Value)); CounterValue val2 = ci.Counter.GetValueAt(new DateTime((long)countChart.SelectionEnd.Value)); seriesStore.SetValue(it, 6, (val2.Value - val.Value).ToString()); }while (seriesStore.IterNext(ref it)); } }
void FillValuesList() { listViewStore.Clear(); List <ListViewValueInfo> values = new List <ListViewValueInfo> (); foreach (var serie in view.Series.Where(s => s.Visible)) { foreach (CounterValue val in serie.Counter.GetValues()) { values.Add(new ListViewValueInfo() { Serie = serie, Value = val }); } } values.Sort(delegate(ListViewValueInfo v1, ListViewValueInfo v2) { return(v1.Value.TimeStamp.CompareTo(v2.Value.TimeStamp)); }); foreach (ListViewValueInfo vinfo in values) { CounterValue val = vinfo.Value; string time = val.TimeStamp.ToLongTimeString(); listViewStore.AppendValues(vinfo, vinfo.Serie.ColorIcon, vinfo.Serie.Counter.Name, time, val.Value.ToString(), val.TotalCount.ToString(), val.HasTimerTraces ? val.Duration.TotalMilliseconds.ToString() : ""); } }
public void reference_equality_should_be_correct() { var first = new CounterValue(10L); var second = new CounterValue(1L); Assert.False(first.Equals((object)second)); }
public static CounterValueSource ToMetricValueSource(this Counter source) { var items = source.Items.Select(i => new CounterValue.SetItem(i.Item, i.Count, i.Percent)).ToArray(); var counterValue = new CounterValue(source.Count, items); return(new CounterValueSource(source.Name, ConstantValue.Provider(counterValue), source.Unit, source.Tags)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CounterValue = StartValue; lblCounter.Text = CounterValue.ToString(); } }
public void SetMainCounter(Counter c, CounterValue value) { mainCounter = c; mainValue = value; data = null; Scale = scale; QueueDraw(); }
public void ReportValue(CounterValue v) { using (var db = new Data()) { db.CounterValues.Add(v); db.SaveChanges(); } }
public CounterValueSource ToValueSource() { var items = this.items.Select(i => new CounterValue.SetItem(i.Item, i.Count, i.Percent)) .ToArray(); var counterValue = new CounterValue(this.Count, items); return new CounterValueSource(this.Name, ConstantValue.Provider(counterValue), this.Unit, this.Tags); }
public CounterValueSource ToValueSource() { var items = this.items.Select(i => new CounterValue.SetItem(i.Item, i.Count, i.Percent)) .ToArray(); var counterValue = new CounterValue(this.Count, items); return(new CounterValueSource(this.Name, ConstantValue.Provider(counterValue), this.Unit, this.Tags)); }
public TimeLineViewWindow(Counter c, CounterValue value) : base(Gtk.WindowType.Toplevel) { this.Build(); this.mainCounter = c; this.mainValue = value; timeView.Scale = 300; Update(); }
public void counter_value_with_null_set_items_throws() { Action setupAction = () => { var unused = new CounterValue(10L, null); }; setupAction.ShouldThrow <ArgumentNullException>(); }
public void OnNext(CounterValue value) { using (var session = _documentStore.OpenSession()) { session.Store(value); session.SaveChanges(); } }
public virtual CounterValue GetValue(int uid) { CounterValue result = null; if (!this._lookingTable.TryGetValue(uid, out result)) { result = null; } return(result); }
public void OnNext(CounterValue value) { WriteFields(value.Time, (value.Time - _initialDate).TotalMilliseconds, value.Counter.Host, value.Counter.Type, value.Counter.Category, value.Counter.Instance, value.Counter.Name, value.Value); }
public virtual void AddValue(int uid, CounterValue t) { if (this._lookingTable.ContainsKey(uid)) { this._lookingTable[uid] = t; } else { this._lookingTable.Add(uid, t); } }
protected override void ReportCounter(string name, CounterValue value, Unit unit, MetricTags tags) { if (value.Items.Length == 0) { Send(Name(name, unit), value.Count); } else { Send(SubfolderName(name, unit, "Total"), value.Count); } }
public void OnNext(CounterValue value) { string lastUpdate = string.Format("Last Update: {0}", value.Time.ToLongTimeString()); lock (_lock) { UpdateConsoleRow(LAST_UPDATE_ROW, lastUpdate); var stats = GetStats(value); UpdateCounterStats(value.Counter, stats, value.Value); } }
protected override void ReportCounter(string name, CounterValue value, Unit unit, MetricTags tags) { var itemProperties = value.Items.SelectMany(i => new[] { new JsonProperty(i.Item + " - Count", i.Count), new JsonProperty(i.Item + " - Percent", i.Percent), }); Pack("Counter", name, unit, tags, new[] { new JsonProperty("Count", value.Count), }.Concat(itemProperties)); }
public CounterBox() { InitializeComponent(); CounterValue = DefaultValue; CounterTextBox.SetBinding(TextBox.TextProperty, new Binding("CounterText") { Source = this, Mode = BindingMode.TwoWay }); CounterTextBox.Text = CounterValue.ToString(); }
public void Update() { float cpu = 23; var v = new CounterValue { HostName = mHost.HostName, TimeLogged = DateTime.Now, Category = "CPU", Counter = "Usage", Instance = "CPU0", Value = cpu }; mHost.ReportValue(v); }
private void ReportCounter(CounterValueSource g) { string name = g.Name; CounterValue value = GetMetricValueSourceValue <CounterValue>(g.ValueProvider); Unit unit = g.Unit; var itemColumns = value.Items.SelectMany(i => new[] { i.Item + " - Count", i.Item + " - Percent" }); var columns = CounterColumns.Concat(itemColumns); var itemValues = value.Items.SelectMany(i => new object[] { i.Count, i.Percent }); var values = new object[] { value.Count }.Concat(itemValues); Pack(name, columns, values, g.Tags); }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="value"></param> /// <param name="unit"></param> /// <param name="tags"></param> protected override void ReportCounter(string name, CounterValue value, Unit unit, MetricTags tags) { // Metrics.NET counters can be decremented, but Prometheus' are expected to be monotonically increasing, // so this maps to a Prometheus gauge. if (_config.OutputSetItems && value.Items?.Length > 0) { var setItems = value.Items.Select(item => new SetItem(item.Item, item.Count)); WriteLongMetricSet("gauge", name, setItems, unit, tags); } else { WriteLongMetric("gauge", name, value.Count, unit, tags); } }
private IEnumerable <CounterValueSource> SetupCounters() { var items = new[] { new CounterValue.SetItem("item1", 20, 10), new CounterValue.SetItem("item2", 40, 20), new CounterValue.SetItem("item3", 140, 70) }; var counterValue = new CounterValue(200, items); var counter = new CounterValueSource("test_counter", ConstantValue.Provider(counterValue), Unit.Items, Tags); return(new[] { counter }); }
public void Metrics() { IMetrics metrics = AppMetrics.CreateDefaultBuilder().Build(); CounterOptions counterOptions = new CounterOptions() { Context = "App", Name = "Counter", }; metrics.Measure.Counter.Increment(counterOptions); MetricsContextValueSource context = metrics.Snapshot.GetForContext("App"); CounterValue counterValue1 = context.Counters.First().Value; }
protected override void ReportCounter(string name, CounterValue value, Unit unit, MetricTags tags) { this.WriteMetricName(name); WriteValue("Count", unit.FormatCount(value.Count)); if (value.Items.Length > 0) { WriteValue("Total Items", value.Items.Length.ToString()); } for (int i = 0; i < value.Items.Length; i++) { var key = "Item " + i.ToString(); var item = value.Items[i]; var val = string.Format("{0:00.00}% {1,5} {2} [{3}]", item.Percent, item.Count, unit.Name, item.Item); WriteValue(key, val); } }
protected override void ReportCounter(string name, CounterValue value, Unit unit, MetricTags tags) { this.WriteMetricName(name); WriteValue("Count", unit.FormatCount(value.Count)); if (value.Items.Length > 0) { WriteValue("Total Items", value.Items.Length.ToString()); } for (int i = 0; i < value.Items.Length; i++) { var key = "Item " + i.ToString(); var item = value.Items[i]; var val = $"{item.Percent:00.00}% {item.Count,5} {unit.Name} [{item.Item}]"; WriteValue(key, val); } }
protected override void ReportCounter(string name, CounterValue value, Unit unit, MetricTags tags) { if (_isDisposed) { return; } var itemProperties = value.Items.SelectMany(i => (new[] { new JsonProperty(SanitizeJsonPropertyName(i.Item) + "-Count", i.Count), new JsonProperty(SanitizeJsonPropertyName(i.Item) + "-Percent", i.Percent), })); Pack("Counter", name, unit, tags, new[] { new JsonProperty("Count", value.Count), }.Concat(itemProperties)); Int64 lastValue; if (!CounterLastValue.TryGetValue(name, out lastValue)) { lastValue = 0; } CounterLastValue[name] = value.Count; var itemPropertiesDiff = value.Items.SelectMany(i => { var pName = SanitizeJsonPropertyName(i.Item); var itemPropName = name + "-" + pName; Int64 pLastValue; if (!CounterPropertiesLastValue.TryGetValue(itemPropName, out pLastValue)) { lastValue = 0; } CounterPropertiesLastValue[itemPropName] = i.Count; var item = (new[] { new JsonProperty(pName + "-Count", i.Count - pLastValue) }); return(item); }); Pack("CounterDiff", name, unit, tags, new[] { new JsonProperty("Count", value.Count - lastValue), }.Concat(itemPropertiesDiff)); }
protected override void ReportCounter(string name, CounterValue value, Unit unit, MetricTags tags) { if (value.Items.Length == 0) { Send(Name(name, unit), value.Count); } else { Send(SubfolderName(name, unit, "Total"), value.Count); } foreach (var item in value.Items) { Send(SubfolderName(name, unit, item.Item), item.Count); Send(SubfolderName(name, unit, item.Item, "Percent"), item.Percent); } }
protected void ReportCounter(string name, CounterValue value, Unit unit, MetricTags tags) { var payload = new JObject { { "count", value.Count } }; value.Items.ForEach(i => { payload.Add(i.Item + "Count", i.Count); payload.Add(i.Item + "Percent", i.Percent); }); var te = Pack("Counter", name, unit, tags, payload); _subject.OnNext(te); }
public void OnNext(CounterValue value) { foreach (var o in _observers) o.OnNext(value); }
Stats GetStats(CounterValue counterValue) { string key = GetCounterShortName(counterValue.Counter); Stats row; if (_data.TryGetValue(key, out row)) { row.CounterValues.Add(counterValue); return row; } else throw new ApplicationException("Counter not initialized on the observer"); }
public void OnNext(CounterValue value) { int eventId = Interlocked.Increment(ref EventId); TraceSource.TraceEvent(TraceEventType.Information, eventId, string.Format("{0} {1} {2}", value.Time, value.Counter, value.Value)); }
protected override void ReportCounter(string name, CounterValue value, Unit unit, MetricTags tags) { Write("Counter", name, CounterValues(value.Count, unit)); }
public void OnNext(CounterValue value) { Console.WriteLine(string.Format("{0} {1} {2}", value.Time, value.Counter, value.Value)); }
protected override void ReportCounter(string name, CounterValue value, Unit unit, MetricTags tags) { this.metricName = name; base.ReportCounter(name, value, unit, tags); }