public static IEnumerable <ResourceManagerMemorySample> GetMemorySamples(string workerId, int pid, IMongoCollection <BsonDocument> collection)
        {
            var memorySamples = new List <ResourceManagerMemorySample>();

            string processName = GetProcessName(collection);

            var filter = Query.And(FilterMessagesByWorkerAndPid(workerId, pid),
                                   Query.Regex("v", new BsonRegularExpression("^Resource Manager: Memory info:")));

            var memorySampleDocuments = collection.Find(filter).ToEnumerable();

            foreach (var document in memorySampleDocuments)
            {
                try
                {
                    ResourceManagerMemorySample memorySample = new ResourceManagerMemorySample(document, processName);
                    memorySamples.Add(memorySample);
                }
                catch (Exception ex)
                {
                    Log.Error("Unable to parse memory sample from " + document, ex);
                }
            }

            return(memorySamples);
        }
Ejemplo n.º 2
0
        private void AddMemorySampleEvent(NativeJsonLogsBaseEvent baseEvent, string message, LogLine logLine, string processName)
        {
            var currentAndTotalMatch = CurrentAndTotalMemoryUtilRegex.Match(message);

            if (currentAndTotalMatch.Success)
            {
                var record = ResourceManagerMemorySample.GetEventWithNullCheck(
                    baseEvent,
                    logLine,
                    processName,
                    TryParseLongWithLogging(currentAndTotalMatch, "current_process_util", logLine),
                    TryParseLongWithLogging(currentAndTotalMatch, "tableau_total_util", logLine)
                    );

                _memorySamplesWriter.AddLine(record);
                return;
            }

            _processingNotificationsCollector.ReportError("Failed to process line as MemorySampleEvent.", logLine, nameof(ResourceManagerPlugin));
        }