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

    https://github.com/apache/flink/pull/2374#discussion_r76410073
  
    --- Diff: docs/monitoring/metrics.md ---
    @@ -155,6 +155,55 @@ public class MyMapper extends RichMapFunction<Long, 
Integer> {
     }
     {% endhighlight %}
     
    +#### Meter
    +
    +A `Meter` measures an average throughput. An occurrence of an event can be 
registered with the `markEvent()` method. Occurrence of multiple events at the 
same time can be registered with `markEvent(long n)` method.
    +You can register a meter by calling `meter(String name, Meter histogram)` 
on a `MetricGroup`.
    +
    +{% highlight java %}
    +public class MyMapper extends RichMapFunction<Long, Integer> {
    +  private Meter meter;
    +
    +  @Override
    +  public void open(Configuration config) {
    +    this.meter = getRuntimeContext()
    +      .getMetricGroup()
    +      .meter("myMeter", new MyMeter());
    +  }
    +
    +  @public Integer map(Long value) throws Exception {
    +    this.meter.markEvent();
    +  }
    +}
    +{% endhighlight %}
    +
    +Flink offers a {% gh_link 
flink-metrics/flink-metrics-dropwizard/src/main/java/org/apache/flink/dropwizard/metrics/DropwizardMeterWrapper.java
 "Wrapper" %} that allows usage of Codahale/DropWizard meters.
    +To use this wrapper add the following dependency in your `pom.xml`:
    +{% highlight xml %}
    +<dependency>
    +      <groupId>org.apache.flink</groupId>
    +      <artifactId>flink-metrics-dropwizard</artifactId>
    +      <version>{{site.version}}</version>
    +</dependency>
    +{% endhighlight %}
    +
    +You can then register a Codahale/DropWizard meter like this:
    +
    +{% highlight java %}
    +public class MyMapper extends RichMapFunction<Long, Integer> {
    +  private Meter meter;
    +
    +  @Override
    +  public void open(Configuration config) {
    +    com.codahale.metrics.Meter meter = new com.codahale.metrics.Meter();
    +
    +    this.meter = getRuntimeContext()
    +      .getMetricGroup()
    +      .histogram("myMeter", new DropWizardMeterWrapper(meter));
    --- End diff --
    
    `.histogram` -> `.meter`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to