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

Yun Tang commented on FLINK-13496:
----------------------------------

[~Zentol], you're correct. I just found our customer used a wrapper class 
{{Double}} instead of primitive and he just followed the guide to configure 
that value as {{transient}}, that's why he got {{null}} when reporting metrics.

> Correct the documentation of Gauge metric initialization
> --------------------------------------------------------
>
>                 Key: FLINK-13496
>                 URL: https://issues.apache.org/jira/browse/FLINK-13496
>             Project: Flink
>          Issue Type: Bug
>          Components: Documentation
>            Reporter: Yun Tang
>            Priority: Major
>
> Current documentation of 
> [Gauge|https://ci.apache.org/projects/flink/flink-docs-stable/monitoring/metrics.html#gauge]
>  set the value to expose as {{transient}}. 
> {code:java}
> public class MyMapper extends RichMapFunction<String, String> {
>   private transient int valueToExpose = 0;
>   @Override
>   public void open(Configuration config) {
>     getRuntimeContext()
>       .getMetricGroup()
>       .gauge("MyGauge", new Gauge<Integer>() {
>         @Override
>         public Integer getValue() {
>           return valueToExpose;
>         }
>       });
>   }
>   @Override
>   public String map(String value) throws Exception {
>     valueToExpose++;
>     return value;
>   }
> }
> {code}
> However, this would let the initialization value {{valueToExpose}} within 
> {{MyGauge}} as null on task manager side. This would actually mislead users 
> who want to add customized gauge.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to