Skip to content

Commit 296a6f4

Browse files
committed
Update DefaultKeyGenerator.cs
1 parent 5a3c34b commit 296a6f4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Serilog.Sinks.AzureTableStorage/Sinks/AzureTableStorage/DefaultKeyGenerator.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff 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.

0 commit comments

Comments
 (0)