Пример #1
0
        /// <summary>
        /// Creates a new instance of the StatisticsApi
        /// </summary>
        /// <param name="serverName"></param>
        /// <param name="pipelineId"></param>
        /// <param name="storage"></param>
        public StatisticsApi(string serverName, string pipelineId, IStorage storage)
        {
            _storage   = storage;
            PipelineId = pipelineId;

            _metrics = new MetricCollection();

            var keys = storage.GetKeys(new StorageKey(PipelineId, $"metric:", serverName));

            foreach (var key in keys)
            {
                var metric = storage.Get <Metric>(new StorageKey(key));
                _metrics.Add(metric);
            }

            // add logs
            _metrics.Add(new LogMetric(MetricType.WorkersLog, "Active Workers", () =>
            {
                var logs = storage.GetList <ActiveWorkersLogMessage>(new StorageKey(pipelineId, $"log:{MetricType.WorkersLog}", serverName));
                return(logs);
            }));
            _metrics.Add(new LogMetric(MetricType.EventLog, "Active Workers", () =>
            {
                var logs = storage.GetList <LogEvent>(new StorageKey(pipelineId, $"logs", serverName));
                return(logs);
            }));
        }
Пример #2
0
 public void Add(string pipelineId, MetricCollection metrics)
 {
     _metrics.Add(pipelineId, metrics);
 }