Skip to content

Instantly share code, notes, and snippets.

@dylan-asos
Last active January 23, 2019 14:30
Show Gist options
  • Save dylan-asos/6a2f0394108618fdc64754e6d4392a04 to your computer and use it in GitHub Desktop.
Save dylan-asos/6a2f0394108618fdc64754e6d4392a04 to your computer and use it in GitHub Desktop.
public class EventStreamBacklogTracing
{
public static void LogSequenceDifference(EventData message, PartitionContext context)
{
var messageSequence = message.SystemProperties.SequenceNumber;
var lastEnqueuedSequence = context.RuntimeInformation.LastSequenceNumber;
var sequenceDifference = lastEnqueuedSequence - messageSequence;
var client = new TelemetryClient();
var metricData = client.GetMetric("PartitionSequenceDifference", "PartitionId", "ConsumerGroupName", "EventHubPath");
metricData.TrackValue(sequenceDifference, context.PartitionId, context.ConsumerGroupName, context.EventHubPath);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment