public static AssertionResult CreateResult(MetricName name, string unitName, double value, Assertion assertion) { var passed = assertion.Test(value); var passedString = passed ? "[PASS]" : "[FAIL]"; var message = $"{passedString} Expected {name} to {assertion} {unitName}; actual value was {value:n} {unitName}."; return new AssertionResult(name, message, passed); }
private void reportTimer(long timestamp, MetricName name, Timer timer) { Snapshot snapshot = timer.Snapshot; report(timestamp, name, "count,max,mean,min,stddev,p50,p75,p95,p98,p99,p999,mean_rate,m1_rate,m5_rate,m15_rate,rate_unit,duration_unit", timer.Count, convertDuration(snapshot.Max), convertDuration(snapshot.Mean), convertDuration(snapshot.Min), convertDuration(snapshot.StdDev), convertDuration(snapshot.Median), convertDuration(snapshot.Percentile75th), convertDuration(snapshot.Percentile95th), convertDuration(snapshot.Percentile98th), convertDuration(snapshot.Percentile99th), convertDuration(snapshot.Percentile999th), convertRate(timer.MeanRate), convertRate(timer.OneMinuteRate), convertRate(timer.FiveMinuteRate), convertRate(timer.FifteenMinuteRate), "calls/" + getRateUnit(), getDurationUnit()); }
protected MetricCollector(MetricName name, string unitName) { Contract.Requires(name != null); Contract.Requires(!string.IsNullOrEmpty(unitName)); Name = name; UnitName = unitName; }
public AssertionResult(MetricName metricName, string message, bool passed) { Contract.Requires(metricName != null); MetricName = metricName; Message = message; Passed = passed; }
public PerformanceCounterValueCollector(MetricName name, string unitName, IPerformanceCounterProxy counter, bool disposesCounter) : base(name, unitName) { Counter = counter; DisposesCounter = disposesCounter; }
public static MetricName BuildName(IProxyRequest request, string Name, bool Absolute) { MetricName metricName = null; if (Absolute) metricName = new MetricName(Name); else metricName = new MetricName(request.Target.GetType().FullName + "." + Name); return metricName; }
public void CanRemoveMetricFromRegistry() { var name = new MetricName( "MeterTests.Can_safely_remove_metrics_from_outer_collection_without_affecting_registry"); var meter = registry.Meter("MeterTests.Can_safely_remove_metrics_from_outer_collection_without_affecting_registry"); meter.Mark(3); registry.Remove(name); Assert.True(!registry.Metrics.ContainsKey(name), "Metric was removed from central registry"); }
public IPerformanceCounterProxy Get(MetricName name) { if (!Exists(name)) { return EmptyPerformanceCounterProxy.Instance; } var counter = _cachedCounters[name]; counter.Touch(); // increment reference count return counter; }
public bool Put(MetricName name, IPerformanceCounterProxy concreteCounter) { if (!Exists(name)) { _cachedCounters[name] = new CachedPerformanceCounterProxy(() => concreteCounter); return true; } // already exists - not overriding return false; }
public AggregateMetrics(MetricName name, string unit, IReadOnlyList<MetricRunReport> runs) { Contract.Requires(runs != null); Contract.Requires(name != null); Contract.Requires(!string.IsNullOrEmpty(unit)); Name = name; Unit = unit; Runs = runs == null || runs.Count == 0 ? GetSafeRuns(name, unit) : runs; Stats = new BenchmarkStat(runs.Select(x => x.MetricValue)); PerSecondStats = new BenchmarkStat(runs.Select(x => x.MetricValuePerSecond)); }
public MetricRunReport(MetricName name, string unit, double metricReading, long ticks) { Contract.Requires(name != null); Contract.Requires(!string.IsNullOrEmpty(unit)); Ticks = Math.Max(ticks, 1); Name = name; Unit = unit; MetricValue = metricReading; ElapsedNanos = Ticks/(double) Stopwatch.Frequency*1000000000; ElapsedSeconds = ElapsedNanos/1000000000; NanosPerMetricValue = ElapsedNanos/Math.Max(MetricValue,1); MetricValuePerSecond = MetricValue/ElapsedSeconds; }
public void Can_get_metrics_from_collection_with_registered_changes() { // Counter var name = new MetricName("MeterTests.counter"); var counter = registry.Counter( "MeterTests.counter"); Assert.IsNotNull(registry.Metrics[name], "Metric not found in central registry"); counter.Increment(10); var actual = ((Counter)registry.Metrics[name]).Count; Assert.AreEqual(10, actual, "Immutable copy did not contain correct values for this metric"); // Meter name = new MetricName("MeterTests.meter"); var meter = registry.Meter( "MeterTests.meter"); Assert.IsNotNull(registry.Metrics[name], "Metric not found in central registry"); meter.Mark(3); actual = ((Meter)registry.Metrics[name]).Count; Assert.AreEqual(3, actual, "Immutable copy did not contain correct values for this metric"); }
public CounterMetricCollector(MetricName name, string unitName, AtomicCounter counter) : base(name, unitName) { _counter = counter; }
public LongArrayMetric(MetricName name, long[] value, string uom) : base(name, value, uom) { }
private void reportCounter(MetricName name, Counter counter, long timestamp) { graphite.Send(Prefix(name, "count"), format(counter.Count), timestamp); }
private void reportGauge(long timestamp, MetricName name, Gauge gauge) { report(timestamp, name, "value", gauge.ValueAsString); }
private void reportHistogram(long timestamp, MetricName name, Histogram histogram) { Snapshot snapshot = histogram.Snapshot; report(timestamp, name, "count,max,mean,min,stddev,p50,p75,p95,p98,p99,p999", histogram.Count, snapshot.Max, snapshot.Mean, snapshot.Min, snapshot.StdDev, snapshot.Median, snapshot.Percentile75th, snapshot.Percentile95th, snapshot.Percentile98th, snapshot.Percentile99th, snapshot.Percentile999th); }
public GcCollectionsPerGenerationCollector(MetricName name, string unitName, int generation) : base(name, unitName) { Generation = generation; }
private string Prefix(MetricName name, params String[] components) { return(MetricName.join(MetricName.join(this.prefix, name), MetricName.build(components)).Key); }
/// <summary> /// Given a new <seealso cref="Gauge{T}" />, registers it under the given metric name. /// </summary> /// <param name="metricName">the name of the metric</param> /// <param name="metric">the metric</param> /// <typeparam name="T">the type of the value returned by the metric</typeparam> /// <returns>{@code metric}</returns> public static Gauge<T> NewGauge<T>( MetricName metricName, Gauge<T> metric) { return DEFAULT_REGISTRY.NewGauge(metricName, metric); }
public override bool Equals(MetricName other) { return(other is CounterMetricName && Equals((CounterMetricName)other)); }
protected MetricsCollectorSelector(MetricName name, SysInfo systemInfo) { Name = name; SystemInfo = systemInfo; }
public PerformanceCounterSelector(MetricName name) : base(name) { }
public PerformanceCounterMetricCollector(MetricName name, string unitName, PerformanceCounter counter, bool disposesCounter) : base(name, unitName) { _counter = counter; DisposesCounter = disposesCounter; }
/// <summary> /// Gets a collection of data points collected for a metric by the monitoring service. /// </summary> /// <param name="service">The monitoring service instance.</param> /// <param name="entityId">The entity ID. This is obtained from <see cref="Entity.Id">Entity.Id</see>.</param> /// <param name="checkId">The check ID. This is obtained from <see cref="Check.Id">Check.Id</see>.</param> /// <param name="metricName">The metric name. This is obtained from <see cref="Metric.Name">Metric.Name</see>.</param> /// <param name="points">The number of data points to return.</param> /// <param name="resolution">The granularity of the returned data points.</param> /// <param name="select">A collection of <see cref="DataPointStatistic"/> objects identifying the statistics to compute for the data.</param> /// <param name="from">The beginning timestamp of the items to include in the collection. This parameter is used for <see href="http://docs.rackspace.com/cm/api/v1.0/cm-devguide/content/api-time-series-collections.html">time series collections</see>.</param> /// <param name="to">The ending timestamp of the items to include in the collection. This parameter is used for <see href="http://docs.rackspace.com/cm/api/v1.0/cm-devguide/content/api-time-series-collections.html">time series collections</see>.</param> /// <returns> /// A collection of <see cref="DataPoint"/> objects describing the data points /// collected for the metric. /// </returns> /// <exception cref="ArgumentNullException">If <paramref name="service"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentNullException"> /// If <paramref name="entityId"/> is <see langword="null"/>. /// <para>-or-</para> /// <para>If <paramref name="checkId"/> is <see langword="null"/>.</para> /// <para>-or-</para> /// <para>If <paramref name="metricName"/> is <see langword="null"/>.</para> /// </exception> /// <exception cref="ArgumentException"> /// If both <paramref name="points"/> and <paramref name="resolution"/> are <see langword="null"/>. /// <para>-or-</para> /// <para>If <paramref name="to"/> occurs before <paramref name="from"/>.</para> /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// If <paramref name="points"/> is less than or equal to 0. /// <para>-or-</para> /// <para>If <paramref name="from"/> represents a date before January 1, 1970 UTC.</para> /// <para>-or-</para> /// <para>If <paramref name="to"/> represents a date before January 1, 1970 UTC.</para> /// </exception> /// <exception cref="WebException">If the REST request does not return successfully.</exception> /// <seealso href="http://docs.rackspace.com/cm/api/v1.0/cm-devguide/content/metrics-api.html#fetch-data-points">Fetch Data Points (Rackspace Cloud Monitoring Developer Guide - API v1.0)</seealso> public static ReadOnlyCollection<DataPoint> GetDataPoints(this IMonitoringService service, EntityId entityId, CheckId checkId, MetricName metricName, int? points, DataPointGranularity resolution, IEnumerable<DataPointStatistic> select, DateTimeOffset from, DateTimeOffset to) { if (service == null) throw new ArgumentNullException("service"); try { return service.GetDataPointsAsync(entityId, checkId, metricName, points, resolution, select, from, to, CancellationToken.None).Result; } catch (AggregateException ex) { ReadOnlyCollection<Exception> innerExceptions = ex.Flatten().InnerExceptions; if (innerExceptions.Count == 1) throw innerExceptions[0]; throw; } }
public DateTimeMetric(MetricName name, DateTimeOffset value, string uom) : base(name, value, uom) { }
/// <summary> /// Creates a new <seealso cref="Histogram" /> and registers it under the given /// metric name. /// </summary> /// <param name="metricName">the name of the metric</param> /// <param name="biased">whether or not the histogram should be biased</param> /// <returns>a new <seealso cref="Histogram" /></returns> public static Histogram NewHistogram( MetricName metricName, bool biased) { return DEFAULT_REGISTRY.NewHistogram(metricName, biased); }
public override bool Equals(MetricName other) { return(other is PerformanceCounterMetricName && Equals((PerformanceCounterMetricName)other)); }
private void LogGauge(IRequest request, MetricName metricName, GaugeMetric metric, long timestamp) { LogGauge(request, metricName.Name, System.Convert.ToInt64(metric.ValueAsString), timestamp); }
public bool Matches( MetricName name, Metric metric) { return(true); }
public GcCollectionsPerGenerationCollector(MetricName name, int generation) : this(name, MetricNames.GcCollectionsUnits, generation) { }
public override bool Equals(MetricName other) { return(other is GcMetricName && Equals((GcMetricName)other)); }
private void reportMeter(long timestamp, MetricName name, Meter meter) { report(timestamp, name, "count,mean_rate,m1_rate,m5_rate,m15_rate,rate_unit", meter.Count, convertRate(meter.MeanRate), convertRate(meter.OneMinuteRate), convertRate(meter.FiveMinuteRate), convertRate(meter.FifteenMinuteRate), "events/" + getRateUnit()); }
private void report(MetricName name, String header, IEnumerable<object> values) { try { string filePath = System.IO.Path.Combine(directory, sanitize(name.Key)); bool fileAlreadyExists = File.Exists(filePath); using (StreamWriter stream = File.AppendText(filePath)) { if (!fileAlreadyExists) { stream.WriteLine(header); } stream.WriteLine(string.Join(",", values)); } } catch (IOException e) { LOGGER.Warn("Error writing to " + name, e); } }
private void reportCounter(long timestamp, MetricName name, Counter counter) { report(timestamp, name, "count", counter.Count); }
public override bool Equals(MetricName other) { return other is CounterMetricName && Equals((CounterMetricName)other); }
private void report(long timestamp, MetricName name, string header, params Object[] valuesArr) { header = "t," + header; List<object> values = new List<object>(); values.Add(timestamp); foreach (object obj in valuesArr) values.Add(obj); report(name, header, values); }
public Metric(MetricName name, T value, string uom) { this.name = name; this.value = value; this.uom = uom; }
public void ThreadMetricsTest() { var serdes = new StringSerDes(); var cloneConfig = config.Clone(); cloneConfig.ApplicationId = "consume-test"; var producer = mockKafkaSupplier.GetProducer(cloneConfig.ToProducerConfig()); var consumer = mockKafkaSupplier.GetConsumer(cloneConfig.ToConsumerConfig("test-consum"), null); consumer.Subscribe("topic2"); thread.Start(token.Token); AssertExtensions.WaitUntil(() => thread.ActiveTasks.Count() == numberPartitions, TimeSpan.FromSeconds(5), TimeSpan.FromMilliseconds(100)); int nbMessage = 1000; // produce ${nbMessage} messages to input topic for (int i = 0; i < nbMessage; ++i) { producer.Produce("topic", new Confluent.Kafka.Message <byte[], byte[]> { Key = serdes.Serialize("key" + i, new SerializationContext()), Value = serdes.Serialize("Hi" + i, new SerializationContext()) }); } var messagesSink = new List <ConsumeResult <byte[], byte[]> >(); AssertExtensions.WaitUntil(() => { messagesSink.AddRange(consumer.ConsumeRecords(TimeSpan.FromSeconds(1))); return(messagesSink.Count == nbMessage); }, TimeSpan.FromSeconds(5), TimeSpan.FromMilliseconds(10)); // waiting end of processing Thread.Sleep(1000); long now = DateTime.Now.GetMilliseconds(); var sensors = streamMetricsRegistry.GetThreadScopeSensor(threadId); var createTaskSensor = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(ThreadMetrics.CREATE_TASK))); Assert.AreEqual(2, createTaskSensor.Metrics.Count()); Assert.AreEqual(numberPartitions, createTaskSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.CREATE_TASK + StreamMetricsRegistry.TOTAL_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value); Assert.IsTrue( (double)(createTaskSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.CREATE_TASK + StreamMetricsRegistry.RATE_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value) > 0d); var closeTaskSensor = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(ThreadMetrics.CLOSE_TASK))); Assert.AreEqual(2, closeTaskSensor.Metrics.Count()); Assert.AreEqual(0d, closeTaskSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.CLOSE_TASK + StreamMetricsRegistry.TOTAL_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value); Assert.AreEqual(0d, closeTaskSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.CLOSE_TASK + StreamMetricsRegistry.RATE_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value); var commitSensor = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(ThreadMetrics.COMMIT))); Assert.AreEqual(4, commitSensor.Metrics.Count()); Assert.IsTrue( (double)commitSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.COMMIT + StreamMetricsRegistry.TOTAL_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value > 0d); Assert.IsTrue( (double)commitSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.COMMIT + StreamMetricsRegistry.RATE_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value > 0d); Assert.IsTrue( (double)commitSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.COMMIT + StreamMetricsRegistry.LATENCY_SUFFIX + StreamMetricsRegistry.AVG_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value > 0d); Assert.IsTrue( (double)commitSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.COMMIT + StreamMetricsRegistry.LATENCY_SUFFIX + StreamMetricsRegistry.MAX_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value > 0d); var pollSensor = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(ThreadMetrics.POLL))); Assert.AreEqual(4, pollSensor.Metrics.Count()); Assert.IsTrue( (double)pollSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.POLL + StreamMetricsRegistry.TOTAL_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value > 0d); Assert.IsTrue( (double)pollSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.POLL + StreamMetricsRegistry.RATE_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value > 0d); Assert.IsTrue( (double)pollSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.POLL + StreamMetricsRegistry.LATENCY_SUFFIX + StreamMetricsRegistry.AVG_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value > 0d); Assert.IsTrue( (double)pollSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.POLL + StreamMetricsRegistry.LATENCY_SUFFIX + StreamMetricsRegistry.MAX_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value > 0d); var pollRecordsSensor = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(ThreadMetrics.POLL + StreamMetricsRegistry.RECORDS_SUFFIX))); Assert.AreEqual(2, pollRecordsSensor.Metrics.Count()); Assert.IsTrue( (double)pollRecordsSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.POLL + StreamMetricsRegistry.RECORDS_SUFFIX + StreamMetricsRegistry.AVG_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value > 0d); Assert.IsTrue( (double)pollRecordsSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.POLL + StreamMetricsRegistry.RECORDS_SUFFIX + StreamMetricsRegistry.MAX_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value > 0d); var processRecordsSensor = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(ThreadMetrics.PROCESS + StreamMetricsRegistry.RECORDS_SUFFIX))); Assert.AreEqual(2, processRecordsSensor.Metrics.Count()); Assert.IsTrue( (double)processRecordsSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.PROCESS + StreamMetricsRegistry.RECORDS_SUFFIX + StreamMetricsRegistry.AVG_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value > 0d); Assert.IsTrue( (double)processRecordsSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.PROCESS + StreamMetricsRegistry.RECORDS_SUFFIX + StreamMetricsRegistry.MAX_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value > 0d); var processRateSensor = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(ThreadMetrics.PROCESS + StreamMetricsRegistry.RATE_SUFFIX))); Assert.AreEqual(2, processRateSensor.Metrics.Count()); Assert.IsTrue( (double)processRateSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.PROCESS + StreamMetricsRegistry.RATE_SUFFIX + StreamMetricsRegistry.RATE_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value > 0d); Assert.IsTrue( (double)processRateSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.PROCESS + StreamMetricsRegistry.RATE_SUFFIX + StreamMetricsRegistry.TOTAL_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value > 0d); var processLatencySensor = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(ThreadMetrics.PROCESS + StreamMetricsRegistry.LATENCY_SUFFIX))); Assert.AreEqual(2, processLatencySensor.Metrics.Count()); Assert.IsTrue( (double)processLatencySensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.PROCESS + StreamMetricsRegistry.LATENCY_SUFFIX + StreamMetricsRegistry.AVG_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value > 0d); Assert.IsTrue( (double)processLatencySensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.PROCESS + StreamMetricsRegistry.LATENCY_SUFFIX + StreamMetricsRegistry.MAX_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value > 0d); // ratio sensors var processRatioSensor = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(ThreadMetrics.PROCESS + StreamMetricsRegistry.RATIO_SUFFIX))); var pollRatioSensor = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(ThreadMetrics.POLL + StreamMetricsRegistry.RATIO_SUFFIX))); var commitRatioSensor = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(ThreadMetrics.COMMIT + StreamMetricsRegistry.RATIO_SUFFIX))); Assert.AreEqual(1, processRatioSensor.Metrics.Count()); Assert.AreEqual(1, pollRatioSensor.Metrics.Count()); Assert.AreEqual(1, commitRatioSensor.Metrics.Count()); var processRatioValue = (double)processRatioSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.PROCESS + StreamMetricsRegistry.RATIO_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value; var pollRatioValue = (double)pollRatioSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.POLL + StreamMetricsRegistry.RATIO_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value; var commitRatioValue = (double)commitRatioSensor.Metrics[MetricName.NameAndGroup( ThreadMetrics.COMMIT + StreamMetricsRegistry.RATIO_SUFFIX, StreamMetricsRegistry.THREAD_LEVEL_GROUP)].Value; double total = Math.Round(processRatioValue + pollRatioValue + commitRatioValue, 2); // we accept 10% of lost Assert.IsTrue(total >= 0.90d); }
private GraphiteReporter(MetricRegistry registry, GraphiteSender graphite, Clock clock, String prefix, TimeUnit rateUnit, TimeUnit durationUnit, MetricFilter filter) : base(registry, "graphite-reporter", filter, rateUnit, durationUnit) { this.graphite = graphite; this.clock = clock; this.prefix = MetricName.build(prefix); }
public override bool Equals(MetricName other) { return other is MemoryMetricName && Equals((MemoryMetricName)other); }
private void reportTimer(MetricName name, Timer timer, long timestamp) { Snapshot snapshot = timer.Snapshot; graphite.Send(Prefix(name, "max"), format(convertDuration(snapshot.Max)), timestamp); graphite.Send(Prefix(name, "mean"), format(convertDuration(snapshot.Mean)), timestamp); graphite.Send(Prefix(name, "min"), format(convertDuration(snapshot.Min)), timestamp); graphite.Send(Prefix(name, "stddev"), format(convertDuration(snapshot.StdDev)), timestamp); graphite.Send(Prefix(name, "p50"), format(convertDuration(snapshot.Median)), timestamp); graphite.Send(Prefix(name, "p75"), format(convertDuration(snapshot.Percentile75th)), timestamp); graphite.Send(Prefix(name, "p95"), format(convertDuration(snapshot.Percentile95th)), timestamp); graphite.Send(Prefix(name, "p98"), format(convertDuration(snapshot.Percentile98th)), timestamp); graphite.Send(Prefix(name, "p99"), format(convertDuration(snapshot.Percentile99th)), timestamp); graphite.Send(Prefix(name, "p999"), format(convertDuration(snapshot.Percentile999th)), timestamp); reportMetered(name, timer, timestamp); }
public CounterMetricCollector(MetricName name, AtomicCounter counter) : this(name, MetricNames.CounterUnits, counter) { }
private void reportMetered(MetricName name, IMetered meter, long timestamp) { graphite.Send(Prefix(name, "count"), format(meter.Count), timestamp); graphite.Send(Prefix(name, "m1_rate"), format(convertRate(meter.OneMinuteRate)), timestamp); graphite.Send(Prefix(name, "m5_rate"), format(convertRate(meter.FiveMinuteRate)), timestamp); graphite.Send(Prefix(name, "m15_rate"), format(convertRate(meter.FifteenMinuteRate)), timestamp); graphite.Send(Prefix(name, "mean_rate"), format(convertRate(meter.MeanRate)), timestamp); }
public override bool Equals(MetricName other) { return((other is TimingMetricName) && Equals((TimingMetricName)other)); }
private void reportHistogram(MetricName name, Histogram histogram, long timestamp) { Snapshot snapshot = histogram.Snapshot; graphite.Send(Prefix(name, "count"), format(histogram.Count), timestamp); graphite.Send(Prefix(name, "max"), format(snapshot.Max), timestamp); graphite.Send(Prefix(name, "mean"), format(snapshot.Mean), timestamp); graphite.Send(Prefix(name, "min"), format(snapshot.Min), timestamp); graphite.Send(Prefix(name, "stddev"), format(snapshot.StdDev), timestamp); graphite.Send(Prefix(name, "p50"), format(snapshot.Median), timestamp); graphite.Send(Prefix(name, "p75"), format(snapshot.Percentile75th), timestamp); graphite.Send(Prefix(name, "p95"), format(snapshot.Percentile95th), timestamp); graphite.Send(Prefix(name, "p98"), format(snapshot.Percentile98th), timestamp); graphite.Send(Prefix(name, "p99"), format(snapshot.Percentile99th), timestamp); graphite.Send(Prefix(name, "p999"), format(snapshot.Percentile999th), timestamp); }
protected MetricsCollectorSelector(MetricName name) : this(name, SysInfo.Instance) { }
/// <summary> /// Gets a collection of monitoring metrics. /// </summary> /// <param name="service">The monitoring service instance.</param> /// <param name="entityId">The entity ID. This is obtained from <see cref="Entity.Id">Entity.Id</see>.</param> /// <param name="checkId">The check ID. This is obtained from <see cref="Check.Id">Check.Id</see>.</param> /// <param name="marker">A marker identifying the next page of results. This parameter is used for <see href="http://docs.rackspace.com/cm/api/v1.0/cm-devguide/content/api-paginated-collections.html">pagination</see>, and is obtained from <see cref="ReadOnlyCollectionPage{T, TMarker}.NextMarker"/>. If the value is <see langword="null"/>, the list starts at the beginning.</param> /// <param name="limit">The maximum number of items to include in a single page of results. This parameter is used for <see href="http://docs.rackspace.com/cm/api/v1.0/cm-devguide/content/api-paginated-collections.html">pagination</see>. If the value is <see langword="null"/>, a provider-specific default value is used.</param> /// <returns> /// A <see cref="ReadOnlyCollectionPage{T, TMarker}"/> object containing the page /// of results and its associated pagination metadata. /// </returns> /// <exception cref="ArgumentNullException">If <paramref name="service"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentNullException"> /// If <paramref name="entityId"/> is <see langword="null"/>. /// <para>-or-</para> /// <para>If <paramref name="checkId"/> is <see langword="null"/>.</para> /// </exception> /// <exception cref="ArgumentOutOfRangeException">If <paramref name="limit"/> is less than or equal to 0.</exception> /// <exception cref="WebException">If the REST request does not return successfully.</exception> /// <seealso href="http://docs.rackspace.com/cm/api/v1.0/cm-devguide/content/metrics-api.html#list-metrics">List Metrics (Rackspace Cloud Monitoring Developer Guide - API v1.0)</seealso> /// <seealso href="http://docs.rackspace.com/cm/api/v1.0/cm-devguide/content/api-paginated-collections.html">Paginated Collections (Rackspace Cloud Monitoring Developer Guide - API v1.0)</seealso> public static ReadOnlyCollectionPage<Metric, MetricName> ListMetrics(this IMonitoringService service, EntityId entityId, CheckId checkId, MetricName marker, int? limit) { if (service == null) throw new ArgumentNullException("service"); try { return service.ListMetricsAsync(entityId, checkId, marker, limit, CancellationToken.None).Result; } catch (AggregateException ex) { ReadOnlyCollection<Exception> innerExceptions = ex.Flatten().InnerExceptions; if (innerExceptions.Count == 1) throw innerExceptions[0]; throw; } }
private void reportGauge(MetricName name, Gauge gauge, long timestamp) { string value = format(gauge.ValueAsString); if (value != null) { graphite.Send(Prefix(name), value, timestamp); } }
public TestMetricCollector(MetricName name, string unitName) : base(name, unitName) { }
private string Prefix(MetricName name, params String[] components) { return MetricName.join(MetricName.join(this.prefix, name), MetricName.build(components)).Key; }
/// <summary> /// Creates a new <seealso cref="Counter" /> and registers it under the given metric /// name. /// </summary> /// <param name="metricName">the name of the metric</param> /// <returns>a new <seealso cref="Counter" /></returns> public static Counter NewCounter(MetricName metricName) { return DEFAULT_REGISTRY.NewCounter(metricName); }
internal PartitionUsage(UnitType?unit, MetricName name, string quotaPeriod, long?limit, long?currentValue, string partitionId, string partitionKeyRangeId) : base(unit, name, quotaPeriod, limit, currentValue) { PartitionId = partitionId; PartitionKeyRangeId = partitionKeyRangeId; }
/// <summary> /// Creates a new non-biased <seealso cref="Histogram" /> and registers it under the /// given metric name. /// </summary> /// <param name="metricName">the name of the metric</param> /// <returns>a new <seealso cref="Histogram" /></returns> public static Histogram NewHistogram(MetricName metricName) { return NewHistogram(metricName, false); }
public CounterSelector(MetricName name, SysInfo systemInfo) : base(name, systemInfo) { }
private void LogCounter(IRequest request, MetricName metricName, CounterMetric metric, long timestamp) { request.AddCounter(new DatadogCounter(_nameFormatter.Format(metricName.Name, _path), metric.Count, timestamp, _globalTags)); }
public void TaskMetricsTest() { var serdes = new StringSerDes(); var cloneConfig = config.Clone(); cloneConfig.ApplicationId = "consume-test"; var producer = syncKafkaSupplier.GetProducer(cloneConfig.ToProducerConfig()); var consumer = syncKafkaSupplier.GetConsumer(cloneConfig.ToConsumerConfig("test-consum"), null); consumer.Subscribe("topic2"); int nbMessage = 1000; // produce 1000 messages to input topic List <ConsumeResult <byte[], byte[]> > messages = new List <ConsumeResult <byte[], byte[]> >(); int offset = 0; for (int i = 0; i < nbMessage; ++i) { messages.Add( new ConsumeResult <byte[], byte[]> { Message = new Message <byte[], byte[]> { Key = serdes.Serialize($"key{i + 1}", new SerializationContext()), Value = serdes.Serialize($"value{i + 1}", new SerializationContext()) }, TopicPartitionOffset = new TopicPartitionOffset(topicPartition, offset++) }); } task.AddRecords(messages); while (task.CanProcess(DateTime.Now.GetMilliseconds())) { Assert.IsTrue(task.Process()); Assert.IsTrue(task.CommitNeeded); task.Commit(); } var messagesSink = new List <ConsumeResult <byte[], byte[]> >(); AssertExtensions.WaitUntil(() => { messagesSink.AddRange(consumer.ConsumeRecords(TimeSpan.FromSeconds(1))); return(messagesSink.Count < nbMessage); }, TimeSpan.FromSeconds(5), TimeSpan.FromMilliseconds(10)); long now = DateTime.Now.GetMilliseconds(); var sensors = streamMetricsRegistry.GetThreadScopeSensor(threadId); var processorSensor = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(TaskMetrics.PROCESS))); Assert.AreEqual(2, processorSensor.Metrics.Count()); Assert.AreEqual(nbMessage, processorSensor.Metrics[MetricName.NameAndGroup( TaskMetrics.PROCESS + StreamMetricsRegistry.TOTAL_SUFFIX, StreamMetricsRegistry.TASK_LEVEL_GROUP)].Value); Assert.IsTrue( (double)(processorSensor.Metrics[MetricName.NameAndGroup( TaskMetrics.PROCESS + StreamMetricsRegistry.RATE_SUFFIX, StreamMetricsRegistry.TASK_LEVEL_GROUP)].Value) > 0d); var enforcedProcessorSensor = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(TaskMetrics.ENFORCED_PROCESSING))); Assert.AreEqual(2, enforcedProcessorSensor.Metrics.Count()); Assert.AreEqual(0, enforcedProcessorSensor.Metrics[MetricName.NameAndGroup( TaskMetrics.ENFORCED_PROCESSING + StreamMetricsRegistry.TOTAL_SUFFIX, StreamMetricsRegistry.TASK_LEVEL_GROUP)].Value); Assert.AreEqual(0, enforcedProcessorSensor.Metrics[MetricName.NameAndGroup( TaskMetrics.ENFORCED_PROCESSING + StreamMetricsRegistry.RATE_SUFFIX, StreamMetricsRegistry.TASK_LEVEL_GROUP)].Value); var processLatency = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(TaskMetrics.PROCESS_LATENCY))); Assert.AreEqual(2, processLatency.Metrics.Count()); Assert.IsTrue( (double)processLatency.Metrics[MetricName.NameAndGroup( TaskMetrics.PROCESS_LATENCY + StreamMetricsRegistry.AVG_SUFFIX, StreamMetricsRegistry.TASK_LEVEL_GROUP)].Value > 0d); Assert.IsTrue( (double)processLatency.Metrics[MetricName.NameAndGroup( TaskMetrics.PROCESS_LATENCY + StreamMetricsRegistry.MAX_SUFFIX, StreamMetricsRegistry.TASK_LEVEL_GROUP)].Value > 0d); var commitSensor = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(TaskMetrics.COMMIT))); Assert.AreEqual(2, commitSensor.Metrics.Count()); Assert.AreEqual(nbMessage, commitSensor.Metrics[MetricName.NameAndGroup( TaskMetrics.COMMIT + StreamMetricsRegistry.TOTAL_SUFFIX, StreamMetricsRegistry.TASK_LEVEL_GROUP)].Value); Assert.IsTrue( (double)commitSensor.Metrics[MetricName.NameAndGroup( TaskMetrics.COMMIT + StreamMetricsRegistry.RATE_SUFFIX, StreamMetricsRegistry.TASK_LEVEL_GROUP)].Value > 0d); var droppedRecordSensor = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(TaskMetrics.DROPPED_RECORDS))); Assert.AreEqual(2, droppedRecordSensor.Metrics.Count()); Assert.AreEqual(0, droppedRecordSensor.Metrics[MetricName.NameAndGroup( TaskMetrics.DROPPED_RECORDS + StreamMetricsRegistry.TOTAL_SUFFIX, StreamMetricsRegistry.TASK_LEVEL_GROUP)].Value); Assert.AreEqual(0, droppedRecordSensor.Metrics[MetricName.NameAndGroup( TaskMetrics.DROPPED_RECORDS + StreamMetricsRegistry.RATE_SUFFIX, StreamMetricsRegistry.TASK_LEVEL_GROUP)].Value); var activeBufferedRecordSensor = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(TaskMetrics.ACTIVE_TASK_PREFIX + TaskMetrics.BUFFER_COUNT))); Assert.AreEqual(1, activeBufferedRecordSensor.Metrics.Count()); Assert.AreEqual(0, activeBufferedRecordSensor.Metrics[MetricName.NameAndGroup( TaskMetrics.ACTIVE_TASK_PREFIX + TaskMetrics.BUFFER_COUNT, StreamMetricsRegistry.TASK_LEVEL_GROUP)].Value); var restorationRecordsSensor = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(TaskMetrics.RESTORATION_RECORDS))); Assert.AreEqual(1, restorationRecordsSensor.Metrics.Count()); Assert.AreEqual(0, restorationRecordsSensor.Metrics[MetricName.NameAndGroup( TaskMetrics.RESTORATION_RECORDS, StreamMetricsRegistry.TASK_LEVEL_GROUP)].Value); var activeRestorationSensor = sensors.FirstOrDefault(s => s.Name.Equals(GetSensorName(TaskMetrics.ACTIVE_RESTORATION))); Assert.AreEqual(1, activeRestorationSensor.Metrics.Count()); Assert.AreEqual(0, activeRestorationSensor.Metrics[MetricName.NameAndGroup( TaskMetrics.ACTIVE_RESTORATION, StreamMetricsRegistry.TASK_LEVEL_GROUP)].Value); }