From a25f882ba5cf25ec643eb9a2c60c230fc4eb16e9 Mon Sep 17 00:00:00 2001 From: Phong Nguyen Date: Wed, 17 Jul 2024 15:15:56 +0700 Subject: [PATCH] (#244) OpenTelemetry with Azure --- .../ClassifiedAds.Infrastructure.csproj | 1 + .../Logging/ApplicationInsightsOptions.cs | 8 --- .../Logging/EventLogOptions.cs | 10 ---- .../Logging/FileOptions.cs | 8 --- .../Logging/LoggingExtensions.cs | 50 +++++++++++++++---- .../Logging/LoggingOptions.cs | 49 +++++++++++++++++- .../Logging/OpenTelemetryOptions.cs | 15 ------ .../OpenTelemetry/OpenTelemetryExtensions.cs | 19 ++++++- .../OpenTelemetry/OpenTelemetryOptions.cs | 9 ++++ .../appsettings.Development.json | 1 + .../appsettings.Development.json | 1 + .../appsettings.Development.json | 1 + .../appsettings.Development.json | 1 + .../appsettings.Development.json | 1 + .../appsettings.Development.json | 1 + .../appsettings.Development.json | 1 + .../appsettings.Development.json | 1 + .../appsettings.Development.json | 1 + .../appsettings.Development.json | 1 + .../appsettings.Development.json | 1 + .../appsettings.Development.json | 1 + .../ClassifiedAds.Infrastructure.csproj | 1 + .../Logging/ApplicationInsightsOptions.cs | 8 --- .../Logging/EventLogOptions.cs | 10 ---- .../Logging/FileOptions.cs | 8 --- .../Logging/LoggingExtensions.cs | 50 +++++++++++++++---- .../Logging/LoggingOptions.cs | 49 +++++++++++++++++- .../Logging/OpenTelemetryOptions.cs | 15 ------ .../OpenTelemetry/OpenTelemetryExtensions.cs | 19 ++++++- .../OpenTelemetry/OpenTelemetryOptions.cs | 9 ++++ .../appsettings.Development.json | 1 + .../ClassifiedAds.WebAPI/appsettings.json | 1 + .../ClassifiedAds.Infrastructure.csproj | 1 + .../Logging/ApplicationInsightsOptions.cs | 8 --- .../Logging/EventLogOptions.cs | 10 ---- .../Logging/FileOptions.cs | 8 --- .../Logging/LoggingExtensions.cs | 50 +++++++++++++++---- .../Logging/LoggingOptions.cs | 49 +++++++++++++++++- .../Logging/OpenTelemetryOptions.cs | 15 ------ .../OpenTelemetry/OpenTelemetryExtensions.cs | 19 ++++++- .../OpenTelemetry/OpenTelemetryOptions.cs | 9 ++++ .../appsettings.Development.json | 1 + .../ClassifiedAds.WebAPI/appsettings.json | 9 ++++ .../appsettings.Development.json | 1 + .../ClassifiedAds.WebMVC/appsettings.json | 9 ++++ 45 files changed, 379 insertions(+), 162 deletions(-) delete mode 100644 src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/ApplicationInsightsOptions.cs delete mode 100644 src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/EventLogOptions.cs delete mode 100644 src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/FileOptions.cs delete mode 100644 src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/OpenTelemetryOptions.cs delete mode 100644 src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/ApplicationInsightsOptions.cs delete mode 100644 src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/EventLogOptions.cs delete mode 100644 src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/FileOptions.cs delete mode 100644 src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/OpenTelemetryOptions.cs delete mode 100644 src/Monolith/ClassifiedAds.Infrastructure/Logging/ApplicationInsightsOptions.cs delete mode 100644 src/Monolith/ClassifiedAds.Infrastructure/Logging/EventLogOptions.cs delete mode 100644 src/Monolith/ClassifiedAds.Infrastructure/Logging/FileOptions.cs delete mode 100644 src/Monolith/ClassifiedAds.Infrastructure/Logging/OpenTelemetryOptions.cs diff --git a/src/Microservices/Common/ClassifiedAds.Infrastructure/ClassifiedAds.Infrastructure.csproj b/src/Microservices/Common/ClassifiedAds.Infrastructure/ClassifiedAds.Infrastructure.csproj index 659edc8cb..daade822b 100644 --- a/src/Microservices/Common/ClassifiedAds.Infrastructure/ClassifiedAds.Infrastructure.csproj +++ b/src/Microservices/Common/ClassifiedAds.Infrastructure/ClassifiedAds.Infrastructure.csproj @@ -16,6 +16,7 @@ + diff --git a/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/ApplicationInsightsOptions.cs b/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/ApplicationInsightsOptions.cs deleted file mode 100644 index ea2bf37aa..000000000 --- a/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/ApplicationInsightsOptions.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace ClassifiedAds.Infrastructure.Logging; - -public class ApplicationInsightsOptions -{ - public bool IsEnabled { get; set; } - - public string InstrumentationKey { get; set; } -} diff --git a/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/EventLogOptions.cs b/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/EventLogOptions.cs deleted file mode 100644 index 5e11b9008..000000000 --- a/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/EventLogOptions.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ClassifiedAds.Infrastructure.Logging; - -public class EventLogOptions -{ - public bool IsEnabled { get; set; } - - public string LogName { get; set; } - - public string SourceName { get; set; } -} diff --git a/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/FileOptions.cs b/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/FileOptions.cs deleted file mode 100644 index f279c8b44..000000000 --- a/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/FileOptions.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Serilog.Events; - -namespace ClassifiedAds.Infrastructure.Logging; - -public class FileOptions -{ - public LogEventLevel MinimumLogEventLevel { get; set; } -} diff --git a/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/LoggingExtensions.cs b/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/LoggingExtensions.cs index d2ab3685c..d96cac4b7 100644 --- a/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/LoggingExtensions.cs +++ b/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/LoggingExtensions.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Hosting; +using Azure.Monitor.OpenTelemetry.Exporter; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; @@ -10,6 +11,7 @@ using Serilog.Exceptions; using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using System.Reflection; @@ -54,6 +56,7 @@ private static void UseClassifiedAdsLogger(this IWebHostEnvironment env, Logging return false; }) .WriteTo.File(Path.Combine(logsPath, "log.txt"), + formatProvider: CultureInfo.InvariantCulture, fileSizeLimitBytes: 10 * 1024 * 1024, rollOnFileSizeLimit: true, shared: true, @@ -77,12 +80,12 @@ private static LoggingOptions SetDefault(LoggingOptions options) options.LogLevel["Default"] = "Warning"; } - options.File ??= new FileOptions + options.File ??= new LoggingOptions.FileOptions { MinimumLogEventLevel = Serilog.Events.LogEventLevel.Warning, }; - options.EventLog ??= new EventLogOptions + options.EventLog ??= new LoggingOptions.EventLogOptions { IsEnabled = false, }; @@ -143,11 +146,23 @@ public static IWebHostBuilder UseClassifiedAdsLogger(this IWebHostBuilder builde logging.AddOpenTelemetry(configure => { - configure.SetResourceBuilder(resourceBuilder) - .AddOtlpExporter(otlpOptions => + configure.SetResourceBuilder(resourceBuilder); + + if (options?.OpenTelemetry?.Otlp?.IsEnabled ?? false) + { + configure.AddOtlpExporter(otlpOptions => + { + otlpOptions.Endpoint = new Uri(options.OpenTelemetry.Otlp.Endpoint); + }); + } + + if (options?.OpenTelemetry?.AzureMonitor?.IsEnabled ?? false) { - otlpOptions.Endpoint = new Uri(options.OpenTelemetry.Otlp.Endpoint); - }); + configure.AddAzureMonitorLogExporter(opts => + { + opts.ConnectionString = options.OpenTelemetry.AzureMonitor.ConnectionString; + }); + } }); } @@ -197,11 +212,23 @@ public static IHostBuilder UseClassifiedAdsLogger(this IHostBuilder builder, Fun logging.AddOpenTelemetry(configure => { - configure.SetResourceBuilder(resourceBuilder) - .AddOtlpExporter(otlpOptions => + configure.SetResourceBuilder(resourceBuilder); + + if (options?.OpenTelemetry?.Otlp?.IsEnabled ?? false) + { + configure.AddOtlpExporter(otlpOptions => + { + otlpOptions.Endpoint = new Uri(options.OpenTelemetry.Otlp.Endpoint); + }); + } + + if (options?.OpenTelemetry?.AzureMonitor?.IsEnabled ?? false) { - otlpOptions.Endpoint = new Uri(options.OpenTelemetry.Otlp.Endpoint); - }); + configure.AddAzureMonitorLogExporter(opts => + { + opts.ConnectionString = options.OpenTelemetry.AzureMonitor.ConnectionString; + }); + } }); } @@ -246,6 +273,7 @@ private static void UseClassifiedAdsLogger(this IHostEnvironment env, LoggingOpt return false; }) .WriteTo.File(Path.Combine(logsPath, "log.txt"), + formatProvider: CultureInfo.InvariantCulture, fileSizeLimitBytes: 10 * 1024 * 1024, rollOnFileSizeLimit: true, shared: true, diff --git a/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/LoggingOptions.cs b/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/LoggingOptions.cs index 9c64bfdcd..8a6ea1de9 100644 --- a/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/LoggingOptions.cs +++ b/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/LoggingOptions.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using Serilog.Events; +using System.Collections.Generic; namespace ClassifiedAds.Infrastructure.Logging; @@ -13,4 +14,50 @@ public class LoggingOptions public ApplicationInsightsOptions ApplicationInsights { get; set; } public OpenTelemetryOptions OpenTelemetry { get; set; } + + public class FileOptions + { + public LogEventLevel MinimumLogEventLevel { get; set; } + } + + public class EventLogOptions + { + public bool IsEnabled { get; set; } + + public string LogName { get; set; } + + public string SourceName { get; set; } + } + + public class ApplicationInsightsOptions + { + public bool IsEnabled { get; set; } + + public string InstrumentationKey { get; set; } + } + + public class OpenTelemetryOptions + { + public bool IsEnabled { get; set; } + + public string ServiceName { get; set; } + + public OtlpOptions Otlp { get; set; } + + public AzureMonitorOptions AzureMonitor { get; set; } + + public class OtlpOptions + { + public bool IsEnabled { get; set; } + + public string Endpoint { get; set; } + } + + public class AzureMonitorOptions + { + public bool IsEnabled { get; set; } + + public string ConnectionString { get; set; } + } + } } diff --git a/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/OpenTelemetryOptions.cs b/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/OpenTelemetryOptions.cs deleted file mode 100644 index 68dbc1155..000000000 --- a/src/Microservices/Common/ClassifiedAds.Infrastructure/Logging/OpenTelemetryOptions.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace ClassifiedAds.Infrastructure.Logging; - -public class OpenTelemetryOptions -{ - public bool IsEnabled { get; set; } - - public string ServiceName { get; set; } - - public OtlpOptions Otlp { get; set; } -} - -public class OtlpOptions -{ - public string Endpoint { get; set; } -} diff --git a/src/Microservices/Common/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryExtensions.cs b/src/Microservices/Common/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryExtensions.cs index 9a7ed8dea..bb1afb423 100644 --- a/src/Microservices/Common/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryExtensions.cs +++ b/src/Microservices/Common/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryExtensions.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.DependencyInjection; +using Azure.Monitor.OpenTelemetry.Exporter; +using Microsoft.Extensions.DependencyInjection; using OpenTelemetry.Metrics; using OpenTelemetry.Resources; using OpenTelemetry.Trace; @@ -47,6 +48,14 @@ public static IServiceCollection AddClassifiedAdsOpenTelemetry(this IServiceColl otlpOptions.Endpoint = new Uri(options.Otlp.Endpoint); }); } + + if (options?.AzureMonitor?.IsEnabled ?? false) + { + builder.AddAzureMonitorTraceExporter(opts => + { + opts.ConnectionString = options.AzureMonitor.ConnectionString; + }); + } }) .WithMetrics(builder => { @@ -63,6 +72,14 @@ public static IServiceCollection AddClassifiedAdsOpenTelemetry(this IServiceColl otlpOptions.Endpoint = new Uri(options.Otlp.Endpoint); }); } + + if (options?.AzureMonitor?.IsEnabled ?? false) + { + builder.AddAzureMonitorMetricExporter(opts => + { + opts.ConnectionString = options.AzureMonitor.ConnectionString; + }); + } }); return services; diff --git a/src/Microservices/Common/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryOptions.cs b/src/Microservices/Common/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryOptions.cs index 27ee0c97b..0bcef84d0 100644 --- a/src/Microservices/Common/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryOptions.cs +++ b/src/Microservices/Common/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryOptions.cs @@ -9,6 +9,8 @@ public class OpenTelemetryOptions public ZipkinOptions Zipkin { get; set; } public OtlpOptions Otlp { get; set; } + + public AzureMonitorOptions AzureMonitor { get; set; } } public class ZipkinOptions @@ -24,3 +26,10 @@ public class OtlpOptions public string Endpoint { get; set; } } + +public class AzureMonitorOptions +{ + public bool IsEnabled { get; set; } + + public string ConnectionString { get; set; } +} diff --git a/src/Microservices/Gateways.GraphQL/ClassifiedAds.Gateways.GraphQL/appsettings.Development.json b/src/Microservices/Gateways.GraphQL/ClassifiedAds.Gateways.GraphQL/appsettings.Development.json index 5a6cf690a..3ac9e4dbc 100644 --- a/src/Microservices/Gateways.GraphQL/ClassifiedAds.Gateways.GraphQL/appsettings.Development.json +++ b/src/Microservices/Gateways.GraphQL/ClassifiedAds.Gateways.GraphQL/appsettings.Development.json @@ -9,6 +9,7 @@ "IsEnabled": true, "ServiceName": "ClassifiedAds.Gateways.GraphQL", "Otlp": { + "IsEnabled": true, "Endpoint": "https://localhost:21052" } } diff --git a/src/Microservices/Gateways.WebAPI/ClassifiedAds.Gateways.WebAPI/appsettings.Development.json b/src/Microservices/Gateways.WebAPI/ClassifiedAds.Gateways.WebAPI/appsettings.Development.json index 42d71c1ca..bdac2e857 100644 --- a/src/Microservices/Gateways.WebAPI/ClassifiedAds.Gateways.WebAPI/appsettings.Development.json +++ b/src/Microservices/Gateways.WebAPI/ClassifiedAds.Gateways.WebAPI/appsettings.Development.json @@ -9,6 +9,7 @@ "IsEnabled": true, "ServiceName": "ClassifiedAds.Gateways.WebAPI", "Otlp": { + "IsEnabled": true, "Endpoint": "https://localhost:21052" } } diff --git a/src/Microservices/Services.AuditLog/ClassifiedAds.Services.AuditLog.Api/appsettings.Development.json b/src/Microservices/Services.AuditLog/ClassifiedAds.Services.AuditLog.Api/appsettings.Development.json index 780092b2d..f9b86e10c 100644 --- a/src/Microservices/Services.AuditLog/ClassifiedAds.Services.AuditLog.Api/appsettings.Development.json +++ b/src/Microservices/Services.AuditLog/ClassifiedAds.Services.AuditLog.Api/appsettings.Development.json @@ -9,6 +9,7 @@ "IsEnabled": true, "ServiceName": "ClassifiedAds.Services.AuditLog.Api", "Otlp": { + "IsEnabled": true, "Endpoint": "https://localhost:21052" } } diff --git a/src/Microservices/Services.AuditLog/ClassifiedAds.Services.AuditLog.Grpc/appsettings.Development.json b/src/Microservices/Services.AuditLog/ClassifiedAds.Services.AuditLog.Grpc/appsettings.Development.json index 0d0533e24..7fe89d66d 100644 --- a/src/Microservices/Services.AuditLog/ClassifiedAds.Services.AuditLog.Grpc/appsettings.Development.json +++ b/src/Microservices/Services.AuditLog/ClassifiedAds.Services.AuditLog.Grpc/appsettings.Development.json @@ -9,6 +9,7 @@ "IsEnabled": true, "ServiceName": "ClassifiedAds.Services.AuditLog.Grpc", "Otlp": { + "IsEnabled": true, "Endpoint": "https://localhost:21052" } } diff --git a/src/Microservices/Services.Configuration/ClassifiedAds.Services.Configuration.Api/appsettings.Development.json b/src/Microservices/Services.Configuration/ClassifiedAds.Services.Configuration.Api/appsettings.Development.json index 19fd5933e..2b87ba512 100644 --- a/src/Microservices/Services.Configuration/ClassifiedAds.Services.Configuration.Api/appsettings.Development.json +++ b/src/Microservices/Services.Configuration/ClassifiedAds.Services.Configuration.Api/appsettings.Development.json @@ -9,6 +9,7 @@ "IsEnabled": true, "ServiceName": "ClassifiedAds.Services.Configuration.Api", "Otlp": { + "IsEnabled": true, "Endpoint": "https://localhost:21052" } } diff --git a/src/Microservices/Services.Identity/ClassifiedAds.Services.Identity.Api/appsettings.Development.json b/src/Microservices/Services.Identity/ClassifiedAds.Services.Identity.Api/appsettings.Development.json index 35e855430..193fc3cb4 100644 --- a/src/Microservices/Services.Identity/ClassifiedAds.Services.Identity.Api/appsettings.Development.json +++ b/src/Microservices/Services.Identity/ClassifiedAds.Services.Identity.Api/appsettings.Development.json @@ -9,6 +9,7 @@ "IsEnabled": true, "ServiceName": "ClassifiedAds.Services.Identity.Api", "Otlp": { + "IsEnabled": true, "Endpoint": "https://localhost:21052" } } diff --git a/src/Microservices/Services.Identity/ClassifiedAds.Services.Identity.Grpc/appsettings.Development.json b/src/Microservices/Services.Identity/ClassifiedAds.Services.Identity.Grpc/appsettings.Development.json index 0c32bc8a2..009e5774b 100644 --- a/src/Microservices/Services.Identity/ClassifiedAds.Services.Identity.Grpc/appsettings.Development.json +++ b/src/Microservices/Services.Identity/ClassifiedAds.Services.Identity.Grpc/appsettings.Development.json @@ -9,6 +9,7 @@ "IsEnabled": true, "ServiceName": "ClassifiedAds.Services.Identity.Grpc", "Otlp": { + "IsEnabled": true, "Endpoint": "https://localhost:21052" } } diff --git a/src/Microservices/Services.Notification/ClassifiedAds.Services.Notification.Api/appsettings.Development.json b/src/Microservices/Services.Notification/ClassifiedAds.Services.Notification.Api/appsettings.Development.json index 60697b5da..a7e0b7180 100644 --- a/src/Microservices/Services.Notification/ClassifiedAds.Services.Notification.Api/appsettings.Development.json +++ b/src/Microservices/Services.Notification/ClassifiedAds.Services.Notification.Api/appsettings.Development.json @@ -9,6 +9,7 @@ "IsEnabled": true, "ServiceName": "ClassifiedAds.Services.Notification.Api", "Otlp": { + "IsEnabled": true, "Endpoint": "https://localhost:21052" } } diff --git a/src/Microservices/Services.Notification/ClassifiedAds.Services.Notification.Background/appsettings.Development.json b/src/Microservices/Services.Notification/ClassifiedAds.Services.Notification.Background/appsettings.Development.json index 83c590671..9a7b9082a 100644 --- a/src/Microservices/Services.Notification/ClassifiedAds.Services.Notification.Background/appsettings.Development.json +++ b/src/Microservices/Services.Notification/ClassifiedAds.Services.Notification.Background/appsettings.Development.json @@ -9,6 +9,7 @@ "IsEnabled": true, "ServiceName": "ClassifiedAds.Services.Notification.Background", "Otlp": { + "IsEnabled": true, "Endpoint": "https://localhost:21052" } } diff --git a/src/Microservices/Services.Notification/ClassifiedAds.Services.Notification.Grpc/appsettings.Development.json b/src/Microservices/Services.Notification/ClassifiedAds.Services.Notification.Grpc/appsettings.Development.json index 8a0a5525b..3f754a4ad 100644 --- a/src/Microservices/Services.Notification/ClassifiedAds.Services.Notification.Grpc/appsettings.Development.json +++ b/src/Microservices/Services.Notification/ClassifiedAds.Services.Notification.Grpc/appsettings.Development.json @@ -9,6 +9,7 @@ "IsEnabled": true, "ServiceName": "ClassifiedAds.Services.Notification.Grpc", "Otlp": { + "IsEnabled": true, "Endpoint": "https://localhost:21052" } } diff --git a/src/Microservices/Services.Product/ClassifiedAds.Services.Product.Api/appsettings.Development.json b/src/Microservices/Services.Product/ClassifiedAds.Services.Product.Api/appsettings.Development.json index 9e834f3d4..5ad3f61d6 100644 --- a/src/Microservices/Services.Product/ClassifiedAds.Services.Product.Api/appsettings.Development.json +++ b/src/Microservices/Services.Product/ClassifiedAds.Services.Product.Api/appsettings.Development.json @@ -9,6 +9,7 @@ "IsEnabled": true, "ServiceName": "ClassifiedAds.Services.Product.Api", "Otlp": { + "IsEnabled": true, "Endpoint": "https://localhost:21052" } } diff --git a/src/Microservices/Services.Storage/ClassifiedAds.Services.Storage.Api/appsettings.Development.json b/src/Microservices/Services.Storage/ClassifiedAds.Services.Storage.Api/appsettings.Development.json index f9086e9c8..be4bb0ff5 100644 --- a/src/Microservices/Services.Storage/ClassifiedAds.Services.Storage.Api/appsettings.Development.json +++ b/src/Microservices/Services.Storage/ClassifiedAds.Services.Storage.Api/appsettings.Development.json @@ -9,6 +9,7 @@ "IsEnabled": true, "ServiceName": "ClassifiedAds.Services.Storage.Api", "Otlp": { + "IsEnabled": true, "Endpoint": "https://localhost:21052" } } diff --git a/src/ModularMonolith/ClassifiedAds.Infrastructure/ClassifiedAds.Infrastructure.csproj b/src/ModularMonolith/ClassifiedAds.Infrastructure/ClassifiedAds.Infrastructure.csproj index 659edc8cb..daade822b 100644 --- a/src/ModularMonolith/ClassifiedAds.Infrastructure/ClassifiedAds.Infrastructure.csproj +++ b/src/ModularMonolith/ClassifiedAds.Infrastructure/ClassifiedAds.Infrastructure.csproj @@ -16,6 +16,7 @@ + diff --git a/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/ApplicationInsightsOptions.cs b/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/ApplicationInsightsOptions.cs deleted file mode 100644 index ea2bf37aa..000000000 --- a/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/ApplicationInsightsOptions.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace ClassifiedAds.Infrastructure.Logging; - -public class ApplicationInsightsOptions -{ - public bool IsEnabled { get; set; } - - public string InstrumentationKey { get; set; } -} diff --git a/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/EventLogOptions.cs b/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/EventLogOptions.cs deleted file mode 100644 index 5e11b9008..000000000 --- a/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/EventLogOptions.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ClassifiedAds.Infrastructure.Logging; - -public class EventLogOptions -{ - public bool IsEnabled { get; set; } - - public string LogName { get; set; } - - public string SourceName { get; set; } -} diff --git a/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/FileOptions.cs b/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/FileOptions.cs deleted file mode 100644 index f279c8b44..000000000 --- a/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/FileOptions.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Serilog.Events; - -namespace ClassifiedAds.Infrastructure.Logging; - -public class FileOptions -{ - public LogEventLevel MinimumLogEventLevel { get; set; } -} diff --git a/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/LoggingExtensions.cs b/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/LoggingExtensions.cs index d2ab3685c..d96cac4b7 100644 --- a/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/LoggingExtensions.cs +++ b/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/LoggingExtensions.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Hosting; +using Azure.Monitor.OpenTelemetry.Exporter; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; @@ -10,6 +11,7 @@ using Serilog.Exceptions; using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using System.Reflection; @@ -54,6 +56,7 @@ private static void UseClassifiedAdsLogger(this IWebHostEnvironment env, Logging return false; }) .WriteTo.File(Path.Combine(logsPath, "log.txt"), + formatProvider: CultureInfo.InvariantCulture, fileSizeLimitBytes: 10 * 1024 * 1024, rollOnFileSizeLimit: true, shared: true, @@ -77,12 +80,12 @@ private static LoggingOptions SetDefault(LoggingOptions options) options.LogLevel["Default"] = "Warning"; } - options.File ??= new FileOptions + options.File ??= new LoggingOptions.FileOptions { MinimumLogEventLevel = Serilog.Events.LogEventLevel.Warning, }; - options.EventLog ??= new EventLogOptions + options.EventLog ??= new LoggingOptions.EventLogOptions { IsEnabled = false, }; @@ -143,11 +146,23 @@ public static IWebHostBuilder UseClassifiedAdsLogger(this IWebHostBuilder builde logging.AddOpenTelemetry(configure => { - configure.SetResourceBuilder(resourceBuilder) - .AddOtlpExporter(otlpOptions => + configure.SetResourceBuilder(resourceBuilder); + + if (options?.OpenTelemetry?.Otlp?.IsEnabled ?? false) + { + configure.AddOtlpExporter(otlpOptions => + { + otlpOptions.Endpoint = new Uri(options.OpenTelemetry.Otlp.Endpoint); + }); + } + + if (options?.OpenTelemetry?.AzureMonitor?.IsEnabled ?? false) { - otlpOptions.Endpoint = new Uri(options.OpenTelemetry.Otlp.Endpoint); - }); + configure.AddAzureMonitorLogExporter(opts => + { + opts.ConnectionString = options.OpenTelemetry.AzureMonitor.ConnectionString; + }); + } }); } @@ -197,11 +212,23 @@ public static IHostBuilder UseClassifiedAdsLogger(this IHostBuilder builder, Fun logging.AddOpenTelemetry(configure => { - configure.SetResourceBuilder(resourceBuilder) - .AddOtlpExporter(otlpOptions => + configure.SetResourceBuilder(resourceBuilder); + + if (options?.OpenTelemetry?.Otlp?.IsEnabled ?? false) + { + configure.AddOtlpExporter(otlpOptions => + { + otlpOptions.Endpoint = new Uri(options.OpenTelemetry.Otlp.Endpoint); + }); + } + + if (options?.OpenTelemetry?.AzureMonitor?.IsEnabled ?? false) { - otlpOptions.Endpoint = new Uri(options.OpenTelemetry.Otlp.Endpoint); - }); + configure.AddAzureMonitorLogExporter(opts => + { + opts.ConnectionString = options.OpenTelemetry.AzureMonitor.ConnectionString; + }); + } }); } @@ -246,6 +273,7 @@ private static void UseClassifiedAdsLogger(this IHostEnvironment env, LoggingOpt return false; }) .WriteTo.File(Path.Combine(logsPath, "log.txt"), + formatProvider: CultureInfo.InvariantCulture, fileSizeLimitBytes: 10 * 1024 * 1024, rollOnFileSizeLimit: true, shared: true, diff --git a/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/LoggingOptions.cs b/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/LoggingOptions.cs index 9c64bfdcd..8a6ea1de9 100644 --- a/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/LoggingOptions.cs +++ b/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/LoggingOptions.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using Serilog.Events; +using System.Collections.Generic; namespace ClassifiedAds.Infrastructure.Logging; @@ -13,4 +14,50 @@ public class LoggingOptions public ApplicationInsightsOptions ApplicationInsights { get; set; } public OpenTelemetryOptions OpenTelemetry { get; set; } + + public class FileOptions + { + public LogEventLevel MinimumLogEventLevel { get; set; } + } + + public class EventLogOptions + { + public bool IsEnabled { get; set; } + + public string LogName { get; set; } + + public string SourceName { get; set; } + } + + public class ApplicationInsightsOptions + { + public bool IsEnabled { get; set; } + + public string InstrumentationKey { get; set; } + } + + public class OpenTelemetryOptions + { + public bool IsEnabled { get; set; } + + public string ServiceName { get; set; } + + public OtlpOptions Otlp { get; set; } + + public AzureMonitorOptions AzureMonitor { get; set; } + + public class OtlpOptions + { + public bool IsEnabled { get; set; } + + public string Endpoint { get; set; } + } + + public class AzureMonitorOptions + { + public bool IsEnabled { get; set; } + + public string ConnectionString { get; set; } + } + } } diff --git a/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/OpenTelemetryOptions.cs b/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/OpenTelemetryOptions.cs deleted file mode 100644 index 68dbc1155..000000000 --- a/src/ModularMonolith/ClassifiedAds.Infrastructure/Logging/OpenTelemetryOptions.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace ClassifiedAds.Infrastructure.Logging; - -public class OpenTelemetryOptions -{ - public bool IsEnabled { get; set; } - - public string ServiceName { get; set; } - - public OtlpOptions Otlp { get; set; } -} - -public class OtlpOptions -{ - public string Endpoint { get; set; } -} diff --git a/src/ModularMonolith/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryExtensions.cs b/src/ModularMonolith/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryExtensions.cs index 9a7ed8dea..bb1afb423 100644 --- a/src/ModularMonolith/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryExtensions.cs +++ b/src/ModularMonolith/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryExtensions.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.DependencyInjection; +using Azure.Monitor.OpenTelemetry.Exporter; +using Microsoft.Extensions.DependencyInjection; using OpenTelemetry.Metrics; using OpenTelemetry.Resources; using OpenTelemetry.Trace; @@ -47,6 +48,14 @@ public static IServiceCollection AddClassifiedAdsOpenTelemetry(this IServiceColl otlpOptions.Endpoint = new Uri(options.Otlp.Endpoint); }); } + + if (options?.AzureMonitor?.IsEnabled ?? false) + { + builder.AddAzureMonitorTraceExporter(opts => + { + opts.ConnectionString = options.AzureMonitor.ConnectionString; + }); + } }) .WithMetrics(builder => { @@ -63,6 +72,14 @@ public static IServiceCollection AddClassifiedAdsOpenTelemetry(this IServiceColl otlpOptions.Endpoint = new Uri(options.Otlp.Endpoint); }); } + + if (options?.AzureMonitor?.IsEnabled ?? false) + { + builder.AddAzureMonitorMetricExporter(opts => + { + opts.ConnectionString = options.AzureMonitor.ConnectionString; + }); + } }); return services; diff --git a/src/ModularMonolith/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryOptions.cs b/src/ModularMonolith/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryOptions.cs index 27ee0c97b..0bcef84d0 100644 --- a/src/ModularMonolith/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryOptions.cs +++ b/src/ModularMonolith/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryOptions.cs @@ -9,6 +9,8 @@ public class OpenTelemetryOptions public ZipkinOptions Zipkin { get; set; } public OtlpOptions Otlp { get; set; } + + public AzureMonitorOptions AzureMonitor { get; set; } } public class ZipkinOptions @@ -24,3 +26,10 @@ public class OtlpOptions public string Endpoint { get; set; } } + +public class AzureMonitorOptions +{ + public bool IsEnabled { get; set; } + + public string ConnectionString { get; set; } +} diff --git a/src/ModularMonolith/ClassifiedAds.WebAPI/appsettings.Development.json b/src/ModularMonolith/ClassifiedAds.WebAPI/appsettings.Development.json index 70869dd6b..12fa81433 100644 --- a/src/ModularMonolith/ClassifiedAds.WebAPI/appsettings.Development.json +++ b/src/ModularMonolith/ClassifiedAds.WebAPI/appsettings.Development.json @@ -9,6 +9,7 @@ "IsEnabled": true, "ServiceName": "ClassifiedAds.WebAPI", "Otlp": { + "IsEnabled": true, "Endpoint": "https://localhost:21052" } } diff --git a/src/ModularMonolith/ClassifiedAds.WebAPI/appsettings.json b/src/ModularMonolith/ClassifiedAds.WebAPI/appsettings.json index 333ba32fb..0b76d20be 100644 --- a/src/ModularMonolith/ClassifiedAds.WebAPI/appsettings.json +++ b/src/ModularMonolith/ClassifiedAds.WebAPI/appsettings.json @@ -35,6 +35,7 @@ "IsEnabled": false, "ServiceName": "ClassifiedAds.WebAPI", "Otlp": { + "IsEnabled": false, "Endpoint": "http://localhost:4317" } } diff --git a/src/Monolith/ClassifiedAds.Infrastructure/ClassifiedAds.Infrastructure.csproj b/src/Monolith/ClassifiedAds.Infrastructure/ClassifiedAds.Infrastructure.csproj index 28fd631fc..8778f7f77 100644 --- a/src/Monolith/ClassifiedAds.Infrastructure/ClassifiedAds.Infrastructure.csproj +++ b/src/Monolith/ClassifiedAds.Infrastructure/ClassifiedAds.Infrastructure.csproj @@ -17,6 +17,7 @@ + diff --git a/src/Monolith/ClassifiedAds.Infrastructure/Logging/ApplicationInsightsOptions.cs b/src/Monolith/ClassifiedAds.Infrastructure/Logging/ApplicationInsightsOptions.cs deleted file mode 100644 index ea2bf37aa..000000000 --- a/src/Monolith/ClassifiedAds.Infrastructure/Logging/ApplicationInsightsOptions.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace ClassifiedAds.Infrastructure.Logging; - -public class ApplicationInsightsOptions -{ - public bool IsEnabled { get; set; } - - public string InstrumentationKey { get; set; } -} diff --git a/src/Monolith/ClassifiedAds.Infrastructure/Logging/EventLogOptions.cs b/src/Monolith/ClassifiedAds.Infrastructure/Logging/EventLogOptions.cs deleted file mode 100644 index 5e11b9008..000000000 --- a/src/Monolith/ClassifiedAds.Infrastructure/Logging/EventLogOptions.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ClassifiedAds.Infrastructure.Logging; - -public class EventLogOptions -{ - public bool IsEnabled { get; set; } - - public string LogName { get; set; } - - public string SourceName { get; set; } -} diff --git a/src/Monolith/ClassifiedAds.Infrastructure/Logging/FileOptions.cs b/src/Monolith/ClassifiedAds.Infrastructure/Logging/FileOptions.cs deleted file mode 100644 index f279c8b44..000000000 --- a/src/Monolith/ClassifiedAds.Infrastructure/Logging/FileOptions.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Serilog.Events; - -namespace ClassifiedAds.Infrastructure.Logging; - -public class FileOptions -{ - public LogEventLevel MinimumLogEventLevel { get; set; } -} diff --git a/src/Monolith/ClassifiedAds.Infrastructure/Logging/LoggingExtensions.cs b/src/Monolith/ClassifiedAds.Infrastructure/Logging/LoggingExtensions.cs index d2ab3685c..d96cac4b7 100644 --- a/src/Monolith/ClassifiedAds.Infrastructure/Logging/LoggingExtensions.cs +++ b/src/Monolith/ClassifiedAds.Infrastructure/Logging/LoggingExtensions.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Hosting; +using Azure.Monitor.OpenTelemetry.Exporter; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; @@ -10,6 +11,7 @@ using Serilog.Exceptions; using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using System.Reflection; @@ -54,6 +56,7 @@ private static void UseClassifiedAdsLogger(this IWebHostEnvironment env, Logging return false; }) .WriteTo.File(Path.Combine(logsPath, "log.txt"), + formatProvider: CultureInfo.InvariantCulture, fileSizeLimitBytes: 10 * 1024 * 1024, rollOnFileSizeLimit: true, shared: true, @@ -77,12 +80,12 @@ private static LoggingOptions SetDefault(LoggingOptions options) options.LogLevel["Default"] = "Warning"; } - options.File ??= new FileOptions + options.File ??= new LoggingOptions.FileOptions { MinimumLogEventLevel = Serilog.Events.LogEventLevel.Warning, }; - options.EventLog ??= new EventLogOptions + options.EventLog ??= new LoggingOptions.EventLogOptions { IsEnabled = false, }; @@ -143,11 +146,23 @@ public static IWebHostBuilder UseClassifiedAdsLogger(this IWebHostBuilder builde logging.AddOpenTelemetry(configure => { - configure.SetResourceBuilder(resourceBuilder) - .AddOtlpExporter(otlpOptions => + configure.SetResourceBuilder(resourceBuilder); + + if (options?.OpenTelemetry?.Otlp?.IsEnabled ?? false) + { + configure.AddOtlpExporter(otlpOptions => + { + otlpOptions.Endpoint = new Uri(options.OpenTelemetry.Otlp.Endpoint); + }); + } + + if (options?.OpenTelemetry?.AzureMonitor?.IsEnabled ?? false) { - otlpOptions.Endpoint = new Uri(options.OpenTelemetry.Otlp.Endpoint); - }); + configure.AddAzureMonitorLogExporter(opts => + { + opts.ConnectionString = options.OpenTelemetry.AzureMonitor.ConnectionString; + }); + } }); } @@ -197,11 +212,23 @@ public static IHostBuilder UseClassifiedAdsLogger(this IHostBuilder builder, Fun logging.AddOpenTelemetry(configure => { - configure.SetResourceBuilder(resourceBuilder) - .AddOtlpExporter(otlpOptions => + configure.SetResourceBuilder(resourceBuilder); + + if (options?.OpenTelemetry?.Otlp?.IsEnabled ?? false) + { + configure.AddOtlpExporter(otlpOptions => + { + otlpOptions.Endpoint = new Uri(options.OpenTelemetry.Otlp.Endpoint); + }); + } + + if (options?.OpenTelemetry?.AzureMonitor?.IsEnabled ?? false) { - otlpOptions.Endpoint = new Uri(options.OpenTelemetry.Otlp.Endpoint); - }); + configure.AddAzureMonitorLogExporter(opts => + { + opts.ConnectionString = options.OpenTelemetry.AzureMonitor.ConnectionString; + }); + } }); } @@ -246,6 +273,7 @@ private static void UseClassifiedAdsLogger(this IHostEnvironment env, LoggingOpt return false; }) .WriteTo.File(Path.Combine(logsPath, "log.txt"), + formatProvider: CultureInfo.InvariantCulture, fileSizeLimitBytes: 10 * 1024 * 1024, rollOnFileSizeLimit: true, shared: true, diff --git a/src/Monolith/ClassifiedAds.Infrastructure/Logging/LoggingOptions.cs b/src/Monolith/ClassifiedAds.Infrastructure/Logging/LoggingOptions.cs index 9c64bfdcd..8a6ea1de9 100644 --- a/src/Monolith/ClassifiedAds.Infrastructure/Logging/LoggingOptions.cs +++ b/src/Monolith/ClassifiedAds.Infrastructure/Logging/LoggingOptions.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using Serilog.Events; +using System.Collections.Generic; namespace ClassifiedAds.Infrastructure.Logging; @@ -13,4 +14,50 @@ public class LoggingOptions public ApplicationInsightsOptions ApplicationInsights { get; set; } public OpenTelemetryOptions OpenTelemetry { get; set; } + + public class FileOptions + { + public LogEventLevel MinimumLogEventLevel { get; set; } + } + + public class EventLogOptions + { + public bool IsEnabled { get; set; } + + public string LogName { get; set; } + + public string SourceName { get; set; } + } + + public class ApplicationInsightsOptions + { + public bool IsEnabled { get; set; } + + public string InstrumentationKey { get; set; } + } + + public class OpenTelemetryOptions + { + public bool IsEnabled { get; set; } + + public string ServiceName { get; set; } + + public OtlpOptions Otlp { get; set; } + + public AzureMonitorOptions AzureMonitor { get; set; } + + public class OtlpOptions + { + public bool IsEnabled { get; set; } + + public string Endpoint { get; set; } + } + + public class AzureMonitorOptions + { + public bool IsEnabled { get; set; } + + public string ConnectionString { get; set; } + } + } } diff --git a/src/Monolith/ClassifiedAds.Infrastructure/Logging/OpenTelemetryOptions.cs b/src/Monolith/ClassifiedAds.Infrastructure/Logging/OpenTelemetryOptions.cs deleted file mode 100644 index 68dbc1155..000000000 --- a/src/Monolith/ClassifiedAds.Infrastructure/Logging/OpenTelemetryOptions.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace ClassifiedAds.Infrastructure.Logging; - -public class OpenTelemetryOptions -{ - public bool IsEnabled { get; set; } - - public string ServiceName { get; set; } - - public OtlpOptions Otlp { get; set; } -} - -public class OtlpOptions -{ - public string Endpoint { get; set; } -} diff --git a/src/Monolith/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryExtensions.cs b/src/Monolith/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryExtensions.cs index 9a7ed8dea..bb1afb423 100644 --- a/src/Monolith/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryExtensions.cs +++ b/src/Monolith/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryExtensions.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.DependencyInjection; +using Azure.Monitor.OpenTelemetry.Exporter; +using Microsoft.Extensions.DependencyInjection; using OpenTelemetry.Metrics; using OpenTelemetry.Resources; using OpenTelemetry.Trace; @@ -47,6 +48,14 @@ public static IServiceCollection AddClassifiedAdsOpenTelemetry(this IServiceColl otlpOptions.Endpoint = new Uri(options.Otlp.Endpoint); }); } + + if (options?.AzureMonitor?.IsEnabled ?? false) + { + builder.AddAzureMonitorTraceExporter(opts => + { + opts.ConnectionString = options.AzureMonitor.ConnectionString; + }); + } }) .WithMetrics(builder => { @@ -63,6 +72,14 @@ public static IServiceCollection AddClassifiedAdsOpenTelemetry(this IServiceColl otlpOptions.Endpoint = new Uri(options.Otlp.Endpoint); }); } + + if (options?.AzureMonitor?.IsEnabled ?? false) + { + builder.AddAzureMonitorMetricExporter(opts => + { + opts.ConnectionString = options.AzureMonitor.ConnectionString; + }); + } }); return services; diff --git a/src/Monolith/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryOptions.cs b/src/Monolith/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryOptions.cs index 27ee0c97b..0bcef84d0 100644 --- a/src/Monolith/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryOptions.cs +++ b/src/Monolith/ClassifiedAds.Infrastructure/Monitoring/OpenTelemetry/OpenTelemetryOptions.cs @@ -9,6 +9,8 @@ public class OpenTelemetryOptions public ZipkinOptions Zipkin { get; set; } public OtlpOptions Otlp { get; set; } + + public AzureMonitorOptions AzureMonitor { get; set; } } public class ZipkinOptions @@ -24,3 +26,10 @@ public class OtlpOptions public string Endpoint { get; set; } } + +public class AzureMonitorOptions +{ + public bool IsEnabled { get; set; } + + public string ConnectionString { get; set; } +} diff --git a/src/Monolith/ClassifiedAds.WebAPI/appsettings.Development.json b/src/Monolith/ClassifiedAds.WebAPI/appsettings.Development.json index 70869dd6b..12fa81433 100644 --- a/src/Monolith/ClassifiedAds.WebAPI/appsettings.Development.json +++ b/src/Monolith/ClassifiedAds.WebAPI/appsettings.Development.json @@ -9,6 +9,7 @@ "IsEnabled": true, "ServiceName": "ClassifiedAds.WebAPI", "Otlp": { + "IsEnabled": true, "Endpoint": "https://localhost:21052" } } diff --git a/src/Monolith/ClassifiedAds.WebAPI/appsettings.json b/src/Monolith/ClassifiedAds.WebAPI/appsettings.json index ef455ddc6..73ad9b03d 100644 --- a/src/Monolith/ClassifiedAds.WebAPI/appsettings.json +++ b/src/Monolith/ClassifiedAds.WebAPI/appsettings.json @@ -38,7 +38,12 @@ "IsEnabled": false, "ServiceName": "ClassifiedAds.WebAPI", "Otlp": { + "IsEnabled": false, "Endpoint": "http://localhost:4317" + }, + "AzureMonitor": { + "IsEnabled": false, + "ConnectionString": "xxx" } } }, @@ -83,6 +88,10 @@ "Otlp": { "IsEnabled": false, "Endpoint": "http://localhost:4317" + }, + "AzureMonitor": { + "IsEnabled": false, + "ConnectionString": "xxx" } } }, diff --git a/src/Monolith/ClassifiedAds.WebMVC/appsettings.Development.json b/src/Monolith/ClassifiedAds.WebMVC/appsettings.Development.json index 73404f070..2b2d49dc8 100644 --- a/src/Monolith/ClassifiedAds.WebMVC/appsettings.Development.json +++ b/src/Monolith/ClassifiedAds.WebMVC/appsettings.Development.json @@ -9,6 +9,7 @@ "IsEnabled": true, "ServiceName": "ClassifiedAds.WebMVC", "Otlp": { + "IsEnabled": true, "Endpoint": "https://localhost:21052" } } diff --git a/src/Monolith/ClassifiedAds.WebMVC/appsettings.json b/src/Monolith/ClassifiedAds.WebMVC/appsettings.json index 2350ef71e..ecac35d7b 100644 --- a/src/Monolith/ClassifiedAds.WebMVC/appsettings.json +++ b/src/Monolith/ClassifiedAds.WebMVC/appsettings.json @@ -44,7 +44,12 @@ "IsEnabled": false, "ServiceName": "ClassifiedAds.WebMVC", "Otlp": { + "IsEnabled": false, "Endpoint": "http://localhost:4317" + }, + "AzureMonitor": { + "IsEnabled": false, + "ConnectionString": "xxx" } } }, @@ -81,6 +86,10 @@ "Otlp": { "IsEnabled": false, "Endpoint": "http://localhost:4317" + }, + "AzureMonitor": { + "IsEnabled": false, + "ConnectionString": "xxx" } } },