Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): Bump dependencies #2241

Merged
merged 7 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Promitor.Agents.Core/AgentStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected virtual LoggerConfiguration WriteTelemetryToSinks(TelemetryConfigurati
if (appInsightsConfig?.IsEnabled == true)
{
var logLevel = SerilogFactory.DetermineSinkLogLevel(appInsightsConfig.Verbosity);
loggerConfiguration.WriteTo.AzureApplicationInsights(appInsightsConfig.InstrumentationKey, restrictedToMinimumLevel: logLevel);
loggerConfiguration.WriteTo.AzureApplicationInsightsWithInstrumentationKey(appInsightsConfig.InstrumentationKey, restrictedToMinimumLevel: logLevel);
}

var consoleLogConfig = telemetryConfiguration.ContainerLogs;
Expand Down
8 changes: 4 additions & 4 deletions src/Promitor.Agents.Core/Promitor.Agents.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Arcus.Observability.Telemetry.AspNetCore" Version="2.4.0" />
<PackageReference Include="Arcus.Observability.Telemetry.Serilog.Enrichers" Version="2.4.0" />
<PackageReference Include="Arcus.Observability.Telemetry.Serilog.Sinks.ApplicationInsights" Version="2.4.0" />
<PackageReference Include="Arcus.WebApi.Logging" Version="1.5.0" />
<PackageReference Include="Arcus.Observability.Telemetry.AspNetCore" Version="2.8.0" />
<PackageReference Include="Arcus.Observability.Telemetry.Serilog.Enrichers" Version="2.8.0" />
<PackageReference Include="Arcus.Observability.Telemetry.Serilog.Sinks.ApplicationInsights" Version="2.8.0" />
<PackageReference Include="Arcus.WebApi.Logging" Version="1.7.1" />
<PackageReference Include="CronScheduler.AspNetCore" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.2.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public virtual async Task<PagedPayload<AzureResourceDefinition>> GetResourcesAsy
// But only if the current page is 1, or we'll emit it too much
if(currentPage == 1)
{
_logger.LogMetric("Discovered Resources", unparsedResults.TotalRecords, contextualInformation);
_logger.LogCustomMetric("Discovered Resources", unparsedResults.TotalRecords, contextualInformation);
}

return new PagedPayload<AzureResourceDefinition>(foundResources, unparsedResults.TotalRecords, unparsedResults.CurrentPage, unparsedResults.PageSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Arcus.Observability.Telemetry.Core" Version="2.4.0" />
<PackageReference Include="Arcus.Observability.Telemetry.Core" Version="2.8.0" />
<PackageReference Include="Guard.NET" Version="3.0.0" />
<PackageReference Include="Microsoft.Azure.Management.ResourceGraph" Version="2.1.0" />
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="2.2.0" />
<PackageReference Include="Polly" Version="7.2.3" />

<!-- Explicitly pin dependencies on container project to mitigate security vulnerabilities -->
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="System.Security.Cryptography.Xml" Version="7.0.1" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>
Expand Down
30 changes: 14 additions & 16 deletions src/Promitor.Agents.Scraper/Discovery/ResourceDiscoveryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,25 @@ private async Task<string> SendGetRequestAsync(string uriPath)

private async Task<HttpResponseMessage> SendRequestToApiAsync(HttpRequestMessage request)
{
using (var dependencyMeasurement = DurationMeasurement.Start())
using var durationMeasurement = DurationMeasurement.Start();
HttpResponseMessage response = null;
try
{
response = await _httpClient.SendAsync(request);
_logger.LogRequest(request, response, durationMeasurement);

return response;
}
finally
{
HttpResponseMessage response = null;
try
{
response = await _httpClient.SendAsync(request);
_logger.LogRequest(request, response, dependencyMeasurement.Elapsed);

return response;
var statusCode = response?.StatusCode ?? HttpStatusCode.InternalServerError;
_logger.LogHttpDependency(request, statusCode, durationMeasurement);
}
finally
catch (Exception ex)
{
try
{
var statusCode = response?.StatusCode ?? HttpStatusCode.InternalServerError;
_logger.LogHttpDependency(request, statusCode, dependencyMeasurement);
}
catch (Exception ex)
{
_logger.LogWarning("Failed to log HTTP dependency. Reason: {Message}", ex.Message);
}
_logger.LogWarning("Failed to log HTTP dependency. Reason: {Message}", ex.Message);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static IServiceCollection AddResourceDiscoveryClient(this IServiceCollect

var resourceDiscoveryConfiguration = configuration.Get<ScraperRuntimeConfiguration>();

if(resourceDiscoveryConfiguration.ResourceDiscovery?.IsConfigured == true)
if(resourceDiscoveryConfiguration?.ResourceDiscovery?.IsConfigured == true)
{
services.AddHttpClient<ResourceDiscoveryClient>(client =>
{
Expand Down Expand Up @@ -231,12 +231,13 @@ private static void AddOpenTelemetryCollectorMetricSink(string collectorUri, str
var resourceBuilder = ResourceBuilder.CreateDefault()
.AddService(OpenTelemetryServiceName, serviceVersion: agentVersion);

services.AddOpenTelemetryMetrics(metricsBuilder =>
{
metricsBuilder.SetResourceBuilder(resourceBuilder)
.AddMeter("Promitor.Scraper.Metrics.AzureMonitor")
.AddOtlpExporter(options => options.Endpoint = new Uri(collectorUri));
});
services.AddOpenTelemetry()
.WithMetrics(metricsBuilder =>
{
metricsBuilder.SetResourceBuilder(resourceBuilder)
.AddMeter("Promitor.Scraper.Metrics.AzureMonitor")
.AddOtlpExporter(options => options.Endpoint = new Uri(collectorUri));
});
services.AddTransient<IMetricSink, OpenTelemetryCollectorMetricSink>();
services.AddTransient<OpenTelemetryCollectorMetricSink>();
services.AddOpenTelemetrySystemMetrics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@
<PackageReference Include="CronExpressionDescriptor" Version="2.19.0" />
<PackageReference Include="Microsoft.Azure.Kusto.Language" Version="11.2.2" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="YamlDotNet" Version="13.0.1" />

<!-- Explicitly pin dependencies on container project to mitigate security vulnerabilities -->
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="System.Security.Cryptography.Xml" Version="7.0.1" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="YamlDotNet" Version="13.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.3.2" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc9.9" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.4.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.4.0" />
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 4 additions & 5 deletions src/Promitor.Tests.Integration/Clients/AgentClient.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using System.Threading.Tasks;
using Arcus.Observability.Telemetry.Core;
using GuardNet;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -52,12 +52,11 @@ public async Task<HttpResponseMessage> GetSystemInfoAsync()
protected async Task<HttpResponseMessage> GetAsync(string uri)
{
var request = new HttpRequestMessage(HttpMethod.Get, uri);

var stopwatch = Stopwatch.StartNew();
var response = await HttpClient.SendAsync(request);
stopwatch.Stop();

var context = new Dictionary<string, object>();

using var durationMeasurement = DurationMeasurement.Start();
try
{
await response.Content.ReadAsStringAsync();
Expand All @@ -66,7 +65,7 @@ protected async Task<HttpResponseMessage> GetAsync(string uri)
}
finally
{
Logger.LogRequest(request, response, stopwatch.Elapsed, context);
Logger.LogRequest(request, response, durationMeasurement, context);
}

return response;
Expand Down
10 changes: 4 additions & 6 deletions src/Promitor.Tests.Integration/Clients/PrometheusClient.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Arcus.Observability.Telemetry.Core;
using GuardNet;
using Microsoft.Extensions.Logging;
using Polly;
Expand Down Expand Up @@ -105,11 +105,9 @@ private async Task<Gauge> WaitForPrometheusMetricAsync(Predicate<Gauge> filter)
protected async Task<HttpResponseMessage> GetAsync(string uri)
{
var request = new HttpRequestMessage(HttpMethod.Get, uri);

var stopwatch = Stopwatch.StartNew();
var response = await HttpClient.SendAsync(request);
stopwatch.Stop();


using var durationMeasurement = DurationMeasurement.Start();
var context = new Dictionary<string, object>();
try
{
Expand All @@ -119,7 +117,7 @@ protected async Task<HttpResponseMessage> GetAsync(string uri)
}
finally
{
Logger.LogRequest(request, response, stopwatch.Elapsed, context);
Logger.LogRequest(request, response, durationMeasurement, context);
}

return response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Arcus.Observability.Telemetry.Core" Version="2.4.0" />
<PackageReference Include="Arcus.Observability.Telemetry.Core" Version="2.8.0" />
<PackageReference Include="Arcus.Testing.Logging" Version="0.5.0" />
<PackageReference Include="Bogus" Version="34.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Polly" Version="7.2.3" />
<PackageReference Include="Promitor.Parsers.Prometheus.Http" Version="0.2.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ public async Task ReportMetricAsync_GetsValidInputWithMetricValueAndTimestampFla
}

[Theory]
[InlineData(0)]
[InlineData(-1)]
[InlineData((double)0)]
[InlineData((double)-1)]
[InlineData(null)]
public async Task ReportMetricAsync_GetsValidInputWithoutMetricValue_SuccessfullyWritesMetricWithDefault(double? expectedDefaultValue)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Promitor.Tests.Unit/Promitor.Tests.Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<PackageReference Include="JetBrains.DotMemoryUnit" Version="3.2.20220510" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
</ItemGroup>

Expand Down