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, 08 Jun 2018 19:51:00 GMT

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

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_r194119409
 
 

 ##########
 File path: lang/cs/Org.Apache.REEF.Common/Telemetry/MetricTracker.cs
 ##########
 @@ -0,0 +1,221 @@
+// 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;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using Newtonsoft.Json;
+using Org.Apache.REEF.Utilities.Logging;
+
+namespace Org.Apache.REEF.Common.Telemetry
+{
+    /// <summary>
+    /// MetricData class maintains the current value of a single metric and keeps count of
the number
+    /// of times this metric has been updated. If the metric is immutable, it keeps a record
of updates.
+    /// Once the data has been processed, the records and count will reset.
+    /// </summary>
+    [JsonObject]
+    public sealed class MetricTracker : IObserver<IMetric>
+    {
+        private static readonly Logger Logger = Logger.GetLogger(typeof(MetricsData));
+
+        private bool _keepUpdateHistory;
+
+        private IDisposable _unsubscriber;
+
+        [JsonProperty]
+        private IMetric _mirror;
+
+        /// <summary>
+        /// List of the history of values this metric has held. If _keepUpdateHistory is
false, only holds current value.
+        /// </summary>
+        [JsonProperty]
+        private ConcurrentQueue<MetricRecord> _records;
+        
+        /// <summary>
+        /// Number of times metric has been updated since last processed.
+        /// </summary>
+        [JsonProperty]
+        internal int ChangesSinceLastSink;
+
+        /// <summary>
+        /// Constructor for metricData
+        /// </summary>
+        /// <param name="metric"></param>
+        /// <param name="initialValue"></param>
+        internal MetricTracker(IMetric metric)
+        {
+            Subscribe(metric);
+            _mirror = metric;
+            ChangesSinceLastSink = 0;
+            _keepUpdateHistory = metric.IsImmutable;
+            _records = new ConcurrentQueue<MetricRecord>();
+            _records.Enqueue(CreateMetricRecord(metric));
+        }
+
+        [JsonConstructor]
+        internal MetricTracker(IMetric _mirRor, int changesSinceLastSink, ConcurrentQueue<MetricRecord>
_recorDs)
+        {
+            _mirror = _mirRor;
+            _records = new ConcurrentQueue<MetricRecord>(_recorDs);
+            ChangesSinceLastSink = changesSinceLastSink;
+        }
+
+        private MetricTracker(IMetric mirror, ConcurrentQueue<MetricRecord> records,
int changes, bool history)
+        {
+            _mirror = mirror;
+            _records = records;
+            ChangesSinceLastSink = changes;
+            _keepUpdateHistory = history;
+        }
+
+        /// <summary>
+        /// Flush records.
+        /// </summary>
+        internal ConcurrentQueue<MetricRecord> FlushChangesSinceLastSink()
+        {
+            ConcurrentQueue<MetricRecord> records = new ConcurrentQueue<MetricRecord>();
+            MetricRecord record;
+            while (_records.TryDequeue(out record))
+            {
+                records.Enqueue(record);
+            }
+            ChangesSinceLastSink = 0;
+            return records;
+        }
+
+        /// <summary>
+        /// When new metric data is received, update the value and records so it reflects
the new data.
+        /// </summary>
+        /// <param name="metric">Metric data received.</param>
+        internal MetricTracker UpdateMetric(MetricTracker metric)
+        {
+            _mirror = metric.GetMetric();
+            if (metric.ChangesSinceLastSink > 0)
 
 Review comment:
   This doesnt look to be thread-safe - if two threads came here and checked if metric.ChangesSinceLastSink
> 0, they would both hit the last code of incrementing ChangesSinceLastSink. So you would
miss an event if history were being tracked.

----------------------------------------------------------------
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