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

ASF GitHub Bot commented on FLINK-9665:
---------------------------------------

Github user jelmerk commented on a diff in the pull request:

    https://github.com/apache/flink/pull/6211#discussion_r198484545
  
    --- Diff: 
flink-metrics/flink-metrics-prometheus/src/test/java/org/apache/flink/metrics/prometheus/PrometheusReporterTest.java
 ---
    @@ -159,6 +162,27 @@ public void histogramIsReportedAsPrometheusSummary() 
throws UnirestException {
                }
        }
     
    +   @Test
    +   public void metricIsRemovedWhenCollectorIsNotUnregisteredYet() throws 
UnirestException {
    +           TaskManagerMetricGroup tmMetricGroup = new 
TaskManagerMetricGroup(registry, HOST_NAME, TASK_MANAGER);
    +
    +           String metricName = "numRecordsOut";
    +
    +           Counter metric1 = new SimpleCounter();
    +           FrontMetricGroup<TaskManagerJobMetricGroup> metricGroup1 = new 
FrontMetricGroup<>(1, new TaskManagerJobMetricGroup(registry, tmMetricGroup, 
JobID.generate(), "job_1"));
    +           reporter.notifyOfAddedMetric(metric1, metricName, metricGroup1);
    +
    +           Counter metric2 = new SimpleCounter();
    +           FrontMetricGroup<TaskManagerJobMetricGroup> metricGroup2 = new 
FrontMetricGroup<>(2, new TaskManagerJobMetricGroup(registry, tmMetricGroup, 
JobID.generate(), "job_2"));
    --- End diff --
    
    PrometheusReporter does an explicit cast to FrontMetricGroup
    
https://github.com/jelmerk/flink/blob/642b21647d78653ebe6a3e9fad8f629599e10367/flink-metrics/flink-metrics-prometheus/src/main/java/org/apache/flink/metrics/prometheus/PrometheusReporter.java#L242
    
    I'll fix the first argument


> PrometheusReporter does not properly unregister metrics
> -------------------------------------------------------
>
>                 Key: FLINK-9665
>                 URL: https://issues.apache.org/jira/browse/FLINK-9665
>             Project: Flink
>          Issue Type: Bug
>          Components: Metrics
>    Affects Versions: 1.5.0, 1.4.2, 1.6.0
>            Reporter: Chesnay Schepler
>            Assignee: Jelmer Kuperus
>            Priority: Major
>              Labels: pull-request-available
>
> The {{PrometheusReporter}} groups metrics with the same logical scope in a 
> single {{Collector}} which are periodically polled by Prometheus.
> New metrics are added to an existing collector, and a reference count is 
> maintained so we can eventually cleanup the {{Collector}} itself.
> For removed metrics we decrease the reference count, do not however remove 
> the metrics that were added. As a result the collector will continue to 
> expose metrics, as long as at least 1 metric exists with the same logical 
> scope.
> If the collector is a {{io.prometheus.client.Gauge}} we can use the 
> {{#remove()}} method. For histograms we will have to modify our 
> {{HistogramSummaryProxy}} class to allow removing individual histograms.



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

Reply via email to