Created
September 20, 2012 13:23
-
-
Save bm4cs/3755875 to your computer and use it in GitHub Desktop.
BlogStreamInsightAustin03
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Convert points to signals | |
var fooEdgeEvents = | |
from e in fooPointEvents | |
.AlterEventDuration(e => TimeSpan.MaxValue) | |
.ClipEventDuration(fooMessagesObservable, (e1, e2) => (e1.MessageId == e2.MessageId)) | |
select e; | |
var latencyQuery = | |
from e1 in fooEdgeEvents | |
join e2 in barPointEvents | |
on e1.MessageId equals e2.MessageId | |
select new | |
{ | |
StoreId = e1.StoreId, | |
LatencyMs = e2.Timestamp.Subtract(e1.Timestamp).Milliseconds | |
}; | |
var averageLatencyQuery = | |
from e1 in latencyQuery | |
group e1 by e1.StoreId | |
into storeGroup from win in storeGroup.TumblingWindow(TimeSpan.FromSeconds(60)) | |
select new MessageLatency() | |
{ | |
Id = null, | |
StoreId = storeGroup.Key, | |
AverageLatency = win.Avg(e => e.LatencyMs), | |
DateTime = DateTime.UtcNow | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment