File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 44using System . Linq ;
55using System . Net ;
66using System . Text ;
7+ using System . Threading ;
78using System . Threading . Tasks ;
89//using System.Web.Configuration;
910using Newtonsoft . Json ;
@@ -123,6 +124,11 @@ public bool ErrorShouldBeSent(StackifyError error)
123124 return governor . ErrorShouldBeSent ( error ) ;
124125 }
125126
127+
128+
129+ private static long _lastEpochMs = 0 ;
130+ private static int _millisecondCount = 0 ;
131+
126132 public void QueueMessage ( LogMsg msg )
127133 {
128134 if ( msg == null ) return ;
@@ -139,6 +145,21 @@ public void QueueMessage(LogMsg msg)
139145 isError = 1 ;
140146 }
141147
148+ // works on the assumption that the epochMS will always be incrementing as it reaches this point
149+ if ( _lastEpochMs < msg . EpochMs )
150+ {
151+ // reset counter if we are no longer in the same ms
152+ //https://msdn.microsoft.com/en-us/library/system.threading.interlocked_methods(v=vs.110).aspx
153+ Interlocked . Exchange ( ref _lastEpochMs , msg . EpochMs ) ;
154+ Interlocked . Exchange ( ref _millisecondCount , 0 ) ;
155+ msg . Order = 0 ;
156+ }
157+ else if ( _lastEpochMs == msg . EpochMs )
158+ {
159+ msg . Order = Interlocked . Increment ( ref _millisecondCount ) ;
160+ }
161+ // else defaulted to 0
162+
142163 //Used by Stackify profiler only
143164 if ( Logger . PrefixEnabled ( ) )
144165 {
Original file line number Diff line number Diff line change @@ -95,6 +95,9 @@ public LogMsg()
9595 [ JsonProperty ]
9696 public List < string > Tags { get ; set ; }
9797
98+ [ JsonProperty ]
99+ public int Order { get ; set ; }
100+
98101 [ JsonIgnore ]
99102 public LogMsgGroup AppDetails { get ; set ; }
100103
You can’t perform that action at this time.
0 commit comments