reef-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (REEF-1732) Build Metrics System
Date Fri, 15 Jun 2018 23:26:01 GMT

    [ https://issues.apache.org/jira/browse/REEF-1732?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16514499#comment-16514499
] 

ASF GitHub Bot commented on REEF-1732:
--------------------------------------

singlis commented on a change in pull request #1460: [REEF-1732] Build Metrics System
URL: https://github.com/apache/reef/pull/1460#discussion_r195879991
 
 

 ##########
 File path: lang/cs/Org.Apache.REEF.Common/Telemetry/MetricsData.cs
 ##########
 @@ -0,0 +1,168 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using Org.Apache.REEF.Tang.Annotations;
+using Org.Apache.REEF.Utilities.Logging;
+using Newtonsoft.Json;
+
+namespace Org.Apache.REEF.Common.Telemetry
+{
+    /// <summary>
+    /// This class maintains a collection of the data for all the metrics for metrics service.

+    /// When new metric data is received, the data in the collection will be updated.
+    /// After the data is processed, the changes since last process will be reset.
+    /// </summary>
+    public sealed class MetricsData : IMetrics
+    {
+        private static readonly Logger Logger = Logger.GetLogger(typeof(MetricsData));
+
+        JsonSerializerSettings settings = new JsonSerializerSettings()
+        {
+            TypeNameHandling = TypeNameHandling.All
+        };
+
+        /// <summary>
+        /// Registration of metrics
+        /// </summary>
+        private ConcurrentDictionary<string, MetricTracker> _metricsMap = new ConcurrentDictionary<string,
MetricTracker>();
+
+        [Inject]
+        internal MetricsData()
+        {
+        }
+
+        /// <summary>
+        /// Deserialization.
+        /// </summary>
+        /// <param name="serializedMetricsString"></param>
+        [JsonConstructor]
+        internal MetricsData(string serializedMetricsString)
+        {
+            var metrics = JsonConvert.DeserializeObject<IList<MetricTracker>>(serializedMetricsString,
settings);
+
+            foreach (var m in metrics)
+            {
+                _metricsMap.TryAdd(m.GetMetric().Name, m);
+            }
+        }
+
+        /// <summary>
+        /// Checks if the metric to be registered has a unique name. If the metric name has
already been 
+        /// registered, metric is not entered into the registration and method returns false.
On successful
+        /// registration, method returns true.
+        /// </summary>
+        /// <param name="metric">Metric to register.</param>
+        /// <returns>Indicates if the metric was registered.</returns>
+        public bool TryRegisterMetric(IMetric metric)
+        {
+            if (!_metricsMap.TryAdd(metric.Name, new MetricTracker(metric)))
+            {
+                Logger.Log(Level.Warning, "The metric [{0}] already exists.", metric.Name);
+                return false;
+            }
+            return true;
+        }
+
+        /// <summary>
+        /// Gets a metric given a name.
+        /// </summary>
+        /// <param name="name">Name of the metric.</param>
+        /// <param name="me">The metric object returned.</param>
+        /// <returns>Boolean indicating if a metric object was succesfully retrieved.</returns>
+        public bool TryGetValue(string name, out IMetric me)
+        {
+            if (!_metricsMap.TryGetValue(name, out MetricTracker tracker))
+            {
+                me = null;
+                return false;
+            }
+            me = tracker.GetMetric();
+            return true;
+        }
+
+        /// <summary>
+        /// Gets all the registered metrics.
+        /// </summary>
+        /// <returns>IEnumerable of MetricData.</returns>
+        public IEnumerable<MetricTracker> GetMetrics()
+        {
+            return _metricsMap.Values;
+        }
+
+        /// <summary>
+        /// Updates metrics given another <see cref="MetricsData"/> object.
+        /// For every metric in the new set, if it is registered then update the value,
+        /// if it is not then add it to the registration.
+        /// </summary>
+        /// <param name="metrics">New metric values to be updated.</param>
+        internal void Update(MetricsData metrics)
+        {
+            foreach (var metric in metrics.GetMetrics())
+            {
+                _metricsMap.AddOrUpdate(metric.GetMetric().Name, metric, (k, v) => v.UpdateMetric(metric));
+            }
+        }
+
+        /// <summary>
+        /// Flushes changes since last sink for each metric. 
+        /// Called when Driver is sinking metrics.
+        /// </summary>
+        /// <returns>Key value pairs of metric name and record that was flushed.</returns>
+        public IEnumerable<KeyValuePair<string, MetricTracker.MetricRecord>>
FlushMetricRecords()
+        {
+            // for each metric, flush the records and create key value pairs
+            return _metricsMap.SelectMany(kv => kv.Value.FlushChangesSinceLastSink().Select(r
=> new KeyValuePair<string, MetricTracker.MetricRecord>(kv.Key, r)));
+        }
+
+        /// <summary>
+        /// Flushes that trackers contained in the queue.
+        /// Called when Evaluator is sending metrics information to Driver.
+        /// </summary>
+        /// <returns>Queue of trackers containing metric records.</returns>
+        public ConcurrentQueue<MetricTracker> FlushMetricTrackers()
 
 Review comment:
   Can this be ICollection?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Build Metrics System
> --------------------
>
>                 Key: REEF-1732
>                 URL: https://issues.apache.org/jira/browse/REEF-1732
>             Project: REEF
>          Issue Type: New Feature
>          Components: IMRU, REEF
>            Reporter: Julia
>            Assignee: Julia
>            Priority: Major
>         Attachments: IMRU Metrics System.docx
>
>
> IMRU Metrics is to provide metrics data to the system so that it can be shown to the
user for monitoring or diagnosis. The goal is to build an E2E flow with simple/basic metrics
data. We can then add more data later. 
> * IMetricsProvider - there are multiple sources of metrics data:
>   1.Task metrics. This is in particular for IMRU task such as current iteration, progress.
Each task can send task state back to driver and let driver to aggregate it. Alternatively,
as UpdateTask knows current iterations and progress, to start with, we can just get task status
from update task. The task metrics can be provided by task function like IUpdateFunction and
send to driver by task host as TaskMessage with heartbeat. 
>   2. Driver metrics – For IMRU driver, it can be system state such as WaitingForEvaluator
or TasksRunning, current retry number, etc. Those driver states are maintained inside IMRU
driver. 
>  3. IMRUDriver will implement IMetricsProvider and supply metrics data. 
> * IMetricsSink – the metrics data will be output somewhere so that it can be consumed
by a monitoring tool. An interface IMetricsSink will be defined to sink metrics data. An implementation
of the interface can store the data to a remote storage. Multiple sinks can be injected. 
> * MetricsManager – It schedules a timer to get metrics from IMetricsProviders and output
the metrics data with IMetricsSinks
> Attached file shows the diagram of the design. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message