Example #1
0
        public async Task DownloadFromApi(CancellationToken cancel)
        {
            //    Daily, monthly costs
            await foreach (var dayData in (await _billingQueryClient.GetDailyData(cancel)).WithCancellation(cancel))
            {
                var dayEnum = DateEnumHelper.ReplaceDateValueToEnums(dayData.GetByColumnName("UsageDate"));

                DailyCosts
                .WithLabels(dayEnum)
                .Set(dayData.Cost);
            }

            await foreach (var dayData in (await _billingQueryClient.GetMonthlyData(cancel)).WithCancellation(cancel))
            {
                var monthEnum = DateEnumHelper.ReplaceDateValueToEnums(dayData.GetByColumnName("BillingMonth"));

                MonthlyCosts
                .WithLabels(monthEnum)
                .Set(dayData.Cost);
            }

            foreach (var(key, _) in _customCollectorConfiguration.CustomGaugeMetrics)
            {
                await foreach (var customData in
                               (await _billingQueryClient.GetCustomData(cancel, key.QueryFilePath)).WithCancellation(cancel))
                {
                    _customCollectorConfiguration.SetValues(key, customData);
                }
            }
        }
        public void DayDateShouldReplacesToTextEnum(string currentDate, string originalDate, string replacedString)
        {
            var today = DateTime.Parse(currentDate);
            var res   = DateEnumHelper.ReplaceDateValueToEnums(originalDate, today);

            StringAssert.AreEqualIgnoringCase(replacedString, res);
        }
Example #3
0
        public void SetValues(MetricConfig key, CostResultRows customData)
        {
            var gauge = CustomGaugeMetrics[key];

            var labelValues = new List <string>();

            labelValues.AddRange(key.StaticLabel.Select(x => x.Value));
            foreach (var keyLabel in key.KeyLabels)
            {
                var dataColumnByKeyLabel = customData.GetByColumnName(keyLabel);

                if (key.ReplaceDateLabelsToEnum)
                {
                    dataColumnByKeyLabel = DateEnumHelper.ReplaceDateValueToEnums(dataColumnByKeyLabel);
                }
                labelValues.Add(dataColumnByKeyLabel);
            }

            gauge
            .WithLabels(labelValues.ToArray())
            .Set(customData.GetValueByColumnName(key.Value));
        }