[GitHub] flink pull request #2443: [FLINK-3950] Implement MeterView

2016-10-26 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/flink/pull/2443


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] flink pull request #2443: [FLINK-3950] Implement MeterView

2016-09-07 Thread rmetzger
Github user rmetzger commented on a diff in the pull request:

https://github.com/apache/flink/pull/2443#discussion_r77829590
  
--- Diff: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractStreamOperator.java
 ---
@@ -105,7 +106,9 @@ public void setup(StreamTask containingTask, 
StreamConfig config, Output")[config.getChainIndex()].trim();

this.metrics = 
container.getEnvironment().getMetricGroup().addOperator(operatorName);
-   this.output = new CountingOutput(output, 
this.metrics.counter("numRecordsOut"));
+   Counter c = this.metrics.counter("numRecordsOut");
+   this.output = new CountingOutput(output, c);
+   this.metrics.meter("numRecordsOutRate", new MeterView(c, 60));
--- End diff --

With the two suggested changes, we can make the example something useful ;)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] flink pull request #2443: [FLINK-3950] Implement MeterView

2016-09-07 Thread zentol
Github user zentol commented on a diff in the pull request:

https://github.com/apache/flink/pull/2443#discussion_r77825932
  
--- Diff: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractStreamOperator.java
 ---
@@ -105,7 +106,9 @@ public void setup(StreamTask containingTask, 
StreamConfig config, Output")[config.getChainIndex()].trim();

this.metrics = 
container.getEnvironment().getMetricGroup().addOperator(operatorName);
-   this.output = new CountingOutput(output, 
this.metrics.counter("numRecordsOut"));
+   Counter c = this.metrics.counter("numRecordsOut");
+   this.output = new CountingOutput(output, c);
+   this.metrics.meter("numRecordsOutRate", new MeterView(c, 60));
--- End diff --

this just served as an example...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] flink pull request #2443: [FLINK-3950] Implement MeterView

2016-09-07 Thread rmetzger
Github user rmetzger commented on a diff in the pull request:

https://github.com/apache/flink/pull/2443#discussion_r77821528
  
--- Diff: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractStreamOperator.java
 ---
@@ -105,7 +106,9 @@ public void setup(StreamTask containingTask, 
StreamConfig config, Output")[config.getChainIndex()].trim();

this.metrics = 
container.getEnvironment().getMetricGroup().addOperator(operatorName);
-   this.output = new CountingOutput(output, 
this.metrics.counter("numRecordsOut"));
+   Counter c = this.metrics.counter("numRecordsOut");
+   this.output = new CountingOutput(output, c);
+   this.metrics.meter("numRecordsOutRate", new MeterView(c, 60));
--- End diff --

I think the metric needs to be documented in the list of "System metrics".


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] flink pull request #2443: [FLINK-3950] Implement MeterView

2016-09-07 Thread rmetzger
Github user rmetzger commented on a diff in the pull request:

https://github.com/apache/flink/pull/2443#discussion_r77815865
  
--- Diff: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractStreamOperator.java
 ---
@@ -105,7 +106,9 @@ public void setup(StreamTask containingTask, 
StreamConfig config, Output")[config.getChainIndex()].trim();

this.metrics = 
container.getEnvironment().getMetricGroup().addOperator(operatorName);
-   this.output = new CountingOutput(output, 
this.metrics.counter("numRecordsOut"));
+   Counter c = this.metrics.counter("numRecordsOut");
+   this.output = new CountingOutput(output, c);
+   this.metrics.meter("numRecordsOutRate", new MeterView(c, 60));
--- End diff --

I think the metric name should include the unit, in this case perMinute.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] flink pull request #2443: [FLINK-3950] Implement MeterView

2016-09-07 Thread rmetzger
Github user rmetzger commented on a diff in the pull request:

https://github.com/apache/flink/pull/2443#discussion_r77814628
  
--- Diff: 
flink-metrics/flink-metrics-core/src/main/java/org/apache/flink/metrics/MeterView.java
 ---
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+package org.apache.flink.metrics;
+
+/**
+ * A MeterView provides a rate of events per second over a given time 
period. The events are counted by a {@link Counter}.
+ * A history of measurements is maintained from which the rate of events 
is calculated on demand.
+ */
+public class MeterView implements Meter, View {
--- End diff --

I think it would be good to add some more javadocs to this class, at least 
for the `timeSpanInSeconds` argument of the ctor.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] flink pull request #2443: [FLINK-3950] Implement MeterView

2016-08-31 Thread zentol
GitHub user zentol opened a pull request:

https://github.com/apache/flink/pull/2443

[FLINK-3950] Implement MeterView

In the JIRA discussion about FLINK-3950 @StephanEwen introduced the notion 
of a `MetricView`, a `Meter`that derives it's values from another Counter or 
Gauge. The `View` would not be updated when the backing metric is modified, but 
instead by a background thread shared by all `Views`.

This PR implements a `Meter` that derives it's values from a `Counter`, 
called `MeterView`.

The `View` class is a small interface, only containing an `update()` method.

A `TimerTask` running in the `MetricRegistry` calls this `update()` method 
on all `Views`, with a hard-coded update interval of 5 seconds.

The `MeterView` class implements both `View` and `Meter`. It maintains a 
history of N measurements in a `long[N]` which is updated whenever 
`View#update()` is called. The rate is only calculated on demand.

The PR contains a small example, demonstrating how a `MeterView` would be 
created & registered in the `AbstractStreamOperator`.



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/zentol/flink metrics_view

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/flink/pull/2443.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2443


commit 9b9d85600912179e7fe7c96f6e2dac77bcf09563
Author: zentol 
Date:   2016-08-31T13:47:17Z

[FLINK-3950] Implement MeterView

commit 929a87a3dac22258517761fef84c73bfd85a7952
Author: zentol 
Date:   2016-08-31T13:47:48Z

example




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---