From f5c328f3d5a54f28e69801234a6449d9dec1bb85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Tom=C3=A1s?= Date: Fri, 6 Oct 2017 10:33:24 +0200 Subject: [PATCH] Added eventflow to apps and Services Added eventflow k8s settings Added eventflow sf win settings --- .env | 1 + .../BasketApiPkg/ServiceManifest.xml | 1 + .../CatalogApiPkg/ServiceManifest.xml | 1 + .../LocationsApiPkg/ServiceManifest.xml | 1 + .../MarketingApiPkg/ServiceManifest.xml | 1 + .../OrderingApiPkg/ServiceManifest.xml | 1 + .../PaymentApiPkg/ServiceManifest.xml | 1 + .../IdentityApiPkg/ServiceManifest.xml | 1 + .../WebMVCPkg/ServiceManifest.xml | 1 + .../WebSPAPkg/ServiceManifest.xml | 1 + .../servicefabricdeploy.parameters.json | 4 +- docker-compose.override.yml | 10 ++++ k8s/conf_local.yml | 1 + k8s/deployments.yaml | 57 +++++++++++++++++-- .../Basket/Basket.API/Basket.API.csproj | 5 ++ src/Services/Basket/Basket.API/Program.cs | 6 ++ src/Services/Basket/Basket.API/Startup.cs | 5 +- .../Basket/Basket.API/eventFlowConfig.json | 24 ++++++++ .../Catalog/Catalog.API/Catalog.API.csproj | 5 ++ .../Infrastructure/CatalogContextSeed.cs | 2 +- src/Services/Catalog/Catalog.API/Program.cs | 6 ++ src/Services/Catalog/Catalog.API/Startup.cs | 3 + .../Catalog/Catalog.API/eventFlowConfig.json | 24 ++++++++ .../Identity/Identity.API/Identity.API.csproj | 5 ++ src/Services/Identity/Identity.API/Program.cs | 5 ++ src/Services/Identity/Identity.API/Startup.cs | 5 +- .../Identity.API/eventFlowConfig.json | 24 ++++++++ .../Locations.API/Locations.API.csproj | 5 ++ .../Location/Locations.API/Program.cs | 6 ++ .../Location/Locations.API/Startup.cs | 4 ++ .../Locations.API/eventFlowConfig.json | 24 ++++++++ .../Infrastructure/MarketingContextSeed.cs | 2 +- .../Marketing.API/Marketing.API.csproj | 5 ++ .../Marketing/Marketing.API/Program.cs | 6 ++ .../Marketing/Marketing.API/Startup.cs | 4 ++ .../Marketing.API/eventFlowConfig.json | 24 ++++++++ ...PaymentMethodVerifiedDomainEventHandler.cs | 2 +- ...dToAwaitingValidationDomainEventHandler.cs | 2 +- ...erStatusChangedToPaidDomainEventHandler.cs | 2 +- ...egateWhenOrderStartedDomainEventHandler.cs | 2 +- ...angedToStockConfirmedDomainEventHandler.cs | 2 +- ...CheckoutAcceptedIntegrationEventHandler.cs | 2 +- .../Infrastructure/OrderingContextSeed.cs | 2 +- .../Ordering/Ordering.API/Ordering.API.csproj | 5 ++ src/Services/Ordering/Ordering.API/Program.cs | 10 +++- src/Services/Ordering/Ordering.API/Startup.cs | 5 +- .../Ordering.API/eventFlowConfig.json | 24 ++++++++ .../Payment/Payment.API/Payment.API.csproj | 5 ++ src/Services/Payment/Payment.API/Program.cs | 6 ++ src/Services/Payment/Payment.API/Startup.cs | 32 +++-------- .../Payment/Payment.API/eventFlowConfig.json | 24 ++++++++ .../ResilientHttpClientFactory.cs | 4 +- src/Web/WebMVC/Program.cs | 6 ++ src/Web/WebMVC/Startup.cs | 3 + src/Web/WebMVC/WebMVC.csproj | 5 ++ src/Web/WebMVC/eventFlowConfig.json | 24 ++++++++ src/Web/WebSPA/Program.cs | 6 ++ src/Web/WebSPA/Startup.cs | 6 +- src/Web/WebSPA/WebSPA.csproj | 5 ++ src/Web/WebSPA/eventFlowConfig.json | 24 ++++++++ 60 files changed, 439 insertions(+), 50 deletions(-) create mode 100644 src/Services/Basket/Basket.API/eventFlowConfig.json create mode 100644 src/Services/Catalog/Catalog.API/eventFlowConfig.json create mode 100644 src/Services/Identity/Identity.API/eventFlowConfig.json create mode 100644 src/Services/Location/Locations.API/eventFlowConfig.json create mode 100644 src/Services/Marketing/Marketing.API/eventFlowConfig.json create mode 100644 src/Services/Ordering/Ordering.API/eventFlowConfig.json create mode 100644 src/Services/Payment/Payment.API/eventFlowConfig.json create mode 100644 src/Web/WebMVC/eventFlowConfig.json create mode 100644 src/Web/WebSPA/eventFlowConfig.json diff --git a/.env b/.env index 797e5fc5c..07072ed2b 100644 --- a/.env +++ b/.env @@ -23,3 +23,4 @@ ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP=10.121.122.92 #ESHOP_AZURE_STORAGE_MARKETING_KEY= #ESHOP_SERVICE_BUS_USERNAME= #ESHOP_SERVICE_BUS_PASSWORD= +INSTRUMENTATION_KEY= diff --git a/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/BasketApiPkg/ServiceManifest.xml b/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/BasketApiPkg/ServiceManifest.xml index 3ef82903a..7805b26b0 100644 --- a/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/BasketApiPkg/ServiceManifest.xml +++ b/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/BasketApiPkg/ServiceManifest.xml @@ -30,6 +30,7 @@ + diff --git a/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/CatalogApiPkg/ServiceManifest.xml b/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/CatalogApiPkg/ServiceManifest.xml index e978f2ecc..6fd3665f3 100644 --- a/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/CatalogApiPkg/ServiceManifest.xml +++ b/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/CatalogApiPkg/ServiceManifest.xml @@ -33,6 +33,7 @@ + diff --git a/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/LocationsApiPkg/ServiceManifest.xml b/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/LocationsApiPkg/ServiceManifest.xml index 749d7a051..83ac410f5 100644 --- a/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/LocationsApiPkg/ServiceManifest.xml +++ b/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/LocationsApiPkg/ServiceManifest.xml @@ -31,6 +31,7 @@ + diff --git a/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/MarketingApiPkg/ServiceManifest.xml b/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/MarketingApiPkg/ServiceManifest.xml index d69a94d50..15b69d7bd 100644 --- a/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/MarketingApiPkg/ServiceManifest.xml +++ b/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/MarketingApiPkg/ServiceManifest.xml @@ -37,6 +37,7 @@ + diff --git a/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/OrderingApiPkg/ServiceManifest.xml b/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/OrderingApiPkg/ServiceManifest.xml index e858bb8c8..cc7a5caf3 100644 --- a/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/OrderingApiPkg/ServiceManifest.xml +++ b/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/OrderingApiPkg/ServiceManifest.xml @@ -33,6 +33,7 @@ + diff --git a/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/PaymentApiPkg/ServiceManifest.xml b/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/PaymentApiPkg/ServiceManifest.xml index d42b8bdeb..068c38f0d 100644 --- a/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/PaymentApiPkg/ServiceManifest.xml +++ b/ServiceFabric/eShopOnServiceFabric/ApplicationPackageRoot/PaymentApiPkg/ServiceManifest.xml @@ -27,6 +27,7 @@ + diff --git a/ServiceFabric/eShopOnServiceFabricIdSrv/eShopOnServiceFabricIdSrv/ApplicationPackageRoot/IdentityApiPkg/ServiceManifest.xml b/ServiceFabric/eShopOnServiceFabricIdSrv/eShopOnServiceFabricIdSrv/ApplicationPackageRoot/IdentityApiPkg/ServiceManifest.xml index 02ec66197..a0ae806be 100644 --- a/ServiceFabric/eShopOnServiceFabricIdSrv/eShopOnServiceFabricIdSrv/ApplicationPackageRoot/IdentityApiPkg/ServiceManifest.xml +++ b/ServiceFabric/eShopOnServiceFabricIdSrv/eShopOnServiceFabricIdSrv/ApplicationPackageRoot/IdentityApiPkg/ServiceManifest.xml @@ -32,6 +32,7 @@ + diff --git a/ServiceFabric/eShopOnServiceFabricWebMVC/eShopOnServiceFabricWebMVC/ApplicationPackageRoot/WebMVCPkg/ServiceManifest.xml b/ServiceFabric/eShopOnServiceFabricWebMVC/eShopOnServiceFabricWebMVC/ApplicationPackageRoot/WebMVCPkg/ServiceManifest.xml index dbb6d3475..416497ac9 100644 --- a/ServiceFabric/eShopOnServiceFabricWebMVC/eShopOnServiceFabricWebMVC/ApplicationPackageRoot/WebMVCPkg/ServiceManifest.xml +++ b/ServiceFabric/eShopOnServiceFabricWebMVC/eShopOnServiceFabricWebMVC/ApplicationPackageRoot/WebMVCPkg/ServiceManifest.xml @@ -28,6 +28,7 @@ + diff --git a/ServiceFabric/eShopOnServiceFabricWebSPA/eShopOnServiceFabricWebSPA/ApplicationPackageRoot/WebSPAPkg/ServiceManifest.xml b/ServiceFabric/eShopOnServiceFabricWebSPA/eShopOnServiceFabricWebSPA/ApplicationPackageRoot/WebSPAPkg/ServiceManifest.xml index f907caddc..a526af596 100644 --- a/ServiceFabric/eShopOnServiceFabricWebSPA/eShopOnServiceFabricWebSPA/ApplicationPackageRoot/WebSPAPkg/ServiceManifest.xml +++ b/ServiceFabric/eShopOnServiceFabricWebSPA/eShopOnServiceFabricWebSPA/ApplicationPackageRoot/WebSPAPkg/ServiceManifest.xml @@ -33,6 +33,7 @@ + diff --git a/deploy/az/servicefabric/WindowsContainers/servicefabricdeploy.parameters.json b/deploy/az/servicefabric/WindowsContainers/servicefabricdeploy.parameters.json index 8d7cf57ac..a22a6efda 100644 --- a/deploy/az/servicefabric/WindowsContainers/servicefabricdeploy.parameters.json +++ b/deploy/az/servicefabric/WindowsContainers/servicefabricdeploy.parameters.json @@ -15,7 +15,7 @@ "value": "eshop" }, "adminPassword": { - "value": "your_password" + "value": "eshopEshop<<<" }, "nicName": { "value": "NIC-eshopsfwin" @@ -24,7 +24,7 @@ "value": "eshopsfwin-PubIP" }, "dnsName": { - "value": "eshoponservicefabric" + "value": "eshoponsfwinsec" }, "virtualNetworkName": { "value": "VNet-eshopsfwin" diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 0d4c420c2..af9d3be04 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -19,6 +19,7 @@ services: - EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME} - EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD} - AzureServiceBusEnabled=False + - outputs__0__instrumentationKey=${INSTRUMENTATION_KEY} ports: - "5103:80" @@ -36,6 +37,7 @@ services: - UseCustomizationData=True - AzureServiceBusEnabled=False - AzureStorageEnabled=False + - outputs__0__instrumentationKey=${INSTRUMENTATION_KEY} ports: - "5101:80" @@ -52,6 +54,7 @@ services: - BasketApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5103 - OrderingApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5102 - UseCustomizationData=True + - outputs__0__instrumentationKey=${INSTRUMENTATION_KEY} ports: - "5105:80" @@ -69,6 +72,7 @@ services: - AzureServiceBusEnabled=False - CheckUpdateTime=30000 - GracePeriodTime=1 + - outputs__0__instrumentationKey=${INSTRUMENTATION_KEY} ports: - "5102:80" @@ -90,6 +94,7 @@ services: - AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_MARKETING_KEY} - AzureServiceBusEnabled=False - AzureStorageEnabled=False + - outputs__0__instrumentationKey=${INSTRUMENTATION_KEY} ports: - "5110:80" @@ -110,6 +115,7 @@ services: - MarketingUrlHC=http://marketing.api/hc - PaymentUrlHC=http://payment.api/hc - UseCustomizationData=True + - outputs__0__instrumentationKey=${INSTRUMENTATION_KEY} ports: - "5104:80" @@ -130,6 +136,7 @@ services: - MarketingUrlHC=http://marketing.api/hc - PaymentUrlHC=http://payment.api/hc - UseCustomizationData=True + - outputs__0__instrumentationKey=${INSTRUMENTATION_KEY} ports: - "5100:80" @@ -146,6 +153,7 @@ services: - PaymentUrl=http://payment.api/hc - mvc=http://webmvc/hc - spa=http://webspa/hc + - outputs__0__instrumentationKey=${INSTRUMENTATION_KEY} ports: - "5107:80" @@ -157,6 +165,7 @@ services: - EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME} - EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD} - AzureServiceBusEnabled=False + - outputs__0__instrumentationKey=${INSTRUMENTATION_KEY} ports: - "5108:80" @@ -172,6 +181,7 @@ services: - EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME} - EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD} - AzureServiceBusEnabled=False + - outputs__0__instrumentationKey=${INSTRUMENTATION_KEY} ports: - "5109:80" diff --git a/k8s/conf_local.yml b/k8s/conf_local.yml index 00d1c2398..49afcf3e4 100644 --- a/k8s/conf_local.yml +++ b/k8s/conf_local.yml @@ -25,5 +25,6 @@ data: keystore: keystore-data GracePeriodManager_GracePeriodTime: "1" GracePeriodManager_CheckUpdateTime: "15000" + Instrumentation_Key: "" diff --git a/k8s/deployments.yaml b/k8s/deployments.yaml index 2a9d6862e..e80dac288 100644 --- a/k8s/deployments.yaml +++ b/k8s/deployments.yaml @@ -37,6 +37,11 @@ spec: configMapKeyRef: name: urls key: IdentityUrl + - name: outputs__0__instrumentationKey + valueFrom: + configMapKeyRef: + name: externalcfg + key: Instrumentation_Key ports: - containerPort: 80 readinessProbe: @@ -95,6 +100,11 @@ spec: configMapKeyRef: name: externalcfg key: CatalogBus + - name: outputs__0__instrumentationKey + valueFrom: + configMapKeyRef: + name: externalcfg + key: Instrumentation_Key ports: - containerPort: 80 readinessProbe: @@ -133,7 +143,7 @@ spec: env: - name: PATH_BASE value: /identity - - name: ConnectionStrings__DefaultConnection + - name: ConnectionString valueFrom: configMapKeyRef: name: externalcfg @@ -174,7 +184,12 @@ spec: valueFrom: configMapKeyRef: name: urls - key: OrderingApiClient + key: OrderingApiClient + - name: outputs__0__instrumentationKey + valueFrom: + configMapKeyRef: + name: externalcfg + key: Instrumentation_Key ports: - containerPort: 80 readinessProbe: @@ -242,7 +257,12 @@ spec: valueFrom: configMapKeyRef: name: externalcfg - key: GracePeriodManager_GracePeriodTime + key: GracePeriodManager_GracePeriodTime + - name: outputs__0__instrumentationKey + valueFrom: + configMapKeyRef: + name: externalcfg + key: Instrumentation_Key ports: - containerPort: 80 readinessProbe: @@ -310,7 +330,12 @@ spec: valueFrom: configMapKeyRef: name: urls - key: IdentityUrl + key: IdentityUrl + - name: outputs__0__instrumentationKey + valueFrom: + configMapKeyRef: + name: externalcfg + key: Instrumentation_Key ports: - containerPort: 80 readinessProbe: @@ -388,7 +413,12 @@ spec: valueFrom: configMapKeyRef: name: urls - key: Marketing_PicBaseUrl + key: Marketing_PicBaseUrl + - name: outputs__0__instrumentationKey + valueFrom: + configMapKeyRef: + name: externalcfg + key: Instrumentation_Key ports: - containerPort: 80 readinessProbe: @@ -437,6 +467,11 @@ spec: configMapKeyRef: name: externalcfg key: PaymentBus + - name: outputs__0__instrumentationKey + valueFrom: + configMapKeyRef: + name: externalcfg + key: Instrumentation_Key ports: - containerPort: 80 readinessProbe: @@ -546,7 +581,12 @@ spec: valueFrom: configMapKeyRef: name: urls - key: PaymentHealthCheckUrl + key: PaymentHealthCheckUrl + - name: outputs__0__instrumentationKey + valueFrom: + configMapKeyRef: + name: externalcfg + key: Instrumentation_Key ports: - containerPort: 80 readinessProbe: @@ -726,6 +766,11 @@ spec: configMapKeyRef: name: urls key: PaymentHealthCheckUrl + - name: outputs__0__instrumentationKey + valueFrom: + configMapKeyRef: + name: externalcfg + key: Instrumentation_Key ports: - containerPort: 80 readinessProbe: diff --git a/src/Services/Basket/Basket.API/Basket.API.csproj b/src/Services/Basket/Basket.API/Basket.API.csproj index 8864c9d06..25c4d9bc1 100644 --- a/src/Services/Basket/Basket.API/Basket.API.csproj +++ b/src/Services/Basket/Basket.API/Basket.API.csproj @@ -18,6 +18,11 @@ + + + + + diff --git a/src/Services/Basket/Basket.API/Program.cs b/src/Services/Basket/Basket.API/Program.cs index 53b6f311f..de3d5da5a 100644 --- a/src/Services/Basket/Basket.API/Program.cs +++ b/src/Services/Basket/Basket.API/Program.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using System.IO; @@ -23,6 +24,11 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API .UseHealthChecks("/hc") .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup() + .ConfigureAppConfiguration((builderContext, config) => + { + config.AddJsonFile("eventFlowConfig.json", optional: true, reloadOnChange: true); + config.AddEnvironmentVariables(); + }) .ConfigureLogging((hostingContext, builder) => { builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); diff --git a/src/Services/Basket/Basket.API/Startup.cs b/src/Services/Basket/Basket.API/Startup.cs index b82a912d8..5f29da7b5 100644 --- a/src/Services/Basket/Basket.API/Startup.cs +++ b/src/Services/Basket/Basket.API/Startup.cs @@ -8,6 +8,8 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Azure.ServiceBus; +using Microsoft.Diagnostics.EventFlow; +using Microsoft.Diagnostics.EventFlow.Inputs; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ; @@ -167,8 +169,9 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { + loggerFactory.AddEventFlow(DiagnosticPipelineFactory.CreatePipeline(Configuration)); var pathBase = Configuration["PATH_BASE"]; if (!string.IsNullOrEmpty(pathBase)) diff --git a/src/Services/Basket/Basket.API/eventFlowConfig.json b/src/Services/Basket/Basket.API/eventFlowConfig.json new file mode 100644 index 000000000..0ddeee125 --- /dev/null +++ b/src/Services/Basket/Basket.API/eventFlowConfig.json @@ -0,0 +1,24 @@ +{ + "inputs": [ + { + "type": "Microsoft.Extensions.Logging" + } + ], + "filters": [ + ], + "outputs": [ + { + "type": "ApplicationInsights", + "instrumentationKey": "" + }, + { + "type": "StdOutput" + } + ], + "schemaVersion": "2016-08-11", + "extensions": [], + "healthReporter": { + "type": "CsvHealthReporter", + "logFileFolder": "/app/log" + } +} \ No newline at end of file diff --git a/src/Services/Catalog/Catalog.API/Catalog.API.csproj b/src/Services/Catalog/Catalog.API/Catalog.API.csproj index 0d8c77efd..9d25d801b 100644 --- a/src/Services/Catalog/Catalog.API/Catalog.API.csproj +++ b/src/Services/Catalog/Catalog.API/Catalog.API.csproj @@ -36,6 +36,11 @@ + + + + + diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs index 42ac7b740..e92f7cf5b 100644 --- a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs +++ b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs @@ -374,7 +374,7 @@ sleepDurationProvider: retry => TimeSpan.FromSeconds(5), onRetry: (exception, timeSpan, retry, ctx) => { - logger.LogTrace($"[{prefix}] Exception {exception.GetType().Name} with message ${exception.Message} detected on attempt {retry} of {retries}"); + logger.LogInformation($"[{prefix}] Exception {exception.GetType().Name} with message ${exception.Message} detected on attempt {retry} of {retries}"); } ); } diff --git a/src/Services/Catalog/Catalog.API/Program.cs b/src/Services/Catalog/Catalog.API/Program.cs index 1eeeeb5ec..621f881e5 100644 --- a/src/Services/Catalog/Catalog.API/Program.cs +++ b/src/Services/Catalog/Catalog.API/Program.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF; using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -34,6 +35,11 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API .UseHealthChecks("/hc") .UseContentRoot(Directory.GetCurrentDirectory()) .UseWebRoot("Pics") + .ConfigureAppConfiguration((builderContext, config) => + { + config.AddJsonFile("eventFlowConfig.json", optional: true, reloadOnChange: true); + config.AddEnvironmentVariables(); + }) .ConfigureLogging((hostingContext, builder) => { builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); diff --git a/src/Services/Catalog/Catalog.API/Startup.cs b/src/Services/Catalog/Catalog.API/Startup.cs index 8bfa347d2..26c8275b2 100644 --- a/src/Services/Catalog/Catalog.API/Startup.cs +++ b/src/Services/Catalog/Catalog.API/Startup.cs @@ -7,6 +7,8 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Azure.ServiceBus; + using Microsoft.Diagnostics.EventFlow; + using Microsoft.Diagnostics.EventFlow.Inputs; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; @@ -167,6 +169,7 @@ loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); + loggerFactory.AddEventFlow(DiagnosticPipelineFactory.CreatePipeline(Configuration)); var pathBase = Configuration["PATH_BASE"]; if (!string.IsNullOrEmpty(pathBase)) diff --git a/src/Services/Catalog/Catalog.API/eventFlowConfig.json b/src/Services/Catalog/Catalog.API/eventFlowConfig.json new file mode 100644 index 000000000..0ddeee125 --- /dev/null +++ b/src/Services/Catalog/Catalog.API/eventFlowConfig.json @@ -0,0 +1,24 @@ +{ + "inputs": [ + { + "type": "Microsoft.Extensions.Logging" + } + ], + "filters": [ + ], + "outputs": [ + { + "type": "ApplicationInsights", + "instrumentationKey": "" + }, + { + "type": "StdOutput" + } + ], + "schemaVersion": "2016-08-11", + "extensions": [], + "healthReporter": { + "type": "CsvHealthReporter", + "logFileFolder": "/app/log" + } +} \ No newline at end of file diff --git a/src/Services/Identity/Identity.API/Identity.API.csproj b/src/Services/Identity/Identity.API/Identity.API.csproj index cee95b94f..785e96d1e 100644 --- a/src/Services/Identity/Identity.API/Identity.API.csproj +++ b/src/Services/Identity/Identity.API/Identity.API.csproj @@ -19,6 +19,11 @@ + + + + + diff --git a/src/Services/Identity/Identity.API/Program.cs b/src/Services/Identity/Identity.API/Program.cs index 0b32b4549..ec45dcce9 100644 --- a/src/Services/Identity/Identity.API/Program.cs +++ b/src/Services/Identity/Identity.API/Program.cs @@ -43,6 +43,11 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() + .ConfigureAppConfiguration((builderContext, config) => + { + config.AddJsonFile("eventFlowConfig.json", optional: true, reloadOnChange: true); + config.AddEnvironmentVariables(); + }) .ConfigureLogging((hostingContext, builder) => { builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); diff --git a/src/Services/Identity/Identity.API/Startup.cs b/src/Services/Identity/Identity.API/Startup.cs index 3cd8acaa4..26d0e75e9 100644 --- a/src/Services/Identity/Identity.API/Startup.cs +++ b/src/Services/Identity/Identity.API/Startup.cs @@ -4,6 +4,8 @@ using IdentityServer4.Services; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Identity; +using Microsoft.Diagnostics.EventFlow; +using Microsoft.Diagnostics.EventFlow.Inputs; using Microsoft.EntityFrameworkCore; using Microsoft.eShopOnContainers.BuildingBlocks; using Microsoft.eShopOnContainers.Services.Identity.API.Certificates; @@ -98,7 +100,8 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); - + loggerFactory.AddEventFlow(DiagnosticPipelineFactory.CreatePipeline(Configuration)); + if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); diff --git a/src/Services/Identity/Identity.API/eventFlowConfig.json b/src/Services/Identity/Identity.API/eventFlowConfig.json new file mode 100644 index 000000000..0ddeee125 --- /dev/null +++ b/src/Services/Identity/Identity.API/eventFlowConfig.json @@ -0,0 +1,24 @@ +{ + "inputs": [ + { + "type": "Microsoft.Extensions.Logging" + } + ], + "filters": [ + ], + "outputs": [ + { + "type": "ApplicationInsights", + "instrumentationKey": "" + }, + { + "type": "StdOutput" + } + ], + "schemaVersion": "2016-08-11", + "extensions": [], + "healthReporter": { + "type": "CsvHealthReporter", + "logFileFolder": "/app/log" + } +} \ No newline at end of file diff --git a/src/Services/Location/Locations.API/Locations.API.csproj b/src/Services/Location/Locations.API/Locations.API.csproj index b1b322708..e08dbb419 100644 --- a/src/Services/Location/Locations.API/Locations.API.csproj +++ b/src/Services/Location/Locations.API/Locations.API.csproj @@ -12,10 +12,15 @@ + + + + + diff --git a/src/Services/Location/Locations.API/Program.cs b/src/Services/Location/Locations.API/Program.cs index 7ebc0ab8a..9d0ef654d 100644 --- a/src/Services/Location/Locations.API/Program.cs +++ b/src/Services/Location/Locations.API/Program.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using System.IO; @@ -18,6 +19,11 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API .UseHealthChecks("/hc") .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup() + .ConfigureAppConfiguration((builderContext, config) => + { + config.AddJsonFile("eventFlowConfig.json", optional: true, reloadOnChange: true); + config.AddEnvironmentVariables(); + }) .ConfigureLogging((hostingContext, builder) => { builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); diff --git a/src/Services/Location/Locations.API/Startup.cs b/src/Services/Location/Locations.API/Startup.cs index 442210216..03f8d7b98 100644 --- a/src/Services/Location/Locations.API/Startup.cs +++ b/src/Services/Location/Locations.API/Startup.cs @@ -5,6 +5,8 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Azure.ServiceBus; +using Microsoft.Diagnostics.EventFlow; +using Microsoft.Diagnostics.EventFlow.Inputs; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ; @@ -142,6 +144,8 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { + loggerFactory.AddEventFlow(DiagnosticPipelineFactory.CreatePipeline(Configuration)); + var pathBase = Configuration["PATH_BASE"]; if (!string.IsNullOrEmpty(pathBase)) { diff --git a/src/Services/Location/Locations.API/eventFlowConfig.json b/src/Services/Location/Locations.API/eventFlowConfig.json new file mode 100644 index 000000000..0ddeee125 --- /dev/null +++ b/src/Services/Location/Locations.API/eventFlowConfig.json @@ -0,0 +1,24 @@ +{ + "inputs": [ + { + "type": "Microsoft.Extensions.Logging" + } + ], + "filters": [ + ], + "outputs": [ + { + "type": "ApplicationInsights", + "instrumentationKey": "" + }, + { + "type": "StdOutput" + } + ], + "schemaVersion": "2016-08-11", + "extensions": [], + "healthReporter": { + "type": "CsvHealthReporter", + "logFileFolder": "/app/log" + } +} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingContextSeed.cs b/src/Services/Marketing/Marketing.API/Infrastructure/MarketingContextSeed.cs index 6396d3f5d..ad8d37a2a 100644 --- a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingContextSeed.cs +++ b/src/Services/Marketing/Marketing.API/Infrastructure/MarketingContextSeed.cs @@ -76,7 +76,7 @@ sleepDurationProvider: retry => TimeSpan.FromSeconds(5), onRetry: (exception, timeSpan, retry, ctx) => { - logger.LogTrace($"[{prefix}] Exception {exception.GetType().Name} with message ${exception.Message} detected on attempt {retry} of {retries}"); + logger.LogInformation($"[{prefix}] Exception {exception.GetType().Name} with message ${exception.Message} detected on attempt {retry} of {retries}"); } ); } diff --git a/src/Services/Marketing/Marketing.API/Marketing.API.csproj b/src/Services/Marketing/Marketing.API/Marketing.API.csproj index 2afba2204..2b0d6480a 100644 --- a/src/Services/Marketing/Marketing.API/Marketing.API.csproj +++ b/src/Services/Marketing/Marketing.API/Marketing.API.csproj @@ -19,10 +19,15 @@ + + + + + diff --git a/src/Services/Marketing/Marketing.API/Program.cs b/src/Services/Marketing/Marketing.API/Program.cs index 32852073c..1e71d17ea 100644 --- a/src/Services/Marketing/Marketing.API/Program.cs +++ b/src/Services/Marketing/Marketing.API/Program.cs @@ -3,6 +3,7 @@ using AspNetCore.Hosting; using Microsoft.AspNetCore; using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure; + using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using System.IO; @@ -29,6 +30,11 @@ .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup() .UseWebRoot("Pics") + .ConfigureAppConfiguration((builderContext, config) => + { + config.AddJsonFile("eventFlowConfig.json", optional: true, reloadOnChange: true); + config.AddEnvironmentVariables(); + }) .ConfigureLogging((hostingContext, builder) => { builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); diff --git a/src/Services/Marketing/Marketing.API/Startup.cs b/src/Services/Marketing/Marketing.API/Startup.cs index b1d0004c1..3df147064 100644 --- a/src/Services/Marketing/Marketing.API/Startup.cs +++ b/src/Services/Marketing/Marketing.API/Startup.cs @@ -22,6 +22,8 @@ using IntegrationEvents.Events; using Marketing.API.IntegrationEvents.Handlers; using Microsoft.AspNetCore.Authentication.JwtBearer; + using Microsoft.Diagnostics.EventFlow; + using Microsoft.Diagnostics.EventFlow.Inputs; using Microsoft.EntityFrameworkCore.Diagnostics; using RabbitMQ.Client; using Swashbuckle.AspNetCore.Swagger; @@ -172,6 +174,8 @@ // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env,ILoggerFactory loggerFactory) { + loggerFactory.AddEventFlow(DiagnosticPipelineFactory.CreatePipeline(Configuration)); + var pathBase = Configuration["PATH_BASE"]; if (!string.IsNullOrEmpty(pathBase)) diff --git a/src/Services/Marketing/Marketing.API/eventFlowConfig.json b/src/Services/Marketing/Marketing.API/eventFlowConfig.json new file mode 100644 index 000000000..0ddeee125 --- /dev/null +++ b/src/Services/Marketing/Marketing.API/eventFlowConfig.json @@ -0,0 +1,24 @@ +{ + "inputs": [ + { + "type": "Microsoft.Extensions.Logging" + } + ], + "filters": [ + ], + "outputs": [ + { + "type": "ApplicationInsights", + "instrumentationKey": "" + }, + { + "type": "StdOutput" + } + ], + "schemaVersion": "2016-08-11", + "extensions": [], + "healthReporter": { + "type": "CsvHealthReporter", + "logFileFolder": "/app/log" + } +} \ No newline at end of file diff --git a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/BuyerAndPaymentMethodVerified/UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/BuyerAndPaymentMethodVerified/UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs index 35e14dd68..eb2fbd992 100644 --- a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/BuyerAndPaymentMethodVerified/UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/BuyerAndPaymentMethodVerified/UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs @@ -32,7 +32,7 @@ namespace Ordering.API.Application.DomainEventHandlers.BuyerAndPaymentMethodVeri orderToUpdate.SetPaymentId(buyerPaymentMethodVerifiedEvent.Payment.Id); _logger.CreateLogger(nameof(UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler)) - .LogTrace($"Order with Id: {buyerPaymentMethodVerifiedEvent.OrderId} has been successfully updated with a payment method id: { buyerPaymentMethodVerifiedEvent.Payment.Id }"); + .LogInformation($"Order with Id: {buyerPaymentMethodVerifiedEvent.OrderId} has been successfully updated with a payment method id: { buyerPaymentMethodVerifiedEvent.Payment.Id }"); } } } diff --git a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderGracePeriodConfirmed/OrderStatusChangedToAwaitingValidationDomainEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderGracePeriodConfirmed/OrderStatusChangedToAwaitingValidationDomainEventHandler.cs index 3c0168656..6e4e7bb9d 100644 --- a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderGracePeriodConfirmed/OrderStatusChangedToAwaitingValidationDomainEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderGracePeriodConfirmed/OrderStatusChangedToAwaitingValidationDomainEventHandler.cs @@ -29,7 +29,7 @@ public async Task Handle(OrderStatusChangedToAwaitingValidationDomainEvent orderStatusChangedToAwaitingValidationDomainEvent) { _logger.CreateLogger(nameof(OrderStatusChangedToAwaitingValidationDomainEvent)) - .LogTrace($"Order with Id: {orderStatusChangedToAwaitingValidationDomainEvent.OrderId} has been successfully updated with " + + .LogInformation($"Order with Id: {orderStatusChangedToAwaitingValidationDomainEvent.OrderId} has been successfully updated with " + $"a status order id: {OrderStatus.AwaitingValidation.Id}"); var orderStockList = orderStatusChangedToAwaitingValidationDomainEvent.OrderItems diff --git a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderPaid/OrderStatusChangedToPaidDomainEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderPaid/OrderStatusChangedToPaidDomainEventHandler.cs index 60f56c2e2..798281114 100644 --- a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderPaid/OrderStatusChangedToPaidDomainEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderPaid/OrderStatusChangedToPaidDomainEventHandler.cs @@ -29,7 +29,7 @@ public async Task Handle(OrderStatusChangedToPaidDomainEvent orderStatusChangedToPaidDomainEvent) { _logger.CreateLogger(nameof(OrderStatusChangedToPaidDomainEventHandler)) - .LogTrace($"Order with Id: {orderStatusChangedToPaidDomainEvent.OrderId} has been successfully updated with " + + .LogInformation($"Order with Id: {orderStatusChangedToPaidDomainEvent.OrderId} has been successfully updated with " + $"a status order id: {OrderStatus.Paid.Id}"); var orderStockList = orderStatusChangedToPaidDomainEvent.OrderItems diff --git a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStartedEvent/ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStartedEvent/ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler.cs index 77714d1b0..7f2db36e0 100644 --- a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStartedEvent/ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStartedEvent/ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler.cs @@ -47,7 +47,7 @@ namespace Ordering.API.Application.DomainEventHandlers.OrderStartedEvent await _buyerRepository.UnitOfWork .SaveEntitiesAsync(); - _logger.CreateLogger(nameof(ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler)).LogTrace($"Buyer {buyerUpdated.Id} and related payment method were validated or updated for orderId: {orderStartedEvent.Order.Id}."); + _logger.CreateLogger(nameof(ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler)).LogInformation($"Buyer {buyerUpdated.Id} and related payment method were validated or updated for orderId: {orderStartedEvent.Order.Id}."); } } } diff --git a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStockConfirmed/OrderStatusChangedToStockConfirmedDomainEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStockConfirmed/OrderStatusChangedToStockConfirmedDomainEventHandler.cs index 7ead82c4d..a6511a5ac 100644 --- a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStockConfirmed/OrderStatusChangedToStockConfirmedDomainEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStockConfirmed/OrderStatusChangedToStockConfirmedDomainEventHandler.cs @@ -28,7 +28,7 @@ public async Task Handle(OrderStatusChangedToStockConfirmedDomainEvent orderStatusChangedToStockConfirmedDomainEvent) { _logger.CreateLogger(nameof(OrderStatusChangedToStockConfirmedDomainEventHandler)) - .LogTrace($"Order with Id: {orderStatusChangedToStockConfirmedDomainEvent.OrderId} has been successfully updated with " + + .LogInformation($"Order with Id: {orderStatusChangedToStockConfirmedDomainEvent.OrderId} has been successfully updated with " + $"a status order id: {OrderStatus.StockConfirmed.Id}"); var orderStatusChangedToStockConfirmedIntegrationEvent = new OrderStatusChangedToStockConfirmedIntegrationEvent(orderStatusChangedToStockConfirmedDomainEvent.OrderId); diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs index e2beff9f3..a19cb153b 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs @@ -51,7 +51,7 @@ namespace Ordering.API.Application.IntegrationEvents.EventHandling } _logger.CreateLogger(nameof(UserCheckoutAcceptedIntegrationEventHandler)) - .LogTrace(result ? $"UserCheckoutAccepted integration event has been received and a create new order process is started with requestId: {eventMsg.RequestId}" : + .LogInformation(result ? $"UserCheckoutAccepted integration event has been received and a create new order process is started with requestId: {eventMsg.RequestId}" : $"UserCheckoutAccepted integration event has been received but a new order process has failed with requestId: {eventMsg.RequestId}"); } } diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs b/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs index 53c53f052..681e90d3b 100644 --- a/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs +++ b/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs @@ -188,7 +188,7 @@ sleepDurationProvider: retry => TimeSpan.FromSeconds(5), onRetry: (exception, timeSpan, retry, ctx) => { - logger.LogTrace($"[{prefix}] Exception {exception.GetType().Name} with message ${exception.Message} detected on attempt {retry} of {retries}"); + logger.LogInformation($"[{prefix}] Exception {exception.GetType().Name} with message ${exception.Message} detected on attempt {retry} of {retries}"); } ); } diff --git a/src/Services/Ordering/Ordering.API/Ordering.API.csproj b/src/Services/Ordering/Ordering.API/Ordering.API.csproj index 123f9e838..57995fc33 100644 --- a/src/Services/Ordering/Ordering.API/Ordering.API.csproj +++ b/src/Services/Ordering/Ordering.API/Ordering.API.csproj @@ -39,6 +39,11 @@ + + + + + diff --git a/src/Services/Ordering/Ordering.API/Program.cs b/src/Services/Ordering/Ordering.API/Program.cs index 46221b42c..fcf8ebb1e 100644 --- a/src/Services/Ordering/Ordering.API/Program.cs +++ b/src/Services/Ordering/Ordering.API/Program.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF; using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure; using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -25,7 +26,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API .SeedAsync(context, env, settings, logger) .Wait(); }) - .MigrateDbContext((_,__)=>{}) + .MigrateDbContext((_,__)=>{}) .Run(); } @@ -34,11 +35,16 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API .UseStartup() .UseHealthChecks("/hc") .UseContentRoot(Directory.GetCurrentDirectory()) + .ConfigureAppConfiguration((builderContext, config) => + { + config.AddJsonFile("eventFlowConfig.json", optional: true, reloadOnChange: true); + config.AddEnvironmentVariables(); + }) .ConfigureLogging((hostingContext, builder) => { builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); builder.AddConsole(); - builder.AddDebug(); + builder.AddDebug(); }) .Build(); } diff --git a/src/Services/Ordering/Ordering.API/Startup.cs b/src/Services/Ordering/Ordering.API/Startup.cs index 8c95ed828..66a396d58 100644 --- a/src/Services/Ordering/Ordering.API/Startup.cs +++ b/src/Services/Ordering/Ordering.API/Startup.cs @@ -14,6 +14,8 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Azure.ServiceBus; + using Microsoft.Diagnostics.EventFlow; + using Microsoft.Diagnostics.EventFlow.Inputs; using Microsoft.EntityFrameworkCore; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; @@ -88,7 +90,7 @@ opts.MigrationsAssembly("Ordering.API"); }); }); - + services.Configure(Configuration); @@ -193,6 +195,7 @@ { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); + loggerFactory.AddEventFlow(DiagnosticPipelineFactory.CreatePipeline(Configuration)); var pathBase = Configuration["PATH_BASE"]; if (!string.IsNullOrEmpty(pathBase)) diff --git a/src/Services/Ordering/Ordering.API/eventFlowConfig.json b/src/Services/Ordering/Ordering.API/eventFlowConfig.json new file mode 100644 index 000000000..0ddeee125 --- /dev/null +++ b/src/Services/Ordering/Ordering.API/eventFlowConfig.json @@ -0,0 +1,24 @@ +{ + "inputs": [ + { + "type": "Microsoft.Extensions.Logging" + } + ], + "filters": [ + ], + "outputs": [ + { + "type": "ApplicationInsights", + "instrumentationKey": "" + }, + { + "type": "StdOutput" + } + ], + "schemaVersion": "2016-08-11", + "extensions": [], + "healthReporter": { + "type": "CsvHealthReporter", + "logFileFolder": "/app/log" + } +} \ No newline at end of file diff --git a/src/Services/Payment/Payment.API/Payment.API.csproj b/src/Services/Payment/Payment.API/Payment.API.csproj index ab28a210d..cdc5e09c8 100644 --- a/src/Services/Payment/Payment.API/Payment.API.csproj +++ b/src/Services/Payment/Payment.API/Payment.API.csproj @@ -9,6 +9,11 @@ + + + + + diff --git a/src/Services/Payment/Payment.API/Program.cs b/src/Services/Payment/Payment.API/Program.cs index a373e2695..11d2e07a9 100644 --- a/src/Services/Payment/Payment.API/Program.cs +++ b/src/Services/Payment/Payment.API/Program.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using System.IO; @@ -18,6 +19,11 @@ namespace Payment.API .UseHealthChecks("/hc") .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup() + .ConfigureAppConfiguration((builderContext, config) => + { + config.AddJsonFile("eventFlowConfig.json", optional: true, reloadOnChange: true); + config.AddEnvironmentVariables(); + }) .ConfigureLogging((hostingContext, builder) => { builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); diff --git a/src/Services/Payment/Payment.API/Startup.cs b/src/Services/Payment/Payment.API/Startup.cs index 44393186b..c43eb7e41 100644 --- a/src/Services/Payment/Payment.API/Startup.cs +++ b/src/Services/Payment/Payment.API/Startup.cs @@ -3,6 +3,8 @@ using Autofac.Extensions.DependencyInjection; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Azure.ServiceBus; +using Microsoft.Diagnostics.EventFlow; +using Microsoft.Diagnostics.EventFlow.Inputs; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ; @@ -16,7 +18,6 @@ using Payment.API.IntegrationEvents.Events; using RabbitMQ.Client; using System; using System.Threading.Tasks; -using Swashbuckle.AspNetCore.Swagger; namespace Payment.API { @@ -75,20 +76,7 @@ namespace Payment.API { checks.AddValueTaskCheck("HTTP Endpoint", () => new ValueTask(HealthCheckResult.Healthy("Ok"))); }); - - // Add framework services. - services.AddSwaggerGen(options => - { - options.DescribeAllEnumsAsStrings(); - options.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info - { - Title = "eShopOnContainers - Payment HTTP API", - Version = "v1", - Description = "The Payment Microservice HTTP API. This is a Data-Driven/CRUD microservice sample", - TermsOfService = "Terms Of Service" - }); - }); - + RegisterEventBus(services); var container = new ContainerBuilder(); @@ -97,22 +85,16 @@ namespace Payment.API } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) - { + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + { + loggerFactory.AddEventFlow(DiagnosticPipelineFactory.CreatePipeline(Configuration)); + var pathBase = Configuration["PATH_BASE"]; if (!string.IsNullOrEmpty(pathBase)) { app.UsePathBase(pathBase); } - app.UseMvcWithDefaultRoute(); - - app.UseSwagger() - .UseSwaggerUI(c => - { - c.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "My API V1"); - }); - ConfigureEventBus(app); } diff --git a/src/Services/Payment/Payment.API/eventFlowConfig.json b/src/Services/Payment/Payment.API/eventFlowConfig.json new file mode 100644 index 000000000..0ddeee125 --- /dev/null +++ b/src/Services/Payment/Payment.API/eventFlowConfig.json @@ -0,0 +1,24 @@ +{ + "inputs": [ + { + "type": "Microsoft.Extensions.Logging" + } + ], + "filters": [ + ], + "outputs": [ + { + "type": "ApplicationInsights", + "instrumentationKey": "" + }, + { + "type": "StdOutput" + } + ], + "schemaVersion": "2016-08-11", + "extensions": [], + "healthReporter": { + "type": "CsvHealthReporter", + "logFileFolder": "/app/log" + } +} \ No newline at end of file diff --git a/src/Web/WebMVC/Infrastructure/ResilientHttpClientFactory.cs b/src/Web/WebMVC/Infrastructure/ResilientHttpClientFactory.cs index b05c6e038..adc4ed4c3 100644 --- a/src/Web/WebMVC/Infrastructure/ResilientHttpClientFactory.cs +++ b/src/Web/WebMVC/Infrastructure/ResilientHttpClientFactory.cs @@ -44,12 +44,12 @@ namespace Microsoft.eShopOnContainers.WebMVC.Infrastructure (exception, duration) => { // on circuit opened - _logger.LogTrace("Circuit breaker opened"); + _logger.LogInformation("Circuit breaker opened"); }, () => { // on circuit closed - _logger.LogTrace("Circuit breaker reset"); + _logger.LogInformation("Circuit breaker reset"); }) }; } diff --git a/src/Web/WebMVC/Program.cs b/src/Web/WebMVC/Program.cs index ec711b2ae..97513024e 100644 --- a/src/Web/WebMVC/Program.cs +++ b/src/Web/WebMVC/Program.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using System.IO; @@ -17,6 +18,11 @@ namespace Microsoft.eShopOnContainers.WebMVC .UseContentRoot(Directory.GetCurrentDirectory()) .UseHealthChecks("/hc") .UseStartup() + .ConfigureAppConfiguration((builderContext, config) => + { + config.AddJsonFile("eventFlowConfig.json", optional: true, reloadOnChange: true); + config.AddEnvironmentVariables(); + }) .ConfigureLogging((hostingContext, builder) => { builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); diff --git a/src/Web/WebMVC/Startup.cs b/src/Web/WebMVC/Startup.cs index a5b690296..8add7295f 100644 --- a/src/Web/WebMVC/Startup.cs +++ b/src/Web/WebMVC/Startup.cs @@ -3,6 +3,8 @@ using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; +using Microsoft.Diagnostics.EventFlow; +using Microsoft.Diagnostics.EventFlow.Inputs; using Microsoft.eShopOnContainers.BuildingBlocks; using Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http; using Microsoft.eShopOnContainers.WebMVC.Infrastructure; @@ -115,6 +117,7 @@ namespace Microsoft.eShopOnContainers.WebMVC loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); + loggerFactory.AddEventFlow(DiagnosticPipelineFactory.CreatePipeline(Configuration)); if (env.IsDevelopment()) { diff --git a/src/Web/WebMVC/WebMVC.csproj b/src/Web/WebMVC/WebMVC.csproj index e8cdbc528..6dd74320b 100644 --- a/src/Web/WebMVC/WebMVC.csproj +++ b/src/Web/WebMVC/WebMVC.csproj @@ -37,7 +37,12 @@ + + + + + diff --git a/src/Web/WebMVC/eventFlowConfig.json b/src/Web/WebMVC/eventFlowConfig.json new file mode 100644 index 000000000..0ddeee125 --- /dev/null +++ b/src/Web/WebMVC/eventFlowConfig.json @@ -0,0 +1,24 @@ +{ + "inputs": [ + { + "type": "Microsoft.Extensions.Logging" + } + ], + "filters": [ + ], + "outputs": [ + { + "type": "ApplicationInsights", + "instrumentationKey": "" + }, + { + "type": "StdOutput" + } + ], + "schemaVersion": "2016-08-11", + "extensions": [], + "healthReporter": { + "type": "CsvHealthReporter", + "logFileFolder": "/app/log" + } +} \ No newline at end of file diff --git a/src/Web/WebSPA/Program.cs b/src/Web/WebSPA/Program.cs index 92a6af2da..fd14e03bf 100644 --- a/src/Web/WebSPA/Program.cs +++ b/src/Web/WebSPA/Program.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Hosting; using System.IO; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Configuration; namespace eShopConContainers.WebSPA { @@ -17,6 +18,11 @@ namespace eShopConContainers.WebSPA .UseStartup() .UseHealthChecks("/hc") .UseContentRoot(Directory.GetCurrentDirectory()) + .ConfigureAppConfiguration((builderContext, config) => + { + config.AddJsonFile("eventFlowConfig.json", optional: true, reloadOnChange: true); + config.AddEnvironmentVariables(); + }) .ConfigureLogging((hostingContext, builder) => { builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); diff --git a/src/Web/WebSPA/Startup.cs b/src/Web/WebSPA/Startup.cs index 0e9585c8c..5291322b4 100644 --- a/src/Web/WebSPA/Startup.cs +++ b/src/Web/WebSPA/Startup.cs @@ -2,6 +2,8 @@ using Microsoft.AspNetCore.Antiforgery; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.Diagnostics.EventFlow; +using Microsoft.Diagnostics.EventFlow.Inputs; using Microsoft.eShopOnContainers.BuildingBlocks; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -78,9 +80,11 @@ namespace eShopConContainers.WebSPA { if (env.IsDevelopment()) { - app.UseDeveloperExceptionPage(); + app.UseDeveloperExceptionPage(); } + loggerFactory.AddEventFlow(DiagnosticPipelineFactory.CreatePipeline(Configuration)); + // Configure XSRF middleware, This pattern is for SPA style applications where XSRF token is added on Index page // load and passed back token on every subsequent async request // app.Use(async (context, next) => diff --git a/src/Web/WebSPA/WebSPA.csproj b/src/Web/WebSPA/WebSPA.csproj index 1efcb89e6..5809fbf30 100644 --- a/src/Web/WebSPA/WebSPA.csproj +++ b/src/Web/WebSPA/WebSPA.csproj @@ -28,6 +28,11 @@ + + + + + diff --git a/src/Web/WebSPA/eventFlowConfig.json b/src/Web/WebSPA/eventFlowConfig.json new file mode 100644 index 000000000..0ddeee125 --- /dev/null +++ b/src/Web/WebSPA/eventFlowConfig.json @@ -0,0 +1,24 @@ +{ + "inputs": [ + { + "type": "Microsoft.Extensions.Logging" + } + ], + "filters": [ + ], + "outputs": [ + { + "type": "ApplicationInsights", + "instrumentationKey": "" + }, + { + "type": "StdOutput" + } + ], + "schemaVersion": "2016-08-11", + "extensions": [], + "healthReporter": { + "type": "CsvHealthReporter", + "logFileFolder": "/app/log" + } +} \ No newline at end of file