From 5b2e28694fe641314799ba8c8ea403e7f69d1cca Mon Sep 17 00:00:00 2001 From: kungurtsev Date: Wed, 10 Aug 2022 16:41:27 +0500 Subject: [PATCH] log windows --- Vostok.Hercules.Consumers/Helpers/Window.cs | 3 +++ Vostok.Hercules.Consumers/Helpers/Windows.cs | 4 ++++ Vostok.Hercules.Consumers/WindowedStreamConsumer.cs | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/Vostok.Hercules.Consumers/Helpers/Window.cs b/Vostok.Hercules.Consumers/Helpers/Window.cs index 6d99ce6..d3583f2 100644 --- a/Vostok.Hercules.Consumers/Helpers/Window.cs +++ b/Vostok.Hercules.Consumers/Helpers/Window.cs @@ -55,5 +55,8 @@ public bool ExistsForTooLong(bool restartPhase = false) public void Flush() => implementation.Flush(End); + + public override string ToString() => + $"{nameof(FirstEventCoordinates)}: {FirstEventCoordinates}, {nameof(Start)}: {Start}, {nameof(End)}: {End}, {nameof(period)}: {period}, {nameof(lag)}: {lag}, {nameof(lastEventAdded)}: {lastEventAdded}, {nameof(EventsCount)}: {EventsCount}"; } } \ No newline at end of file diff --git a/Vostok.Hercules.Consumers/Helpers/Windows.cs b/Vostok.Hercules.Consumers/Helpers/Windows.cs index 7604861..ea19289 100644 --- a/Vostok.Hercules.Consumers/Helpers/Windows.cs +++ b/Vostok.Hercules.Consumers/Helpers/Windows.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Vostok.Commons.Time; using Vostok.Hercules.Client.Abstractions.Models; @@ -84,5 +85,8 @@ private Window CreateWindow(T @event, DateTimeOffset timestamp, StreamC var result = new Window(settings.CreateWindow(key), coordinates, start, start + period, period, lag); return result; } + + public override string ToString() => + $"{nameof(LastEventAdded)}: {LastEventAdded}, {nameof(key)}: {key}, {nameof(minimumAllowedTimestamp)}: {minimumAllowedTimestamp}, {nameof(maximumObservedTimestamp)}: {maximumObservedTimestamp} {nameof(windows)}:\n{string.Join("\n", windows.Select(w => w.ToString()))}"; } } \ No newline at end of file diff --git a/Vostok.Hercules.Consumers/WindowedStreamConsumer.cs b/Vostok.Hercules.Consumers/WindowedStreamConsumer.cs index 89176f1..a544fb4 100644 --- a/Vostok.Hercules.Consumers/WindowedStreamConsumer.cs +++ b/Vostok.Hercules.Consumers/WindowedStreamConsumer.cs @@ -79,6 +79,7 @@ private async Task Stop(StreamCoordinates rightCoordinates) { await settings.LeftCoordinatesStorage.AdvanceAsync(leftCoordinates).ConfigureAwait(false); LogCoordinates("Stop", leftCoordinates, rightCoordinates); + LogWindows(); } private async Task Restart(StreamCoordinates rightCoordinates) @@ -135,6 +136,7 @@ private async Task RestartWindows(StreamCoordinates rightCoordinates) FlushWindows(); LogCoordinates("Restarted", leftCoordinates, rightCoordinates); + LogWindows(); } private async Task RestartPartition(int partition, int partitionsCount, long start, long end) @@ -228,5 +230,8 @@ private void LogCoordinates(string message, StreamCoordinates left, StreamCoordi LogCoordinates(message + " left", left); LogCoordinates(message + " right", right); } + + private void LogWindows() => + log.Info("Windows: {{Windows}}.", windows.ToString()); } } \ No newline at end of file