using Sony.Filtr.Utility.Extensions; using System.Diagnostics.Tracing; namespace Sony.Filtr.Tasks.EventSource { public class ApolloUpdatePlaylistInfoEventSource : System.Diagnostics.Tracing.EventSource { public static readonly ApolloUpdatePlaylistInfoEventSource Log = new ApolloUpdatePlaylistInfoEventSource(); private ApolloUpdatePlaylistInfoEventSource() { } public void PrepareDataStart() { this.WriteEvent(1); } public void PrepareDataStop() { this.WriteEvent(2); } [NonEvent] public void ProcessPlaylistStart(string playlistId, System.Diagnostics.Stopwatch sw, NLog.Logger logger) { sw.Restart(); this.ProcessPlaylistInternalStart(playlistId); } private void ProcessPlaylistInternalStart(string playlistId) { if (this.IsEnabled()) { this.WriteEvent(3, playlistId); } } [NonEvent] public void ProcessPlaylistStop(string playlistId, System.DateTime processStartTime, NLog.Logger logger) { //logger.Warn($@"UPDATED PLAYLIST {playlistId}. PROCESS TIME: {System.DateTime.Now - processStartTime} milliseconds"); this.ProcessPlaylistInternalStop(playlistId); } private void ProcessPlaylistInternalStop(string playlistId) { if (this.IsEnabled()) { this.WriteEvent(4, playlistId); } } public void GetSpotifyPlaylistStart(string playlistId) { if (this.IsEnabled()) { this.WriteEvent(5, playlistId); } } public void GetSpotifyPlaylistStop(string playlistId) { if (this.IsEnabled()) { this.WriteEvent(6, playlistId); } } public void RemovePlaylistStart(string playlistId) { if (this.IsEnabled()) { this.WriteEvent(7, playlistId); } } public void RemovePlaylistStop(string playlistId) { if (this.IsEnabled()) { this.WriteEvent(8, playlistId); } } internal void SaveSpotifyPlaylistStart(string playlistId) { if (this.IsEnabled()) { this.WriteEvent(9, playlistId); } } internal void SaveSpotifyPlaylistStop(string playlistId) { if (this.IsEnabled()) { this.WriteEvent(10, playlistId); } } public void UpdateEditorialPlaylistsParallelStart(string playlistId) { if (this.IsEnabled()) { this.WriteEvent(11, playlistId); } } public void UpdateEditorialPlaylistsParallelStop(string playlistId) { if (this.IsEnabled()) { this.WriteEvent(12, playlistId); } } [NonEvent] public void PlaylistGetBlockStart(string playlistId, System.Diagnostics.Stopwatch sw, NLog.Logger logger) { sw.Restart(); //logger.Warn($"Get Spotify data block START for PLAYLIST {playlistId}. {System.DateTime.Now.ToString("hh:mm:ss fff")}"); this.PlaylistGetBlockInternalStart(playlistId); } private void PlaylistGetBlockInternalStart(string playlistId) { if (this.IsEnabled()) { this.WriteEvent(13, playlistId); } } [NonEvent] public void PlaylistGetBlockStop(string playlistId, System.Diagnostics.Stopwatch sw, NLog.Logger logger) { sw.Stop(); //logger.Warn($"Get Spotify data block END for PLAYLIST {playlistId}. {System.DateTime.Now.ToString("hh:mm:ss fff")} Duration: {sw.Elapsed.TotalMilliseconds} ms"); this.PlaylistGetBlockInternalStop(playlistId); } private void PlaylistGetBlockInternalStop(string playlistId) { if (this.IsEnabled()) { this.WriteEvent(14, playlistId); } } [NonEvent] public void PlaylistProcessBlockStart(string playlistId, System.Diagnostics.Stopwatch sw, NLog.Logger logger) { sw.Restart(); //logger.Warn($"process playlist block START for PLAYLIST {playlistId}. {System.DateTime.Now.ToString("hh:mm:ss fff")}"); this.PlaylistProcessBlockInternalStart(playlistId); } private void PlaylistProcessBlockInternalStart(string playlistId) { if (this.IsEnabled()) { this.WriteEvent(15, playlistId); } } [NonEvent] public void PlaylistProcessBlockStop(string playlistId, System.Diagnostics.Stopwatch sw, NLog.Logger logger) { sw.Stop(); //logger.Warn($"process playlist block END for PLAYLIST {playlistId}. {System.DateTime.Now.ToString("hh:mm:ss fff")} Duration: {sw.Elapsed.TotalMilliseconds} ms"); this.PlaylistProcessBlockInternalStop(playlistId); } private void PlaylistProcessBlockInternalStop(string playlistId) { if (this.IsEnabled()) { this.WriteEvent(16, playlistId); } } [NonEvent] public void PlaylistSaveBlockStart(string playlistId, System.Diagnostics.Stopwatch sw, NLog.Logger logger) { sw.Restart(); //logger.Warn($"Save playlist block START for PLAYLIST {playlistId}. {System.DateTime.Now.ToString("hh:mm:ss fff")}"); this.PlaylistSaveBlockInternalStart(playlistId); } private void PlaylistSaveBlockInternalStart(string playlistId) { if (this.IsEnabled()) { this.WriteEvent(17, playlistId); } } [NonEvent] public void PlaylistSaveBlockStop(string playlistId, System.Diagnostics.Stopwatch sw, NLog.Logger logger) { sw.Stop(); //logger.Warn($"Save playlist block END for PLAYLIST {playlistId}. {System.DateTime.Now.ToString("hh:mm:ss fff")} Duration: {sw.Elapsed.TotalMilliseconds} ms"); this.PlaylistSaveBlockInternalStop(playlistId); } private void PlaylistSaveBlockInternalStop(string playlistId) { if (this.IsEnabled()) { this.WriteEvent(18, playlistId); } } [NonEvent] public void PlaylistSaveBlockExceptionStop(string playlistId, System.Diagnostics.Stopwatch sw, NLog.Logger logger, System.Exception ex) { sw.Stop(); //logger.Error($"Save playlist block END for PLAYLIST {playlistId}. {System.DateTime.Now.ToString("hh:mm:ss fff")} Duration: {sw.Elapsed.TotalMilliseconds} ms. Exception: {ex.GetFullMessage()}. ExceptionType: {ex.GetType().Name}"); this.PlaylistSaveBlockExceptionInternalStop(playlistId, ex.GetFullMessage(), ex.GetType().Name); } private void PlaylistSaveBlockExceptionInternalStop(string playlistId, string exceptionMessage, string exceptionType) { if (this.IsEnabled()) { this.WriteEvent(19, playlistId, exceptionMessage, exceptionType); } } [NonEvent] public void ProcessPlaylistException(string playlistId, System.Diagnostics.Stopwatch sw, NLog.Logger logger, System.Exception ex) { sw.Stop(); //logger.Error($@"UPDATED PLAYLIST {playlistId} FAILED. PROCESS TIME: {sw.Elapsed.TotalMilliseconds} ms. Exception: {ex.GetFullMessage()}. ExceptionType: {ex.GetType().Name}"); this.ProcessPlaylistExceptionInternal(playlistId, ex.GetFullMessage(), ex.GetType().Name); } private void ProcessPlaylistExceptionInternal(string playlistId, string exceptionMessage, string exceptionType) { if (this.IsEnabled()) { this.WriteEvent(20, playlistId, exceptionMessage, exceptionType); } } [NonEvent] public void PlaylistGetBlockException(string playlistId, System.Diagnostics.Stopwatch sw, NLog.Logger logger, System.Exception ex) { sw.Stop(); //logger.Error($"Get Spotify data block END for PLAYLIST {playlistId}. {System.DateTime.Now.ToString("hh:mm:ss fff")} Duration: {sw.Elapsed.TotalMilliseconds} ms. Exception: {ex.GetFullMessage()}. ExceptionType: {ex.GetType().Name}"); this.PlaylistGetBlockExceptionInternal(playlistId, ex.GetFullMessage(), ex.GetType().Name); } private void PlaylistGetBlockExceptionInternal(string playlistId, string exceptionMessage, string exceptionType) { if (this.IsEnabled()) { this.WriteEvent(21, playlistId, exceptionMessage, exceptionType); } } [NonEvent] public void GetSpotifyPlaylistByIdStart(string playlistId, System.Diagnostics.Stopwatch sw, NLog.Logger logger) { sw.Restart(); //logger.Warn($"Get Spotify playlist by Id START for PLAYLIST {playlistId}. {System.DateTime.Now.ToString("hh:mm:ss fff")}"); this.GetSpotifyPlaylistByIdInternalStart(playlistId); } private void GetSpotifyPlaylistByIdInternalStart(string playlistId) { if (this.IsEnabled()) { this.WriteEvent(22, playlistId); } } [NonEvent] public void GetSpotifyPlaylistByIdStop(string playlistId, System.Diagnostics.Stopwatch sw, NLog.Logger logger) { sw.Stop(); //logger.Warn($"Get Spotify playlist by Id END for PLAYLIST {playlistId}. {System.DateTime.Now.ToString("hh:mm:ss fff")} Duration: {sw.Elapsed.TotalMilliseconds} ms"); this.GetSpotifyPlaylistByIdInternalStop(playlistId); } private void GetSpotifyPlaylistByIdInternalStop(string playlistId) { if (this.IsEnabled()) { this.WriteEvent(23, playlistId); } } public void DownloadImageStart(string playlistId) { this.WriteEvent(24, playlistId); } public void DownloadImageStop(string playlistId) { this.WriteEvent(25, playlistId); } } }