internal override MetricDefaults Deserialize(YamlMappingNode node)
        {
            Guard.NotNull(node, nameof(node));

            Aggregation aggregation = null;

            if (node.Children.ContainsKey("aggregation"))
            {
                var metricDefaultsNode       = (YamlMappingNode)node.Children[new YamlScalarNode("aggregation")];
                var metricDefaultsSerializer = new AggregationDeserializer(Logger);
                aggregation = metricDefaultsSerializer.Deserialize(metricDefaultsNode);
            }

            return(new MetricDefaults
            {
                Aggregation = aggregation
            });
        }
Beispiel #2
0
        internal override MetricDefaults Deserialize(YamlMappingNode node)
        {
            Guard.NotNull(node, nameof(node));

            var metricDefaults = new MetricDefaults();

            if (node.Children.ContainsKey("aggregation"))
            {
                var metricDefaultsNode       = (YamlMappingNode)node.Children[new YamlScalarNode("aggregation")];
                var metricDefaultsSerializer = new AggregationDeserializer(Logger);
                var aggregation = metricDefaultsSerializer.Deserialize(metricDefaultsNode);
                metricDefaults.Aggregation = aggregation;
            }

            if (node.Children.ContainsKey(@"scraping"))
            {
                var metricDefaultsNode       = (YamlMappingNode)node.Children[new YamlScalarNode("scraping")];
                var metricDefaultsSerializer = new ScrapingDeserializer(Logger);
                var scraping = metricDefaultsSerializer.Deserialize(metricDefaultsNode);
                metricDefaults.Scraping = scraping;
            }

            return(metricDefaults);
        }
        internal override MetricDefaults Deserialize(YamlMappingNode node)
        {
            Guard.NotNull(node, nameof(node));

            var metricDefaults = new MetricDefaults();

            if (node.Children.ContainsKey("aggregation"))
            {
                var metricDefaultsNode       = (YamlMappingNode)node.Children[new YamlScalarNode("aggregation")];
                var metricDefaultsSerializer = new AggregationDeserializer(Logger);
                var aggregation = metricDefaultsSerializer.Deserialize(metricDefaultsNode);
                metricDefaults.Aggregation = aggregation;
            }

            if (node.Children.ContainsKey(@"scraping"))
            {
                var scrapingNode = (YamlMappingNode)node.Children[new YamlScalarNode(@"scraping")];
                try
                {
                    var scrapingIntervalNode = scrapingNode.Children[new YamlScalarNode(@"interval")];

                    if (scrapingIntervalNode != null)
                    {
                        var scrapingIntervalTimeSpan = TimeSpan.Parse(scrapingIntervalNode.ToString());
                        metricDefaults.Scraping.Interval = scrapingIntervalTimeSpan;
                    }
                }
                catch (KeyNotFoundException)
                {
                    // happens when the YAML doesn't have the properties in it which is fine because the object
                    // will get a default interval of 'null'
                }
            }

            return(metricDefaults);
        }