[Docs] Can't add metrics to RichFilterFunction

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Docs] Can't add metrics to RichFilterFunction

Julio Biason
Hello,

I'm trying to add a metric to a filter function, but following the example in the docs is not working.

So I have this class:

```
class LogBrokenFilter extends RichFilterFunction[LineData] {
  private val logger = LoggerFactory.getLogger(this.getClass)
  @transient private var counter:Counter

  override def open(parameters:Configuration):Unit = {
    counter = getRuntimeContext
      .getMetricGroup()
      .counter("brokenLogs")
  }

  // and then I override `filter` to do filter events out and count those.
```

The problem is that, when compiling, I get the following errors:

abstract member may not have private modifier
[error]   @transient private var counter:Counter

and

no valid targets for annotation on method counter - it is discarded unused. You may specify targets with meta-annotations, e.g. @(transient @getter)
[warn]   @transient private var counter:Counter
[warn]    ^

Any ideas? Are the docs wrong?

--
Julio Biason, Sofware Engineer
AZION  |  Deliver. Accelerate. Protect.
Office: <a href="callto:+555130838101" value="+555130838101" style="color:rgb(17,85,204);font-family:arial,sans-serif;font-size:12.8px" target="_blank">+55 51 3083 8101  |  Mobile: <a href="callto:+5551996209291" style="color:rgb(17,85,204)" target="_blank">+55 51 99907 0554
Reply | Threaded
Open this post in threaded view
|

Re: [Docs] Can't add metrics to RichFilterFunction

Julio Biason
Oh, obviously, code is Scala. Also we are using Flink 1.4.0 and flink-metrics-core-1.4-SNAPSHOT.

On Thu, Dec 14, 2017 at 10:56 AM, Julio Biason <[hidden email]> wrote:
Hello,

I'm trying to add a metric to a filter function, but following the example in the docs is not working.

So I have this class:

```
class LogBrokenFilter extends RichFilterFunction[LineData] {
  private val logger = LoggerFactory.getLogger(this.getClass)
  @transient private var counter:Counter

  override def open(parameters:Configuration):Unit = {
    counter = getRuntimeContext
      .getMetricGroup()
      .counter("brokenLogs")
  }

  // and then I override `filter` to do filter events out and count those.
```

The problem is that, when compiling, I get the following errors:

abstract member may not have private modifier
[error]   @transient private var counter:Counter

and

no valid targets for annotation on method counter - it is discarded unused. You may specify targets with meta-annotations, e.g. @(transient @getter)
[warn]   @transient private var counter:Counter
[warn]    ^

Any ideas? Are the docs wrong?

--
Julio Biason, Sofware Engineer
AZION  |  Deliver. Accelerate. Protect.
Office: <a href="callto:+555130838101" value="+555130838101" style="color:rgb(17,85,204);font-family:arial,sans-serif;font-size:12.8px" target="_blank">+55 51 3083 8101  |  Mobile: <a href="callto:+5551996209291" style="color:rgb(17,85,204)" target="_blank">+55 51 99907 0554



--
Julio Biason, Sofware Engineer
AZION  |  Deliver. Accelerate. Protect.
Office: <a href="callto:+555130838101" value="+555130838101" style="color:rgb(17,85,204);font-family:arial,sans-serif;font-size:12.8px" target="_blank">+55 51 3083 8101  |  Mobile: <a href="callto:+5551996209291" style="color:rgb(17,85,204)" target="_blank">+55 51 99907 0554
Reply | Threaded
Open this post in threaded view
|

Re: [Docs] Can't add metrics to RichFilterFunction

Kien Truong
That syntax is incorrect, should be.

@transient private var counter:Counter = _


Regards,

Kien


On 12/14/2017 8:03 PM, Julio Biason wrote:
> @transient private var counter:Counter
Reply | Threaded
Open this post in threaded view
|

Re: [Docs] Can't add metrics to RichFilterFunction

Fabian Hueske-2
Thanks for reporting the issue.

I've filed FLINK-8278 [1] to fix the issue.

Best, Fabian

[1] https://issues.apache.org/jira/browse/FLINK-8278

2017-12-14 14:04 GMT+01:00 Kien Truong <[hidden email]>:
That syntax is incorrect, should be.

@transient private var counter:Counter = _


Regards,

Kien



On 12/14/2017 8:03 PM, Julio Biason wrote:
@transient private var counter:Counter