public ActiveMqMetricsRecorder(string name, ActiveMqMetricsOptions options, IMetrics metrics) { Name = name; _metrics = metrics; _messageSendTime = new HistogramOptions { Context = options.Context, Name = "Message Send Time", MeasurementUnit = Unit.Custom("ns") }; _messageSendRate = new MeterOptions { Context = options.Context, Name = "Message Send Rate", MeasurementUnit = Unit.Custom("msg") }; _messageProcessingTime = new HistogramOptions { Context = options.Context, Name = "Message Processing Time", MeasurementUnit = Unit.Custom("ns") }; _messageProcessingRate = new MeterOptions { Context = options.Context, Name = "Message Processing Rate", MeasurementUnit = Unit.Custom("msg"), }; }
internal static DefaultHistogram Factory(string name, Action <HistogramOptions> init) { var options = new HistogramOptions(); init(options); return(new DefaultHistogram(name, options)); }
public void histogramOptions(HistogramOptions histogramOpts) { msclPINVOKE.WirelessNodeConfig_histogramOptions__SWIG_1(swigCPtr, HistogramOptions.getCPtr(histogramOpts)); if (msclPINVOKE.SWIGPendingException.Pending) { throw msclPINVOKE.SWIGPendingException.Retrieve(); } }
public IHistogram Histogram <T>(HistogramOptions options, Func <T> builder) where T : IHistogramMetric { return(_histograms.GetOrAdd(options.Name, () => { var histogram = builder(); return Tuple.Create((IHistogram)histogram, new HistogramValueSource(options.Name, histogram, options.MeasurementUnit, options.Tags)); })); }
public IHistogram Histogram <T>(HistogramOptions options, Func <T> builder) where T : IHistogramMetric { EnsureContextLabel(options); EnsureSamplingType(options); var registry = _contexts.GetOrAdd(options.Context, _newContextRegistry); return(registry.Histogram(options, builder)); }
private static async Task Main(string[] args) { var metrics = AppMetrics.CreateDefaultBuilder().Build(); var counter = new CounterOptions { Name = "my_counter" }; metrics.Measure.Counter.Increment(counter); var gauge = new GaugeOptions { Name = "my_gauge" }; metrics.Measure.Gauge.SetValue(gauge, 1); var meter = new MeterOptions { Name = "my_meter" }; metrics.Measure.Meter.Mark(meter); var histogram = new HistogramOptions { Name = "my_histogram" }; metrics.Measure.Histogram.Update(histogram, 10); var timer = new TimerOptions { Name = "my_timer" }; using (metrics.Measure.Timer.Time(timer)) { await Task.Delay(100); } var apdex = new ApdexOptions { Name = "my_apdex", AllowWarmup = false, ApdexTSeconds = 0.1 }; using (metrics.Measure.Apdex.Track(apdex)) { await Task.Delay(200); } var snapshot = metrics.Snapshot.Get(); using (var stream = new MemoryStream()) { await metrics.DefaultOutputMetricsFormatter.WriteAsync(stream, snapshot); var result = Encoding.UTF8.GetString(stream.ToArray()); WriteLine(result); } ReadKey(); }
public IHistogram Histogram(HistogramOptions options) { if (options.WithReservoir != null) { return(Histogram(options, () => this.BuildHistogram(options, options.WithReservoir()))); } return(Histogram(options, () => this.BuildHistogram(options))); }
public MetricsHistogram(string name, IMeasureHistogramMetrics histogramMetrics, List <string> labelNames) : base(labelNames, new List <string>()) { this.histogramMetrics = histogramMetrics; this.histogramOptions = new HistogramOptions { Name = name, MeasurementUnit = Unit.Items }; }
public HistogramOptions histogramOptions() { HistogramOptions ret = new HistogramOptions(msclPINVOKE.WirelessNodeConfig_histogramOptions__SWIG_0(swigCPtr), false); if (msclPINVOKE.SWIGPendingException.Pending) { throw msclPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public HistogramOptions getHistogramOptions() { HistogramOptions ret = new HistogramOptions(msclPINVOKE.WirelessNode_getHistogramOptions(swigCPtr), true); if (msclPINVOKE.SWIGPendingException.Pending) { throw msclPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public MetricContextTestFixture() { ApdexOptions = new ApdexOptions { Name = "apdex" }; CounterOptions = new CounterOptions { Name = "counter" }; GaugeOptions = new GaugeOptions { Name = "gauge" }; HistogramOptions = new HistogramOptions { Name = "histogram" }; MeterOptions = new MeterOptions { Name = "meter" }; TimerOptions = new TimerOptions { Name = "timer" }; var tags = new GlobalMetricTags { { "key1", "value1" }, { "key2", "value2" } }; var contextualTags = new ContextualMetricTagProviders { { "key1", () => new Guid().ToString() }, { "key2", () => new Guid().ToString() } }; var samplingProvider = new DefaultSamplingReservoirProvider(() => new DefaultForwardDecayingReservoir()); Registry = new DefaultMetricContextRegistry("context_label", tags, contextualTags); ApdexBuilder = new DefaultApdexBuilder(samplingProvider); HistogramBuilder = new DefaultHistogramBuilder(samplingProvider); CounterBuilder = new DefaultCounterBuilder(); GaugeBuilder = new DefaultGaugeBuilder(); MeterBuilder = new DefaultMeterBuilder(); TimerBuilder = new DefaultTimerBuilder(samplingProvider); Clock = new StopwatchClock(); }
public void Can_update() { var metricName = "test_update_histogram"; var options = new HistogramOptions { Name = metricName }; _manager.Update(options, 2L); _fixture.Snapshot.GetHistogramValue(_context, metricName).LastValue.Should().Be(2L); }
public MetricsDuration(string name, DurationUnit durationUnit, IMeasureHistogramMetrics histogramMetrics, List <string> labelNames) : base(labelNames, new List <string>()) { this.histogramMetrics = histogramMetrics; this.histogramOptions = new HistogramOptions { Name = $"{name}_milliseconds", MeasurementUnit = Unit.Items }; this.durationUnit = durationUnit; }
static MeasureHistogramBenchmark() { Metrics = new HistogramOptions[NumberOfMetrics]; for (var i = 0; i < NumberOfMetrics; i++) { Metrics[i] = new HistogramOptions { Name = $"metric_{i:D4}" }; } }
public void Can_update_with_user_value() { var metricName = "test_update_histogram_user_value"; var options = new HistogramOptions { Name = metricName }; _manager.Update(options, 5L, "uservalue"); _fixture.Snapshot.GetHistogramValue(_context, metricName).LastValue.Should().Be(5L); _fixture.Snapshot.GetHistogramValue(_context, metricName).LastUserValue.Should().Be("uservalue"); }
public void Context_doesnt_exist_returns_default_histgoram_when_multidimensional() { var metricName = "DefaultMetricValuesProviderTests_histgoram_without_context_multi"; var options = new HistogramOptions { Name = "different", Context = Context }; _measure.Histogram.Update(options, _tags[1], 1L); _provider.GetHistogramValue(Context, _tags[1].AsMetricName(metricName)).Should().NotBe(1); }
public void Can_get_multidimensional_histogram_value() { var metricName = "DefaultMetricValuesProviderTests_histogram_multi"; var options = new HistogramOptions { Name = metricName, Context = Context }; _measure.Histogram.Update(options, _tags[1], 1L); _provider.GetHistogramValue(Context, _tags[1].AsMetricName(metricName)).Count.Should().Be(1); }
public void Can_get_histogram_value() { var metricName = "DefaultMetricValuesProviderTests_histogram"; var options = new HistogramOptions { Name = metricName, Context = Context }; _measure.Histogram.Update(options, 1L); _provider.GetHistogramValue(Context, metricName).Count.Should().Be(1); }
public void Can_update_multidimensional() { var metricName = "test_update_histogram_multi"; var options = new HistogramOptions { Name = metricName }; _manager.Update(options, _fixture.Tags[0], 2L); _manager.Update(options, _fixture.Tags[1], 4L); _fixture.Snapshot.GetHistogramValue(_context, _fixture.Tags[0].AsMetricName(metricName)).LastValue.Should().Be(2L); _fixture.Snapshot.GetHistogramValue(_context, _fixture.Tags[1].AsMetricName(metricName)).LastValue.Should().Be(4L); }
public void context_doesnt_exist_returns_default_histgoram() { var metricName = "DefaultMetricValuesProviderTests_histgoram_without_context"; var options = new HistogramOptions { Name = "different", Context = Context }; _measure.Histogram.Update(options, 1L); _provider.GetHistogramValue(Context, metricName).Should().NotBe(1); }
/// <inheritdoc /> public IHistogram Histogram <T>(HistogramOptions options, MetricTags tags, Func <T> builder) where T : IHistogramMetric { if (_nullMetricsRegistry.IsValueCreated) { return(_nullMetricsRegistry.Value.Histogram(options, tags, builder)); } EnsureContextLabel(options); var contextRegistry = _contexts.GetOrAdd(options.Context, _newContextRegistry); return(contextRegistry.Histogram(options, tags, builder)); }
private void SetNodeItemEvicted(Guid guid, string machineName, long itemsEvicted) { var tags = new MetricTags(new[] { "node_id", "machine_name" }, new[] { guid.ToString(), machineName }); var histogram = new HistogramOptions { Context = "node", Tags = tags, Name = "Node Items Evicted", Reservoir = () => new DefaultAlgorithmRReservoir(), MeasurementUnit = Unit.None }; _metrics?.Measure.Histogram.Update(histogram, itemsEvicted); }
private void SetNodeThroughput(Guid guid, string machineName, double throughput) { var tags = new MetricTags(new[] { "node_id", "machine_name" }, new[] { guid.ToString(), machineName }); var histogram = new HistogramOptions { Context = "node", Tags = tags, Name = "Node Throughput", Reservoir = () => new DefaultAlgorithmRReservoir(), MeasurementUnit = Unit.None }; _metrics?.Measure.Histogram.Update(histogram, Convert.ToInt64(throughput)); }
public void Can_get_histogram_value_with_tags() { var metricName = "DefaultMetricValuesProviderTests_histogram"; var options = new HistogramOptions { Name = metricName, Context = Context }; var tags = new MetricTags("key", "value"); _measure.Histogram.Update(options, tags, 1L); _provider.GetHistogramValue(Context, tags.AsMetricName(metricName)).Count.Should().Be(1); }
public void can_add_multidimensional_to_registry() { var metricName = "histogram_provider_test_multi"; var options = new HistogramOptions { Name = metricName }; _provider.Instance(options, _fixture.Tags[0]); _filter.WhereMetricName(name => name == _fixture.Tags[0].AsMetricName(metricName)); _fixture.Registry.GetData(_filter).Contexts.First().Histograms.Count().Should().Be(1); }
public void can_add_instance_to_registry() { var metricName = "histogram_provider_test"; var options = new HistogramOptions { Name = metricName }; _provider.Instance(options); _filter.WhereMetricName(name => name == metricName); _fixture.Registry.GetData(_filter).Contexts.First().Histograms.Count().Should().Be(1); }
public void does_not_throw_on_metrics_of_different_type_with_same_name() { ((Action)(() => { var name = "Test"; var apdexOptions = new ApdexOptions { Name = name, MeasurementUnit = Unit.Calls, }; var counterOptions = new CounterOptions { Name = name, MeasurementUnit = Unit.Calls, }; var meterOptions = new MeterOptions { Name = name, MeasurementUnit = Unit.Calls }; var gaugeOptions = new GaugeOptions { Name = name, MeasurementUnit = Unit.Calls }; var histogramOptions = new HistogramOptions { Name = name, MeasurementUnit = Unit.Calls }; var timerOptions = new TimerOptions { Name = name, MeasurementUnit = Unit.Calls }; _fixture.Metrics.Measure.Apdex.Track(apdexOptions); _fixture.Metrics.Measure.Gauge.SetValue(gaugeOptions, () => 0.0); _fixture.Metrics.Measure.Counter.Increment(counterOptions); _fixture.Metrics.Measure.Meter.Mark(meterOptions); _fixture.Metrics.Measure.Histogram.Update(histogramOptions, 1L); _fixture.Metrics.Measure.Timer.Time(timerOptions); })).ShouldNotThrow(); }
public void Can_update_multidimensional_with_user_value() { var metricName = "test_update_histogram_user_value_multi"; var options = new HistogramOptions { Name = metricName }; _manager.Update(options, _fixture.Tags[0], 5L, "uservalue"); _manager.Update(options, _fixture.Tags[1], 100L, "uservalue"); _fixture.Snapshot.GetHistogramValue(_context, _fixture.Tags[0].AsMetricName(metricName)).LastValue.Should().Be(5L); _fixture.Snapshot.GetHistogramValue(_context, _fixture.Tags[0].AsMetricName(metricName)).LastUserValue.Should().Be("uservalue"); _fixture.Snapshot.GetHistogramValue(_context, _fixture.Tags[1].AsMetricName(metricName)).LastValue.Should().Be(100L); _fixture.Snapshot.GetHistogramValue(_context, _fixture.Tags[1].AsMetricName(metricName)).LastUserValue.Should().Be("uservalue"); }
public void can_add_add_new_multidimensional_to_registry() { var metricName = "histogram_provider_metric_test_multi"; var options = new HistogramOptions { Name = metricName }; var apdexMetric = _fixture.Builder.Histogram.Build(() => new DefaultAlgorithmRReservoir(1028)); _provider.Instance(options, _fixture.Tags[0], () => apdexMetric); _filter.WhereMetricName(name => name == _fixture.Tags[0].AsMetricName(metricName)); _fixture.Registry.GetData(_filter).Contexts.First().Histograms.Count().Should().Be(1); }
static void Main(string[] args) { var metrics = new MetricsBuilder() .Report.ToConsole() .Build(); //var sentEmailsCounter = new CounterOptions() //{ // Name = "Sent Emails", // MeasurementUnit = Unit.Calls //}; //metrics.Measure.Counter.Increment(sentEmailsCounter, "email-a-friend"); //metrics.Measure.Counter.Increment(sentEmailsCounter, "forget-password"); //metrics.Measure.Counter.Increment(sentEmailsCounter, "account-verification"); //var httpStatusMeter = new MeterOptions() //{ // Name = "Http Status", // MeasurementUnit = Unit.Calls //}; //metrics.Measure.Meter.Mark(httpStatusMeter, "200"); //metrics.Measure.Meter.Mark(httpStatusMeter, "500"); //metrics.Measure.Meter.Mark(httpStatusMeter, "401"); //metrics.Provider.Meter.Instance(httpStatusMeter).Reset(); var rnd = new Random(); var postAndPutRequestSize = new HistogramOptions() { Name = "Web Request Post & Put Size", MeasurementUnit = Unit.Bytes }; foreach (var i in Enumerable.Range(0, 50)) { var t = rnd.Next(0, 10); metrics.Measure.Histogram.Update(postAndPutRequestSize, t); } Task.WhenAll(metrics.ReportRunner.RunAllAsync()).Wait(); Console.ReadKey(); }