Exemplo n.º 1
0
        public MetricValueCollectionWrapper Convert(string info)
        {
            var exchanges = JArray.Parse(info);

            var collection = new MetricValueCollectionWrapper();

            foreach (var q in exchanges)
            {
                if (q.SelectToken(MessageStats) == null)
                {
                    continue;
                }

                var exchangeName = q.Value <string>("name");
                if (string.IsNullOrEmpty(exchangeName))
                {
                    continue;
                }

                for (var i = 0; i < PathsWithDetailRate.Length; i++)
                {
                    var pathValue = PathsWithDetailRate[i];
                    collection.Add(q.ValueFromPath <float?>($"{pathValue}"), DimensionTranslations[i], exchangeName);
                    collection.Add(q.ValueFromPath <float?>($"{pathValue}{DetailsRateSuffix}"), DimensionRateTranslations[i], exchangeName);
                }
            }

            return(collection);
        }
        public MetricValueCollectionWrapper Convert(string info)
        {
            var collection = new MetricValueCollectionWrapper();
            var queues     = JArray.Parse(info);

            foreach (var q in queues)
            {
                var qName = q.Value <string>("name");

                for (var i = 0; i < PathsWithDetailRate.Length; i++)
                {
                    var pathValue = PathsWithDetailRate[i];
                    collection.Add(q.ValueFromPath <float?>($"{pathValue}"), StatsDimensionTranslations[i], qName);
                    collection.Add(q.ValueFromPath <float?>($"{pathValue}{DetailsRateSuffix}"), StatsDimensionRateTranslations[i], qName);
                }

                for (var i = 0; i < Paths.Length; i++)
                {
                    var pathValue = Paths[i];
                    collection.Add(q.ValueFromPath <float?>($"{pathValue}"), PathsDimensionTranslations[i], qName);
                }

                for (var i = 0; i < Calculations.Length; i++)
                {
                    Calculations[i](q, collection, qName);
                }
            }

            return(collection);
        }
        /// <summary>
        /// Calculates the delay of the delivery relative to the publishing of the messages and publishes
        /// that value in the passed in metric.
        /// </summary>
        /// <param name="jToken">Token to use to parse.</param>
        /// <param name="collection">The collection to store the value.</param>
        /// <param name="queueName">The queue name of the metric.</param>
        private static void CalculateDeliveryDelay(JToken jToken, MetricValueCollectionWrapper collection, string queueName)
        {
            var deliverRate = jToken.ValueFromPath <float>(MessageStats + ".deliver_get" + DetailsRateSuffix);
            var publishRate = jToken.ValueFromPath <float>(MessageStats + ".publish" + DetailsRateSuffix);

            var relativeDelay = (publishRate > 0) ? Math.Round(1 - (deliverRate / publishRate), 2) : 0;

            collection.Add((float)relativeDelay, CalculationTranslations[(int)CalculationType.DeliveryDelay], queueName);
        }
Exemplo n.º 4
0
        public void When_Calling_TelemetryClient_With_Multiple_Dimensions_Metrics_Are_Accepted(string[] dimensions)
        {
            var metricIdentifier = CreateMetricIdentifier(dimensions);
            var tc                = new TelemetryClient(TelemetryConfiguration.CreateDefault());
            var metric            = tc.GetMetric(metricIdentifier);
            var publisher         = new TelemetryClientPublisher(metric);
            var collectionWrapper = new MetricValueCollectionWrapper();

            collectionWrapper.Add(0, dimensions);

            Assert.DoesNotThrowAsync(async() => await publisher.PublishAsync(collectionWrapper));
        }
Exemplo n.º 5
0
        public MetricValueCollectionWrapper Convert(string info)
        {
            var collection = new MetricValueCollectionWrapper();

            var overviewInfo = JObject.Parse(info);

            for (var i = 0; i < ChurnRatesPaths.Length; i++)
            {
                var path = ChurnRatesPaths[i];
                collection.Add(overviewInfo.ValueFromPath <float?>($"{ChurnRates}.{path}"), DimensionTranslations[i]);
            }

            return(collection);
        }