-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring and performance optimizations
Refactoring * Removed DataTableCreator from class MsSqlServerSink. Pushed it down to SqlBulkBatchWriter. This also made it possible to remove reference to System.Data in MsSqlServerSink. * Removed DataTableCreator from SinkDependencies. * Removed IBulkBatchWriter interface from SqlInsertStatementWriter. MSSqlServerSink class now has separate instances of ISqlBulkBatchWriter and ISqlLogEventWriter and chooses which one to use based on sink option `UseSqlBulkCopy`. * Added new class SqlCommandFactory with interface ISqlCommandFactory Performance optimizations in batched sink * Generate schema and table string only once and do not use string.Format(). * Do not cast on each column of each log event. Performance optimizations in audit sink * Render INSERT string only once and not for each log event since it will not change between log events. * Do not create a separate SqlCommand for each log event. Reuse the same and set only new SqlConnection, CommandText and parameters for each log event. Added new tests and adapted existing ones.
- Loading branch information
Showing
28 changed files
with
494 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Platform/ISqlBulkBatchWriter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Serilog.Events; | ||
|
||
namespace Serilog.Sinks.MSSqlServer.Platform | ||
{ | ||
internal interface ISqlBulkBatchWriter | ||
internal interface ISqlBulkBatchWriter : IDisposable | ||
{ | ||
Task WriteBatch(IEnumerable<LogEvent> events, DataTable dataTable); | ||
Task WriteBatch(IEnumerable<LogEvent> events); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Platform/ISqlCommandFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Serilog.Sinks.MSSqlServer.Platform.SqlClient; | ||
|
||
namespace Serilog.Sinks.MSSqlServer.Platform | ||
{ | ||
internal interface ISqlCommandFactory | ||
{ | ||
ISqlCommandWrapper CreateCommand(ISqlConnectionWrapper sqlConnection); | ||
ISqlCommandWrapper CreateCommand(string cmdText, ISqlConnectionWrapper sqlConnection); | ||
} | ||
} |
9 changes: 7 additions & 2 deletions
9
src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Platform/ISqlLogEventWriter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
using Serilog.Events; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Serilog.Events; | ||
|
||
namespace Serilog.Sinks.MSSqlServer.Platform | ||
{ | ||
internal interface ISqlLogEventWriter | ||
internal interface ISqlLogEventWriter : IDisposable | ||
{ | ||
void WriteEvent(LogEvent logEvent); | ||
|
||
Task WriteEvents(IEnumerable<LogEvent> events); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.