[ 
https://issues.apache.org/jira/browse/FLINK-32649?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

chenyuzhi updated FLINK-32649:
------------------------------
    Description: 
When runing unit test 
'org.apache.flink.metrics.prometheus.PrometheusReporterTest#metricIsRemovedWhileOtherMetricsWithSameNameExist',
 it got wrong response string as 
{code:java}
# HELP flink_logical_scope_metric metric (scope: logical_scope)
# TYPE flink_logical_scope_metric gauge
flink_logical_scope_metric{label1="some_value",label2="value1",} 0.0 {code}
 

in my opinion, the expected right response is :

 
{code:java}
# HELP flink_logical_scope_metric metric (scope: logical_scope)
# TYPE flink_logical_scope_metric gauge
flink_logical_scope_metric{label1="value1",label2="some_value",} 0.0
 {code}
 

 

The reason may be we create two metric with same name, but two different order  
label-keys in the variables of MetricGroup. And we don't sort the key&value in 
variables within methond 
'org.apache.flink.metrics.prometheus.AbstractPrometheusReporter#notifyOfAddedMetric'.

 

Maybe it won't happen in production env now, howerver it's important to ensure 
the robustness of method with unpected input param.

  was:
When runing unit test 
'org.apache.flink.metrics.prometheus.PrometheusReporterTest#metricIsRemovedWhileOtherMetricsWithSameNameExist',
 it got wrong response string as 
{code:java}
# HELP flink_logical_scope_metric metric (scope: logical_scope)
# TYPE flink_logical_scope_metric gauge
flink_logical_scope_metric{label1="some_value",label2="value1",} 0.0 {code}
 

in my opinion, the expected right response is :

 
{code:java}
# HELP flink_logical_scope_metric metric (scope: logical_scope)
# TYPE flink_logical_scope_metric gauge
flink_logical_scope_metric{label1="value1",label2="some_value",} 0.0
 {code}
 

 

The reason may be we create two metric with same name, but two different order  
label-keys in the variables of MetricGroup. And we don't sort the key&value in 
variables within methond 
'org.apache.flink.metrics.prometheus.AbstractPrometheusReporter#notifyOfAddedMetric'.

 

Maybe it won't happen in production env now, cause we alway use the same 
'MetricGroup' instance as the input param of method 'notifyOfAddedMetric'.

Howerver it's important to ensure the robustness of method with unpected input 
param.


> Mismatch label and value for prometheus reporter
> ------------------------------------------------
>
>                 Key: FLINK-32649
>                 URL: https://issues.apache.org/jira/browse/FLINK-32649
>             Project: Flink
>          Issue Type: Bug
>          Components: Runtime / Metrics
>    Affects Versions: 1.17.0
>            Reporter: chenyuzhi
>            Priority: Major
>              Labels: pull-request-available
>
> When runing unit test 
> 'org.apache.flink.metrics.prometheus.PrometheusReporterTest#metricIsRemovedWhileOtherMetricsWithSameNameExist',
>  it got wrong response string as 
> {code:java}
> # HELP flink_logical_scope_metric metric (scope: logical_scope)
> # TYPE flink_logical_scope_metric gauge
> flink_logical_scope_metric{label1="some_value",label2="value1",} 0.0 {code}
>  
> in my opinion, the expected right response is :
>  
> {code:java}
> # HELP flink_logical_scope_metric metric (scope: logical_scope)
> # TYPE flink_logical_scope_metric gauge
> flink_logical_scope_metric{label1="value1",label2="some_value",} 0.0
>  {code}
>  
>  
> The reason may be we create two metric with same name, but two different 
> order  label-keys in the variables of MetricGroup. And we don't sort the 
> key&value in variables within methond 
> 'org.apache.flink.metrics.prometheus.AbstractPrometheusReporter#notifyOfAddedMetric'.
>  
> Maybe it won't happen in production env now, howerver it's important to 
> ensure the robustness of method with unpected input param.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to