File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-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,13 @@ public bool ErrorShouldBeSent(StackifyError error)
123124 return governor . ErrorShouldBeSent ( error ) ;
124125 }
125126
127+
128+
129+ private long ? LastEpochMs = 0 ;
130+ private object locker = new object ( ) ;
131+ private int count ;
132+
133+
126134 public void QueueMessage ( LogMsg msg )
127135 {
128136 if ( msg == null ) return ;
@@ -139,6 +147,23 @@ public void QueueMessage(LogMsg msg)
139147 isError = 1 ;
140148 }
141149
150+ // works on the assumption that the epochMS will always be incrementing as it reaches this point
151+ if ( LastEpochMs < msg . EpochMs )
152+ {
153+ // reset counter if we are no longer in the same ms
154+ lock ( locker )
155+ {
156+ //https://msdn.microsoft.com/en-us/library/system.threading.interlocked_methods(v=vs.110).aspx
157+ LastEpochMs = msg . EpochMs ;
158+ Interlocked . Exchange ( ref count , 0 ) ;
159+ msg . Order = 0 ;
160+ }
161+ }
162+ else
163+ {
164+ msg . Order = Interlocked . Increment ( ref count ) ;
165+ }
166+
142167 //Used by Stackify profiler only
143168 if ( Logger . PrefixEnabled ( ) )
144169 {
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 ( PropertyName = "order" ) ]
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