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

Hai Zhou UTC+8 edited comment on FLINK-7608 at 10/11/17 4:53 PM:
-----------------------------------------------------------------

Before I start, I want discuss my idea:
redesign a class that measures latency, named LatencyStatistics.
the following is the structure of this class:

1.contains a constructor
{code:java}
 LatencyStatistics(MetricGroup metricGroup, int histogramWindowSize)
{code}

2. contains three fields
{code:java}
MetricGroup metricGroup  // equal metricGroup  from the constructor
int windowSize  // equal histogramWindowSize from the constructor
latencyStats = HashMap<String, LatencyHistogram>
{code}

3. contains a method to receive latencyMarker
{code:java}
reportLatency(latencyMarker maker) { 
     String key = _maker.vertexID_ +"-"+_maker.subtaskIndex_ 
     LatencyHistogram sourceStats = latencyStats.get(key);
     if sourceStats == null then {
          sourceStats = new LatencyHistogram(this.windowSize)
          this.latencyStats.put(key, sourceStats)
          this.metricGroup.histogram(key, sourceStats)
      }
      this.sourceStats.addValue(System.currentTimeMillis() - 
marker.getMarkedTime());
}
{code}

the *LatencyHistogram* extends org.apache.flink.metrics.Histogram, and wrap a 
*DescriptiveStatistics* internally.

[~Zentol] [~rmetzger] [~aljoscha], what is your opinions here?


was (Author: yew1eb):
Before I start, I want discuss my idea:
redesign a class that measures latency, named LatencyStatistics.
the following is the structure of this class:

1.contains a constructor
{code:java}
 LatencyStatistics(MetricGroup metricGroup, int histogramWindowSize)
{code}

2. contains three fields
{code:java}
MetricGroup metricGroup  // equal metricGroup  from the constructor
int windowSize  // equal histogramWindowSize from the constructor
latencyStats = HashMap<String, LatencyHistogram>
{code}

3. contains a method to receive latencyMarker
{code:java}
reportLatency(latencyMarker maker) { 
     String key = _maker.vertexID_ +"-"+_maker.subtaskIndex_ 
     LatencyHistogram sourceStats = latencyStats.get(key);
     if sourceStats == null then
          sourceStats = new LatencyHistogram(this.windowSize)
          this.latencyStats.put(key, sourceStats)
       this.metricGroup.histogram(key, sourceStats)
this.sourceStats.addValue(System.currentTimeMillis() - marker.getMarkedTime());
}
{code}

the *LatencyHistogram* extends org.apache.flink.metrics.Histogram, and wrap a 
*DescriptiveStatistics* internally.

[~Zentol] [~rmetzger] [~aljoscha], what is your opinions here?

> LatencyGauge change to  histogram metric
> ----------------------------------------
>
>                 Key: FLINK-7608
>                 URL: https://issues.apache.org/jira/browse/FLINK-7608
>             Project: Flink
>          Issue Type: Bug
>          Components: Metrics
>            Reporter: Hai Zhou UTC+8
>            Assignee: Hai Zhou UTC+8
>            Priority: Blocker
>             Fix For: 1.4.0, 1.3.3
>
>
> I used slf4jReporter[https://issues.apache.org/jira/browse/FLINK-4831]  to 
> export metrics the log file.
> I found:
> {noformat}
> -- Gauges 
> ---------------------------------------------------------------------
> ......
> zhouhai-mbp.taskmanager.f3fd3a269c8c3da4e8319c8f6a201a57.Flink Streaming 
> Job.Map.0.latency:
>  value={LatencySourceDescriptor{vertexID=1, subtaskIndex=-1}={p99=116.0, 
> p50=59.5, min=11.0, max=116.0, p95=116.0, mean=61.833333333333336}}
> zhouhai-mbp.taskmanager.f3fd3a269c8c3da4e8319c8f6a201a57.Flink Streaming 
> Job.Sink- Unnamed.0.latency: 
> value={LatencySourceDescriptor{vertexID=1, subtaskIndex=0}={p99=195.0, 
> p50=163.5, min=115.0, max=195.0, p95=195.0, mean=161.0}}
> ......
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to