File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
src/Serilog.Sinks.AzureTableStorage/Sinks/AzureTableStorage Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -17,10 +17,15 @@ public class DefaultKeyGenerator : IKeyGenerator
1717 /// <remarks>The partition key based on the Timestamp rounded to the nearest 5 min</remarks>
1818 public virtual string GeneratePartitionKey ( LogEvent logEvent )
1919 {
20+ // log entries are partitioned in 5 minute blocks.
21+ // batch insert is used to get around time based partition key performance issues
22+ // values are created in reverse chronological order so newest are always first
23+
2024 var utcEventTime = logEvent . Timestamp . UtcDateTime ;
2125 var roundedEvent = Round ( utcEventTime , TimeSpan . FromMinutes ( 5 ) ) ;
2226
23- return $ "0{ roundedEvent . Ticks } ";
27+ // create a 19 character String for reverse chronological ordering.
28+ return $ "{ DateTime . MaxValue . Ticks - roundedEvent . Ticks : D19} ";
2429 }
2530
2631 /// <summary>
@@ -30,6 +35,8 @@ public virtual string GeneratePartitionKey(LogEvent logEvent)
3035 /// <returns>The generated RowKey</returns>
3136 public virtual string GenerateRowKey ( LogEvent logEvent )
3237 {
38+ // row key created in reverse chronological order so newest are always first
39+
3340 var utcEventTime = logEvent . Timestamp . UtcDateTime ;
3441
3542 // create a 19 character String for reverse chronological ordering.
You can’t perform that action at this time.
0 commit comments