Skip to content

Commit

Permalink
more style fixes :(
Browse files Browse the repository at this point in the history
  • Loading branch information
hkfgo committed Sep 26, 2024
1 parent 5d38684 commit b3eb049
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public string BuildBatchHashKey()
/// </summary>
public bool Equals(ScrapeDefinitionBatchProperties obj)
{
if (obj is null || !(obj is ScrapeDefinitionBatchProperties))
if (!(obj is ScrapeDefinitionBatchProperties))

Check warning on line 98 in src/Promitor.Core.Scraping/Configuration/Model/Metrics/ScrapeDefinitionBatchProperties.cs

View workflow job for this annotation

GitHub Actions / Code Quality (R#)

"[ConvertTypeCheckToNullCheck] Use null check instead of a type check succeeding on any not-null value" on /home/runner/work/promitor/promitor/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ScrapeDefinitionBatchProperties.cs(98,4119)
return false;

ScrapeDefinitionBatchProperties other = obj;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Promitor.Core.Scraping.Configuration.Model;
using Promitor.Core.Serialization.Enum;

namespace Promitor.Core.Scraping.Configuration.Serialization.v1.Model
Expand Down
3 changes: 0 additions & 3 deletions src/Promitor.Core.Scraping/LogAnalyticsScraper.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using GuardNet;
using Microsoft.VisualBasic;
using Promitor.Core.Contracts;
using Promitor.Core.Contracts.ResourceTypes;
using Promitor.Core.Metrics;
Expand Down Expand Up @@ -55,7 +53,6 @@ private Dictionary<string, string> DetermineMetricLabels(LogAnalyticsResourceDef

protected override async Task<List<ScrapeResult>> BatchScrapeResourceAsync(string subscriptionId, BatchScrapeDefinition<IAzureResourceDefinition> batchScrapeDefinition, PromitorMetricAggregationType aggregationType, TimeSpan aggregationInterval)
{
// TODO: these just dispatch and await on tasks that do single-resource scraping. Implement integration with Log Analytics batch endpoint
var logScrapingTasks = batchScrapeDefinition.ScrapeDefinitions.Select(definition => ScrapeResourceAsync(subscriptionId, definition, (LogAnalyticsResourceDefinition) definition.Resource, aggregationType, aggregationInterval)).ToList();

var resultsList = await Task.WhenAll(logScrapingTasks);
Expand Down
1 change: 1 addition & 0 deletions src/Promitor.Core/Extensions/MeasureMetricExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Promitor.Core.Extensions
{
public static class MeasuredMetricExtensions
{
/// <param name="measuredMetric">A time series value</param>
/// <param name="resourceId">Resource ID to associate the metric with</param>
/// <returns>Instance of MeasuredMetric subclass with resourceId attached</returns>
public static ResourceAssociatedMeasuredMetric WithResourceIdAssociation(this MeasuredMetric measuredMetric, string resourceId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
using Azure.Core.Diagnostics;
using System.Diagnostics.Tracing;
using Promitor.Integrations.AzureMonitor.Extensions;
using System.Globalization;

namespace Promitor.Integrations.AzureMonitor
{
Expand Down Expand Up @@ -302,7 +301,7 @@ private MetricsClient CreateAzureMonitorMetricsBatchClient(AzureCloud azureCloud
public static string InsertRegionIntoUrl(string region, string baseUrl)
{
// Find the position where ".metrics" starts in the URL
int metricsIndex = baseUrl.IndexOf("metrics", System.StringComparison.Ordinal);
int metricsIndex = baseUrl.IndexOf("metrics", StringComparison.Ordinal);

// Split the base URL into two parts: before and after the ".metrics"
string beforeMetrics = baseUrl.Substring(0, metricsIndex);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using Azure.Core;

namespace Promitor.Integrations.AzureMonitor.Configuration
{
public class AzureMonitorMetricBatchScrapeConfig
{
public bool Enabled { get; set; } = false;

Check warning on line 5 in src/Promitor.Integrations.AzureMonitor/Configuration/AzureMonitorMetricBatchScrapeConfig.cs

View workflow job for this annotation

GitHub Actions / Code Quality (R#)

"[RedundantDefaultMemberInitializer] Initializing property by default value is redundant" on /home/runner/work/promitor/promitor/src/Promitor.Integrations.AzureMonitor/Configuration/AzureMonitorMetricBatchScrapeConfig.cs(5,162)
public int MaxBatchSize { get; set; }
public string AzureRegion { get; set; } = "eastus"; // Batch scrape endpoints are deployed by region
public string AzureRegion { get; set; } // Batch scrape endpoints are deployed by region
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Core.Pipeline;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ public void BuildBatchHashKeyDifferentResultDifferentSchedule()
[Fact]
public void BuildBatchHashKeyTest()
{
AzureMetricConfigurationV1 _azureMetricConfigurationTest1 = new AzureMetricConfigurationV1
AzureMetricConfigurationV1 azureMetricConfigurationTest1 = new AzureMetricConfigurationV1
{
MetricName = "availabilityResults/availabilityPercentage",
Aggregation = new MetricAggregationV1
{
Type = PromitorMetricAggregationType.Average
},
};
AzureMetricConfigurationV1 _azureMetricConfigurationTest2 = new AzureMetricConfigurationV1
AzureMetricConfigurationV1 azureMetricConfigurationTest2 = new AzureMetricConfigurationV1
{
MetricName = "availabilityResults/availabilityPercentage",
Dimensions = [new MetricDimensionV1{Name = "availabilityResult/name"}],
Expand All @@ -186,8 +186,8 @@ public void BuildBatchHashKeyTest()
Type = PromitorMetricAggregationType.Average
},
};
var azureMetricConfiguration1 = _mapper.Map<AzureMetricConfiguration>(_azureMetricConfigurationTest1);
var azureMetricConfiguration2 = _mapper.Map<AzureMetricConfiguration>(_azureMetricConfigurationTest2);
var azureMetricConfiguration1 = _mapper.Map<AzureMetricConfiguration>(azureMetricConfigurationTest1);
var azureMetricConfiguration2 = _mapper.Map<AzureMetricConfiguration>(azureMetricConfigurationTest2);

var scraping1 = _mapper.Map<Promitor.Core.Scraping.Configuration.Model.Scraping>(scrapingBase);
var scraping2 = _mapper.Map<Promitor.Core.Scraping.Configuration.Model.Scraping>(scrapingBase);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading;
using AutoMapper;
using Promitor.Core.Contracts;
using Promitor.Core.Metrics;
Expand All @@ -12,7 +11,7 @@
using Promitor.Core.Scraping.Configuration.Serialization.v1.Model;
using Xunit;

namespace Promitor.Tests.Unit.Core.Metrics
namespace Promitor.Tests.Unit.Core.Scraping.Batching
{
[Category("Unit")]
public class AzureResourceDefinitionBatchingTests
Expand Down

0 comments on commit b3eb049

Please sign in to comment.