diff --git a/src/Promitor.Agents.Core/AgentStartup.cs b/src/Promitor.Agents.Core/AgentStartup.cs
index 25d01efda..cc5c73d10 100644
--- a/src/Promitor.Agents.Core/AgentStartup.cs
+++ b/src/Promitor.Agents.Core/AgentStartup.cs
@@ -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;
diff --git a/src/Promitor.Agents.Core/Promitor.Agents.Core.csproj b/src/Promitor.Agents.Core/Promitor.Agents.Core.csproj
index 8d124f716..065f6f396 100644
--- a/src/Promitor.Agents.Core/Promitor.Agents.Core.csproj
+++ b/src/Promitor.Agents.Core/Promitor.Agents.Core.csproj
@@ -14,10 +14,10 @@
-
-
-
-
+
+
+
+
diff --git a/src/Promitor.Agents.ResourceDiscovery/Graph/Repositories/AzureResourceRepository.cs b/src/Promitor.Agents.ResourceDiscovery/Graph/Repositories/AzureResourceRepository.cs
index 770466ee1..89961f88a 100644
--- a/src/Promitor.Agents.ResourceDiscovery/Graph/Repositories/AzureResourceRepository.cs
+++ b/src/Promitor.Agents.ResourceDiscovery/Graph/Repositories/AzureResourceRepository.cs
@@ -71,7 +71,7 @@ public virtual async Task> 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(foundResources, unparsedResults.TotalRecords, unparsedResults.CurrentPage, unparsedResults.PageSize);
diff --git a/src/Promitor.Agents.ResourceDiscovery/Promitor.Agents.ResourceDiscovery.csproj b/src/Promitor.Agents.ResourceDiscovery/Promitor.Agents.ResourceDiscovery.csproj
index e77741ce3..bab8be8f7 100644
--- a/src/Promitor.Agents.ResourceDiscovery/Promitor.Agents.ResourceDiscovery.csproj
+++ b/src/Promitor.Agents.ResourceDiscovery/Promitor.Agents.ResourceDiscovery.csproj
@@ -31,7 +31,7 @@
-
+
@@ -39,6 +39,9 @@
+
+
+
diff --git a/src/Promitor.Agents.Scraper/Discovery/ResourceDiscoveryClient.cs b/src/Promitor.Agents.Scraper/Discovery/ResourceDiscoveryClient.cs
index cd56ef315..447f59dd2 100644
--- a/src/Promitor.Agents.Scraper/Discovery/ResourceDiscoveryClient.cs
+++ b/src/Promitor.Agents.Scraper/Discovery/ResourceDiscoveryClient.cs
@@ -63,27 +63,25 @@ private async Task SendGetRequestAsync(string uriPath)
private async Task 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);
}
}
}
diff --git a/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs b/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs
index aea3cc2a5..6f26ebbdd 100644
--- a/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs
+++ b/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs
@@ -63,7 +63,7 @@ public static IServiceCollection AddResourceDiscoveryClient(this IServiceCollect
var resourceDiscoveryConfiguration = configuration.Get();
- if(resourceDiscoveryConfiguration.ResourceDiscovery?.IsConfigured == true)
+ if(resourceDiscoveryConfiguration?.ResourceDiscovery?.IsConfigured == true)
{
services.AddHttpClient(client =>
{
@@ -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();
services.AddTransient();
services.AddOpenTelemetrySystemMetrics();
diff --git a/src/Promitor.Agents.Scraper/Promitor.Agents.Scraper.csproj b/src/Promitor.Agents.Scraper/Promitor.Agents.Scraper.csproj
index 1e84ba418..ba1945b31 100644
--- a/src/Promitor.Agents.Scraper/Promitor.Agents.Scraper.csproj
+++ b/src/Promitor.Agents.Scraper/Promitor.Agents.Scraper.csproj
@@ -40,9 +40,12 @@
+
+
+
+
-
diff --git a/src/Promitor.Integrations.Sinks.OpenTelemetry/Promitor.Integrations.Sinks.OpenTelemetry.csproj b/src/Promitor.Integrations.Sinks.OpenTelemetry/Promitor.Integrations.Sinks.OpenTelemetry.csproj
index 8a4105b61..fe1423a2a 100644
--- a/src/Promitor.Integrations.Sinks.OpenTelemetry/Promitor.Integrations.Sinks.OpenTelemetry.csproj
+++ b/src/Promitor.Integrations.Sinks.OpenTelemetry/Promitor.Integrations.Sinks.OpenTelemetry.csproj
@@ -14,8 +14,8 @@
-
-
+
+
diff --git a/src/Promitor.Tests.Integration/Clients/AgentClient.cs b/src/Promitor.Tests.Integration/Clients/AgentClient.cs
index 19c06a7ea..cd6fde9b0 100644
--- a/src/Promitor.Tests.Integration/Clients/AgentClient.cs
+++ b/src/Promitor.Tests.Integration/Clients/AgentClient.cs
@@ -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;
@@ -52,12 +52,11 @@ public async Task GetSystemInfoAsync()
protected async Task 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();
+
+ using var durationMeasurement = DurationMeasurement.Start();
try
{
await response.Content.ReadAsStringAsync();
@@ -66,7 +65,7 @@ protected async Task GetAsync(string uri)
}
finally
{
- Logger.LogRequest(request, response, stopwatch.Elapsed, context);
+ Logger.LogRequest(request, response, durationMeasurement, context);
}
return response;
diff --git a/src/Promitor.Tests.Integration/Clients/PrometheusClient.cs b/src/Promitor.Tests.Integration/Clients/PrometheusClient.cs
index 624ff04cf..6a717f61d 100644
--- a/src/Promitor.Tests.Integration/Clients/PrometheusClient.cs
+++ b/src/Promitor.Tests.Integration/Clients/PrometheusClient.cs
@@ -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;
@@ -105,11 +105,9 @@ private async Task WaitForPrometheusMetricAsync(Predicate filter)
protected async Task 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();
try
{
@@ -119,7 +117,7 @@ protected async Task GetAsync(string uri)
}
finally
{
- Logger.LogRequest(request, response, stopwatch.Elapsed, context);
+ Logger.LogRequest(request, response, durationMeasurement, context);
}
return response;
diff --git a/src/Promitor.Tests.Integration/Promitor.Tests.Integration.csproj b/src/Promitor.Tests.Integration/Promitor.Tests.Integration.csproj
index f794e440a..178f9105a 100644
--- a/src/Promitor.Tests.Integration/Promitor.Tests.Integration.csproj
+++ b/src/Promitor.Tests.Integration/Promitor.Tests.Integration.csproj
@@ -15,14 +15,14 @@
-
+
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/Promitor.Tests.Unit/Metrics/Sinks/PrometheusScrapingEndpointMetricSinkTests.cs b/src/Promitor.Tests.Unit/Metrics/Sinks/PrometheusScrapingEndpointMetricSinkTests.cs
index a61230e35..350822d51 100644
--- a/src/Promitor.Tests.Unit/Metrics/Sinks/PrometheusScrapingEndpointMetricSinkTests.cs
+++ b/src/Promitor.Tests.Unit/Metrics/Sinks/PrometheusScrapingEndpointMetricSinkTests.cs
@@ -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)
{
diff --git a/src/Promitor.Tests.Unit/Promitor.Tests.Unit.csproj b/src/Promitor.Tests.Unit/Promitor.Tests.Unit.csproj
index a9cbaf8d2..1f44280af 100644
--- a/src/Promitor.Tests.Unit/Promitor.Tests.Unit.csproj
+++ b/src/Promitor.Tests.Unit/Promitor.Tests.Unit.csproj
@@ -40,7 +40,7 @@
-
+