public JsonSerializationTests() { var eventFields = new Dictionary <string, object>(); eventFields.Add("field", "value"); eventFields.Add("abc", "123"); eventValue = new EventValue(new List <EventDetails> { new EventDetails(eventFields, new DateTime(1, 1, 1)) }); this.timerValue = new TimerValue(this.meterValue, this.histogramValue, 0, 1, TimeUnit.Nanoseconds); this.counter = new CounterValueSource("test1", Provider(counterValue), Unit.Errors, MetricTags.None); this.meter = new MeterValueSource("test2", Provider(meterValue), Unit.Calls, TimeUnit.Seconds, MetricTags.None); this.histogram = new HistogramValueSource("test3", Provider(histogramValue), Unit.Items, MetricTags.None); this.timer = new TimerValueSource("test4", Provider(timerValue), Unit.Requests, TimeUnit.Seconds, TimeUnit.Milliseconds, MetricTags.None); this.evnt = new EventValueSource("test5", Provider(eventValue), MetricTags.None); this.data = new MetricsData("test", new DateTime(2014, 2, 17), new[] { new EnvironmentEntry("name", "1") }, new[] { gauge }, new[] { counter }, new[] { meter }, new[] { histogram }, new[] { timer }, new[] { evnt }, Enumerable.Empty <MetricsData>() ); this.jsonContext = JsonMetricsContext.FromContext(this.data, "1"); }
public void Consume(JsonMetricsContext metricsData) { var sendSideLinkStateByKey = metricsData.Gauges.Where(g => g.Tags.Contains("type:sent")).GroupBy(g => g.Name); foreach (var keyState in sendSideLinkStateByKey) { var sequenceKey = keyState.Key; sendLinkState.Gauge(sequenceKey, () => GetHighestSequenceNumber(sequenceKey, receivedMetricContext, "type:sent"), sequenceUnit); } var queues = new HashSet <string>(); var receiveSideLinkStateByKey = metricsData.Gauges.Where(g => g.Tags.Contains("type:received")).GroupBy(g => g.Name); foreach (var keyState in receiveSideLinkStateByKey) { var sequenceKey = keyState.Key; var queue = QueueTag(keyState.First().Tags); queues.Add(queue); receiveLinkState.Gauge(sequenceKey, () => GetHighestSequenceNumber(sequenceKey, receivedMetricContext, "type:received"), sequenceUnit, new MetricTags($"queue:{queue}")); linkState.Gauge(sequenceKey, () => GetNumberOfInFlightMessages(sequenceKey, receiveLinkState, sendLinkState), messagesUnit, new MetricTags($"queue:{queue}")); } foreach (var queue in queues) { queueState.Gauge(queue, () => GetQueueState(queue, linkState), messagesUnit); } }
public JsonSerializationTests() { this.timerValue = new TimerValue(this.meterValue, this.histogramValue, 0, 1, TimeUnit.Nanoseconds); this.counter = new CounterValueSource("test1", Provider(counterValue), Unit.Errors, MetricTags.None); this.meter = new MeterValueSource("test2", Provider(meterValue), Unit.Calls, TimeUnit.Seconds, MetricTags.None); this.histogram = new HistogramValueSource("test3", Provider(histogramValue), Unit.Items, MetricTags.None); this.timer = new TimerValueSource("test4", Provider(timerValue), Unit.Requests, TimeUnit.Seconds, TimeUnit.Milliseconds, MetricTags.None); this.data = new MetricsData("test", new DateTime(2014, 2, 17), new[] { new EnvironmentEntry("name", "1") }, new[] { gauge }, new[] { counter }, new[] { meter }, new[] { histogram }, new[] { timer }, Enumerable.Empty <MetricsData>() ); this.jsonContext = JsonMetricsContext.FromContext(this.data, "1"); }