Skip to content

Instantly share code, notes, and snippets.

@bm4cs
Created September 20, 2012 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bm4cs/3755875 to your computer and use it in GitHub Desktop.
Save bm4cs/3755875 to your computer and use it in GitHub Desktop.
BlogStreamInsightAustin03
// 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