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

Chesnay Schepler commented on FLINK-4920:
-----------------------------------------

Currently, in order to create a Gauge that simply returns 4 in Scala you have 
to write the following:
{code}
MetricGroup heap = ...
heap.gauge[Long, Gauge[Long]]("Max", new Gauge[Long] {
      override def getValue: Long = 4
    })
{code}

This issue is about allowing something the following:

{code}
MetricGroup heap = ...
heap.gauge[Long, Gauge[Long]]("Max", new ScalaGauge[Long](() => 4))
{code}

ScalaGauge will implement the Gauge interface.

The above example should be supportable by adding a constructor like 
ScalaGauge(fun: () => T).

But there's probably a lot more wizard stuff you can do with a Scala-specific 
gauge type; someone else will have to chime in with suggestions.

> Add a Scala Function Gauge
> --------------------------
>
>                 Key: FLINK-4920
>                 URL: https://issues.apache.org/jira/browse/FLINK-4920
>             Project: Flink
>          Issue Type: Improvement
>          Components: Metrics, Scala API
>            Reporter: Stephan Ewen
>              Labels: easyfix, starter
>
> A useful metrics utility for the Scala API would be to add a Gauge that 
> obtains its value by calling a Scala Function0.
> That way, one can add Gauges in Scala programs using Scala lambda notation or 
> function references.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to