diff --git a/source/settlement-report/Orchestration.SettlementReports/host.json b/source/settlement-report/Orchestration.SettlementReports/host.json index d635d6a..07be6d1 100644 --- a/source/settlement-report/Orchestration.SettlementReports/host.json +++ b/source/settlement-report/Orchestration.SettlementReports/host.json @@ -12,6 +12,9 @@ "isEnabled": true, "excludedTypes": "Request" }, + "logLevel": { + "default": "Information" + }, "enableLiveMetricsFilters": true } } diff --git a/source/settlement-report/SettlementReports.Infrastructure/Experimental/DatabricksContextBase.cs b/source/settlement-report/SettlementReports.Infrastructure/Experimental/DatabricksContextBase.cs index 219c49a..cae6a7e 100644 --- a/source/settlement-report/SettlementReports.Infrastructure/Experimental/DatabricksContextBase.cs +++ b/source/settlement-report/SettlementReports.Infrastructure/Experimental/DatabricksContextBase.cs @@ -20,6 +20,7 @@ using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; namespace Energinet.DataHub.SettlementReport.Infrastructure.Experimental; @@ -31,10 +32,11 @@ public abstract class DatabricksContextBase : IDisposable protected DatabricksContextBase( DatabricksSqlWarehouseQueryExecutor databricksSqlWarehouseQueryExecutor, - IOptions options) + IOptions options, + ILoggerFactory loggerFactory) { _dbContext = new DbContextCore(OnModelCreating); - _executor = new DatabricksSqlQueryExecutor(_dbContext, databricksSqlWarehouseQueryExecutor, options); + _executor = new DatabricksSqlQueryExecutor(_dbContext, databricksSqlWarehouseQueryExecutor, options, loggerFactory); } public void Dispose() diff --git a/source/settlement-report/SettlementReports.Infrastructure/Experimental/DatabricksSqlQueryBuilder.cs b/source/settlement-report/SettlementReports.Infrastructure/Experimental/DatabricksSqlQueryBuilder.cs index 2a92a1a..43e9ddd 100644 --- a/source/settlement-report/SettlementReports.Infrastructure/Experimental/DatabricksSqlQueryBuilder.cs +++ b/source/settlement-report/SettlementReports.Infrastructure/Experimental/DatabricksSqlQueryBuilder.cs @@ -20,6 +20,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; namespace Energinet.DataHub.SettlementReport.Infrastructure.Experimental; @@ -28,11 +29,16 @@ public sealed class DatabricksSqlQueryBuilder { private readonly DbContext _context; private readonly IOptions _options; + private readonly ILogger _logger; - public DatabricksSqlQueryBuilder(DbContext context, IOptions options) + public DatabricksSqlQueryBuilder( + DbContext context, + IOptions options, + ILoggerFactory loggerFactory) { _context = context; _options = options; + _logger = loggerFactory.CreateLogger(); } public DatabricksStatement Build(DatabricksSqlQueryable query) @@ -101,7 +107,10 @@ private string PrepareSqlStatement(DatabricksSqlQueryable query, Func $"Parameter Name: {x.Key} | Value: {x.Value}")); + _logger.LogInformation(logString); + return translated; } private string TranslateTransactToAnsi(StringBuilder transactSqlQuery) diff --git a/source/settlement-report/SettlementReports.Infrastructure/Experimental/DatabricksSqlQueryExecutor.cs b/source/settlement-report/SettlementReports.Infrastructure/Experimental/DatabricksSqlQueryExecutor.cs index 8cb86cf..11263ba 100644 --- a/source/settlement-report/SettlementReports.Infrastructure/Experimental/DatabricksSqlQueryExecutor.cs +++ b/source/settlement-report/SettlementReports.Infrastructure/Experimental/DatabricksSqlQueryExecutor.cs @@ -17,6 +17,7 @@ using Energinet.DataHub.Core.Databricks.SqlStatementExecution.Formats; using Energinet.DataHub.SettlementReport.Common.Infrastructure.Options; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; namespace Energinet.DataHub.SettlementReport.Infrastructure.Experimental; @@ -30,9 +31,10 @@ public sealed class DatabricksSqlQueryExecutor public DatabricksSqlQueryExecutor( DbContext dbContext, DatabricksSqlWarehouseQueryExecutor databricksSqlWarehouseQueryExecutor, - IOptions options) + IOptions options, + ILoggerFactory loggerFactory) { - _sqlQueryBuilder = new DatabricksSqlQueryBuilder(dbContext, options); + _sqlQueryBuilder = new DatabricksSqlQueryBuilder(dbContext, options, loggerFactory); _sqlRowHydrator = new DatabricksSqlRowHydrator(); _databricksSqlWarehouseQueryExecutor = databricksSqlWarehouseQueryExecutor; } diff --git a/source/settlement-report/SettlementReports.Infrastructure/Persistence/Databricks/SettlementReportDatabricksContext.cs b/source/settlement-report/SettlementReports.Infrastructure/Persistence/Databricks/SettlementReportDatabricksContext.cs index 0acea5e..dfc910a 100644 --- a/source/settlement-report/SettlementReports.Infrastructure/Persistence/Databricks/SettlementReportDatabricksContext.cs +++ b/source/settlement-report/SettlementReports.Infrastructure/Persistence/Databricks/SettlementReportDatabricksContext.cs @@ -16,6 +16,7 @@ using Energinet.DataHub.SettlementReport.Common.Infrastructure.Options; using Energinet.DataHub.SettlementReport.Infrastructure.Experimental; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; namespace Energinet.DataHub.SettlementReport.Infrastructure.Persistence.Databricks; @@ -26,8 +27,9 @@ public sealed class SettlementReportDatabricksContext : DatabricksContextBase, I public SettlementReportDatabricksContext( IOptions deltaTableOptions, - DatabricksSqlWarehouseQueryExecutor sqlWarehouseQueryExecutor) - : base(sqlWarehouseQueryExecutor, deltaTableOptions) + DatabricksSqlWarehouseQueryExecutor sqlWarehouseQueryExecutor, + ILoggerFactory loggerFactory) + : base(sqlWarehouseQueryExecutor, deltaTableOptions, loggerFactory) { _deltaTableOptions = deltaTableOptions; } diff --git a/source/settlement-report/SettlementReports.IntegrationTests/Application/SettlementReports/SettlementReportFileRequestHandlerIntegrationTests.cs b/source/settlement-report/SettlementReports.IntegrationTests/Application/SettlementReports/SettlementReportFileRequestHandlerIntegrationTests.cs index bbd0d35..5a6163e 100644 --- a/source/settlement-report/SettlementReports.IntegrationTests/Application/SettlementReports/SettlementReportFileRequestHandlerIntegrationTests.cs +++ b/source/settlement-report/SettlementReports.IntegrationTests/Application/SettlementReports/SettlementReportFileRequestHandlerIntegrationTests.cs @@ -22,6 +22,8 @@ using Energinet.DataHub.SettlementReport.Interfaces.Models; using Energinet.DataHub.SettlementReport.Interfaces.SettlementReports_v2.Models; using Energinet.DataHub.Wholesale.CalculationResults.IntegrationTests.Fixtures; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; using Moq; using NodaTime; @@ -58,7 +60,7 @@ public SettlementReportFileRequestHandlerIntegrationTests( Fixture.Inject(mockedOptions); var sqlWarehouseQueryExecutor = _databricksSqlStatementApiFixture.GetDatabricksExecutor(); - var databricksContext = new SettlementReportDatabricksContext(mockedOptions.Object, sqlWarehouseQueryExecutor); + var databricksContext = new SettlementReportDatabricksContext(mockedOptions.Object, sqlWarehouseQueryExecutor, NullLoggerFactory.Instance); var settlementReportDataRepository = new SettlementReportEnergyResultRepository(databricksContext); var settlementReportWholesaleRepository = new SettlementReportWholesaleRepository(databricksContext); @@ -66,23 +68,28 @@ public SettlementReportFileRequestHandlerIntegrationTests( var settlementReportMeteringPointMasterDataRepository = new SettlementReportMeteringPointMasterDataRepository(new SettlementReportDatabricksContext( mockedOptions.Object, - sqlWarehouseQueryExecutor)); + sqlWarehouseQueryExecutor, + NullLoggerFactory.Instance)); var settlementReportMeteringPointTimeSeriesResultRepository = new SettlementReportMeteringPointTimeSeriesResultRepository(new SettlementReportDatabricksContext( mockedOptions.Object, - sqlWarehouseQueryExecutor)); + sqlWarehouseQueryExecutor, + NullLoggerFactory.Instance)); var settlementReportMonthlyAmountRepository = new SettlementReportMonthlyAmountRepository(new SettlementReportDatabricksContext( mockedOptions.Object, - sqlWarehouseQueryExecutor)); + sqlWarehouseQueryExecutor, + NullLoggerFactory.Instance)); var settlementReportChargePriceRepository = new SettlementReportChargePriceRepository(new SettlementReportDatabricksContext( mockedOptions.Object, - sqlWarehouseQueryExecutor)); + sqlWarehouseQueryExecutor, + NullLoggerFactory.Instance)); var settlementReportMonthlyAmountTotalRepository = new SettlementReportMonthlyAmountTotalRepository(new SettlementReportDatabricksContext( mockedOptions.Object, - sqlWarehouseQueryExecutor)); + sqlWarehouseQueryExecutor, + NullLoggerFactory.Instance)); Fixture.Inject(new SettlementReportFileGeneratorFactory( settlementReportDataRepository, diff --git a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportChargeLinkPeriodsRepositoryTests.cs b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportChargeLinkPeriodsRepositoryTests.cs index cb6f481..a8874e4 100644 --- a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportChargeLinkPeriodsRepositoryTests.cs +++ b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportChargeLinkPeriodsRepositoryTests.cs @@ -21,6 +21,9 @@ using Energinet.DataHub.SettlementReport.Interfaces.SettlementReports_v2.Models; using Energinet.DataHub.Wholesale.CalculationResults.IntegrationTests.Fixtures; using FluentAssertions; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Moq; using Xunit; namespace Energinet.DataHub.Wholesale.CalculationResults.IntegrationTests.Infrastructure.SettlementReports_v2; @@ -39,7 +42,8 @@ public SettlementReportChargeLinkPeriodsRepositoryTests(MigrationsFreeDatabricks Fixture.Inject(new SettlementReportDatabricksContext( _databricksSqlStatementApiFixture.DatabricksSchemaManager.DeltaTableOptions, - _databricksSqlStatementApiFixture.GetDatabricksExecutor())); + _databricksSqlStatementApiFixture.GetDatabricksExecutor(), + NullLoggerFactory.Instance)); } [Fact(Skip = "Performance testing")] diff --git a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportChargePricesRepositoryTests.cs b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportChargePricesRepositoryTests.cs index 103c405..763c7de 100644 --- a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportChargePricesRepositoryTests.cs +++ b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportChargePricesRepositoryTests.cs @@ -20,6 +20,9 @@ using Energinet.DataHub.SettlementReport.Interfaces.Models; using Energinet.DataHub.SettlementReport.Interfaces.SettlementReports_v2.Models; using Energinet.DataHub.Wholesale.CalculationResults.IntegrationTests.Fixtures; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Moq; using Xunit; namespace Energinet.DataHub.Wholesale.CalculationResults.IntegrationTests.Infrastructure.SettlementReports_v2; @@ -50,7 +53,8 @@ public SettlementReportChargePricesRepositoryTests(MigrationsFreeDatabricksSqlSt Fixture.Inject(new SettlementReportDatabricksContext( _databricksSqlStatementApiFixture.DatabricksSchemaManager.DeltaTableOptions, - _databricksSqlStatementApiFixture.GetDatabricksExecutor())); + _databricksSqlStatementApiFixture.GetDatabricksExecutor(), + NullLoggerFactory.Instance)); } [Fact(Skip = "Performance testing")] diff --git a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportEnergyResultRepositoryTests.cs b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportEnergyResultRepositoryTests.cs index 0a4d75c..6d423bc 100644 --- a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportEnergyResultRepositoryTests.cs +++ b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportEnergyResultRepositoryTests.cs @@ -20,6 +20,9 @@ using Energinet.DataHub.SettlementReport.Interfaces.Models; using Energinet.DataHub.SettlementReport.Interfaces.SettlementReports_v2.Models; using Energinet.DataHub.Wholesale.CalculationResults.IntegrationTests.Fixtures; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Moq; using Xunit; namespace Energinet.DataHub.Wholesale.CalculationResults.IntegrationTests.Infrastructure.SettlementReports_v2; @@ -38,7 +41,8 @@ public SettlementReportEnergyResultRepositoryTests(MigrationsFreeDatabricksSqlSt Fixture.Inject(new SettlementReportDatabricksContext( _databricksSqlStatementApiFixture.DatabricksSchemaManager.DeltaTableOptions, - _databricksSqlStatementApiFixture.GetDatabricksExecutor())); + _databricksSqlStatementApiFixture.GetDatabricksExecutor(), + NullLoggerFactory.Instance)); } [Fact(Skip = "Performance testing")] diff --git a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportMeteringPointMasterDataRepositoryTests.cs b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportMeteringPointMasterDataRepositoryTests.cs index 5d6264a..a4f1071 100644 --- a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportMeteringPointMasterDataRepositoryTests.cs +++ b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportMeteringPointMasterDataRepositoryTests.cs @@ -21,6 +21,9 @@ using Energinet.DataHub.SettlementReport.Interfaces.SettlementReports_v2.Models; using Energinet.DataHub.Wholesale.CalculationResults.IntegrationTests.Fixtures; using FluentAssertions; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Moq; using Xunit; namespace Energinet.DataHub.Wholesale.CalculationResults.IntegrationTests.Infrastructure.SettlementReports_v2; @@ -39,7 +42,8 @@ public SettlementReportMeteringPointMasterDataRepositoryTests(MigrationsFreeData Fixture.Inject(new SettlementReportDatabricksContext( _databricksSqlStatementApiFixture.DatabricksSchemaManager.DeltaTableOptions, - _databricksSqlStatementApiFixture.GetDatabricksExecutor())); + _databricksSqlStatementApiFixture.GetDatabricksExecutor(), + NullLoggerFactory.Instance)); } [Fact(Skip = "Performance testing")] diff --git a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportMeteringPointTimeSeriesResultRepositoryTests.cs b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportMeteringPointTimeSeriesResultRepositoryTests.cs index 638db09..fc9c854 100644 --- a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportMeteringPointTimeSeriesResultRepositoryTests.cs +++ b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportMeteringPointTimeSeriesResultRepositoryTests.cs @@ -21,6 +21,9 @@ using Energinet.DataHub.SettlementReport.Interfaces.Models; using Energinet.DataHub.SettlementReport.Interfaces.SettlementReports_v2.Models; using Energinet.DataHub.Wholesale.CalculationResults.IntegrationTests.Fixtures; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Moq; using Xunit; namespace Energinet.DataHub.Wholesale.CalculationResults.IntegrationTests.Infrastructure.SettlementReports_v2; @@ -39,7 +42,8 @@ public SettlementReportMeteringPointTimeSeriesResultRepositoryTests(MigrationsFr Fixture.Inject(new SettlementReportDatabricksContext( _databricksSqlStatementApiFixture.DatabricksSchemaManager.DeltaTableOptions, - _databricksSqlStatementApiFixture.GetDatabricksExecutor())); + _databricksSqlStatementApiFixture.GetDatabricksExecutor(), + NullLoggerFactory.Instance)); } [Fact] diff --git a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportMonthlyAmountRepositoryTests.cs b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportMonthlyAmountRepositoryTests.cs index aa93945..cef0810 100644 --- a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportMonthlyAmountRepositoryTests.cs +++ b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportMonthlyAmountRepositoryTests.cs @@ -20,6 +20,9 @@ using Energinet.DataHub.SettlementReport.Interfaces.Models; using Energinet.DataHub.SettlementReport.Interfaces.SettlementReports_v2.Models; using Energinet.DataHub.Wholesale.CalculationResults.IntegrationTests.Fixtures; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Moq; using Xunit; namespace Energinet.DataHub.Wholesale.CalculationResults.IntegrationTests.Infrastructure.SettlementReports_v2; @@ -38,7 +41,8 @@ public SettlementReportMonthlyAmountRepositoryTests(MigrationsFreeDatabricksSqlS Fixture.Inject(new SettlementReportDatabricksContext( _databricksSqlStatementApiFixture.DatabricksSchemaManager.DeltaTableOptions, - _databricksSqlStatementApiFixture.GetDatabricksExecutor())); + _databricksSqlStatementApiFixture.GetDatabricksExecutor(), + NullLoggerFactory.Instance)); } [Fact(Skip = "Performance testing")] diff --git a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportMonthlyAmountTotalRepositoryTests.cs b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportMonthlyAmountTotalRepositoryTests.cs index bcf9955..f59d8b8 100644 --- a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportMonthlyAmountTotalRepositoryTests.cs +++ b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportMonthlyAmountTotalRepositoryTests.cs @@ -20,6 +20,9 @@ using Energinet.DataHub.SettlementReport.Interfaces.Models; using Energinet.DataHub.SettlementReport.Interfaces.SettlementReports_v2.Models; using Energinet.DataHub.Wholesale.CalculationResults.IntegrationTests.Fixtures; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Moq; using Xunit; namespace Energinet.DataHub.Wholesale.CalculationResults.IntegrationTests.Infrastructure.SettlementReports_v2; @@ -38,7 +41,8 @@ public SettlementReportMonthlyAmountTotalRepositoryTests(MigrationsFreeDatabrick Fixture.Inject(new SettlementReportDatabricksContext( _databricksSqlStatementApiFixture.DatabricksSchemaManager.DeltaTableOptions, - _databricksSqlStatementApiFixture.GetDatabricksExecutor())); + _databricksSqlStatementApiFixture.GetDatabricksExecutor(), + NullLoggerFactory.Instance)); } [Fact(Skip = "Performance testing")] diff --git a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportWholesaleRepositoryTests.cs b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportWholesaleRepositoryTests.cs index 5dd89fc..092cfc7 100644 --- a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportWholesaleRepositoryTests.cs +++ b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/SettlementReportWholesaleRepositoryTests.cs @@ -20,6 +20,9 @@ using Energinet.DataHub.SettlementReport.Interfaces.Models; using Energinet.DataHub.SettlementReport.Interfaces.SettlementReports_v2.Models; using Energinet.DataHub.Wholesale.CalculationResults.IntegrationTests.Fixtures; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Moq; using Xunit; namespace Energinet.DataHub.Wholesale.CalculationResults.IntegrationTests.Infrastructure.SettlementReports_v2; @@ -38,7 +41,8 @@ public SettlementReportWholesaleRepositoryTests(MigrationsFreeDatabricksSqlState Fixture.Inject(new SettlementReportDatabricksContext( _databricksSqlStatementApiFixture.DatabricksSchemaManager.DeltaTableOptions, - _databricksSqlStatementApiFixture.GetDatabricksExecutor())); + _databricksSqlStatementApiFixture.GetDatabricksExecutor(), + NullLoggerFactory.Instance)); } [Fact(Skip = "Performance testing")]