Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Src/StackifyLib/Internal/Logs/LogClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
//using System.Web.Configuration;
using Newtonsoft.Json;
Expand Down Expand Up @@ -123,6 +124,11 @@ public bool ErrorShouldBeSent(StackifyError error)
return governor.ErrorShouldBeSent(error);
}



private static long _lastEpochMs = 0;
private static int _millisecondCount = 0;

public void QueueMessage(LogMsg msg)
{
if (msg == null) return;
Expand All @@ -139,6 +145,21 @@ public void QueueMessage(LogMsg msg)
isError = 1;
}

// works on the assumption that the epochMS will always be incrementing as it reaches this point
if (_lastEpochMs < msg.EpochMs)
{
// reset counter if we are no longer in the same ms
//https://msdn.microsoft.com/en-us/library/system.threading.interlocked_methods(v=vs.110).aspx
Interlocked.Exchange(ref _lastEpochMs, msg.EpochMs);
Interlocked.Exchange(ref _millisecondCount, 0);
msg.Order = 0;
}
else if (_lastEpochMs == msg.EpochMs)
{
msg.Order = Interlocked.Increment(ref _millisecondCount);
}
// else defaulted to 0

//Used by Stackify profiler only
if (Logger.PrefixEnabled())
{
Expand Down
3 changes: 3 additions & 0 deletions Src/StackifyLib/Models/LogMsgGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public LogMsg()
[JsonProperty]
public List<string> Tags { get; set; }

[JsonProperty]
public int Order { get; set; }

[JsonIgnore]
public LogMsgGroup AppDetails { get; set; }

Expand Down