Example #1
0
        private void CheckLagBetweenCatalogAndLucene()
        {
            DateTime lastCommitToIndex   = GetLastCommitTimeStampForLucene();
            DateTime lastCommitToCatalog = V3Utility.GetValueFromCatalogIndex(CatalogRootUrl, "commitTimeStamp");
            double   actualLag           = lastCommitToCatalog.Subtract(lastCommitToIndex).TotalMinutes;
            //Allowed lag should be taken from config and it should be in seconds. But right now, the lag noticed is around 10 minutes. So setting it to 20
            //Until we fix the issue https://github.com/NuGet/NuGetGallery/issues/2479
            //double allowedLag = thresholdValues.V3SearchIndexCommitTimeStampLagInMinutes;
            double allowedLag = 20;

            Console.WriteLine("Lag between catalog and Lucene : {0}", actualLag);
            if (actualLag > allowedLag)
            {
                new SendAlertMailTask
                {
                    AlertSubject = string.Format("V3 search lagging behind catalog by {0} minutes", actualLag),
                    Details      = string.Format("The commit timestamp for V3 Search Lucene Index is {0} and the commit timestamp for Catalog is {1}", lastCommitToIndex.ToString(), lastCommitToCatalog.ToString()),
                    AlertName    = "V3 Search Luence Index Lagging behind V2 DB.",
                    Component    = "V3 SearchService",
                    Level        = "Error"
                }.ExecuteCommand();
            }
        }
 private DateTime GetLastCreatedCursorFromCatalog()
 {
     return(V3Utility.GetValueFromCatalogIndex(CatalogRootUrl, "nuget:lastCreated"));
 }
 private DateTime GetCommitTimeStampFromCatalog()
 {
     return(V3Utility.GetValueFromCatalogIndex(CatalogRootUrl, "commitTimeStamp"));
 }