Skip to content

Commit

Permalink
fixing resharper warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonh-msft committed Mar 28, 2019
1 parent e027b81 commit 3d25c55
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
4 changes: 1 addition & 3 deletions src/Promitor.Core.Scraping/Configuration/Model/Scraping.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace Promitor.Core.Scraping.Configuration.Model
namespace Promitor.Core.Scraping.Configuration.Model
{
public class Scraping
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,25 @@ public virtual MetricsDeclaration Get(bool applyDefaults = false)
}

// Apply the default aggregation interval if none is specified
if (metric.AzureMetricConfiguration?.Aggregation?.Interval == null)
if (metric.AzureMetricConfiguration == null)
{
metric.AzureMetricConfiguration = new AzureMetricConfiguration();
}
if (metric.AzureMetricConfiguration?.Aggregation == null)
{
metric.AzureMetricConfiguration.Aggregation = new MetricAggregation();
}
if (metric.AzureMetricConfiguration?.Aggregation.Interval == null)
{
metric.AzureMetricConfiguration.Aggregation.Interval = config.MetricDefaults.Aggregation.Interval;
}

// Apply the default scraping interval if none is specified
if (metric.Scraping?.Schedule == null)
if (metric.Scraping == null)
{
metric.Scraping = config.MetricDefaults.Scraping;
}

// Apply the default scraping interval if none is specified
if (metric.Scraping.Schedule == null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using GuardNet;
using GuardNet;
using Microsoft.Extensions.Logging;
using Promitor.Core.Scraping.Configuration.Model;
using YamlDotNet.RepresentationModel;
Expand All @@ -21,15 +20,15 @@ internal override MetricDefaults Deserialize(YamlMappingNode node)
if (node.Children.ContainsKey("aggregation"))
{
var metricDefaultsNode = (YamlMappingNode)node.Children[new YamlScalarNode("aggregation")];
var metricDefaultsSerializer = new AggregationDeserializer(this.Logger);
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(this.Logger);
var metricDefaultsSerializer = new ScrapingDeserializer(Logger);
var scraping = metricDefaultsSerializer.Deserialize(metricDefaultsNode);
metricDefaults.Scraping = scraping;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class MetricScraperFactory
/// </summary>
/// <param name="azureMetadata">Metadata concerning the Azure resources</param>
/// <param name="metricDefinitionResourceType">Resource type to scrape</param>
/// <param name="metricDefaults">Default configuration for metrics</param>
/// <param name="logger">General logger</param>
/// <param name="exceptionTracker">Tracker used to log exceptions</param>
public static IScraper<MetricDefinition> CreateScraper(ResourceType metricDefinitionResourceType, AzureMetadata azureMetadata,
Expand Down
4 changes: 2 additions & 2 deletions src/Promitor.Core.Scraping/Scraper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ protected Scraper(AzureMetadata azureMetadata, AzureMonitorClient azureMonitorCl
_logger = logger;
_exceptionTracker = exceptionTracker;

this.AzureMetadata = azureMetadata;
this.AzureMonitorClient = azureMonitorClient;
AzureMetadata = azureMetadata;
AzureMonitorClient = azureMonitorClient;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public MetricsDeclarationValidationStep(IMetricsDeclarationProvider metricsDecla
public ValidationResult Run()
{
var rawMetricsConfiguration = _metricsDeclarationProvider.ReadRawDeclaration();
this.Logger.LogInformation("Following metrics configuration was configured:\n{Configuration}", rawMetricsConfiguration);
Logger.LogInformation("Following metrics configuration was configured:\n{Configuration}", rawMetricsConfiguration);

MetricsDeclaration metricsDeclaration = null;
try
Expand All @@ -42,7 +42,7 @@ public ValidationResult Run()

if (metricsDeclaration == null)
{
return ValidationResult.Failure(this.ComponentName, "Unable to deserialize configured metrics declaration");
return ValidationResult.Failure(ComponentName, "Unable to deserialize configured metrics declaration");
}

var validationErrors = new List<string>();
Expand All @@ -55,7 +55,7 @@ public ValidationResult Run()
var metricsErrorMessages = ValidateMetrics(metricsDeclaration.Metrics, metricsDeclaration.MetricDefaults);
validationErrors.AddRange(metricsErrorMessages);

return validationErrors.Any() ? ValidationResult.Failure(this.ComponentName, validationErrors) : ValidationResult.Successful(this.ComponentName);
return validationErrors.Any() ? ValidationResult.Failure(ComponentName, validationErrors) : ValidationResult.Successful(ComponentName);
}

private static IEnumerable<string> ValidateMetricDefaults(MetricDefaults metricDefaults)
Expand Down

0 comments on commit 3d25c55

Please sign in to comment.