GitHub user tony810430 opened a pull request:
https://github.com/apache/flink/pull/5115
[FLINK-7692] [metrics] Support user-defined variables in Metrics
## What is the purpose of the change
This pull request makes user can create his own `MetricGroup` with
user-defined variables.
The way to create user-defined variables is to use a new public method
`MetricGroup#addGroup(String key, String value)`, which is almost same as
`group.addGroup(key).addGroup(value)` but the former will return a group with
one more variable: `{"<key>":"value"}`.
## Brief change log
- Added a new public method: `MetricGroup#addGroup(String key, String
value)`.
- Introduce two new class: `GenericKeyMetricGroup` and
`GenericValueMetricGroup`.
- The child group of `GenericKeyMetricGroup` will be either
`GenericMetricGroup` or `GenericValueMetricGroup`.
- The child group of `GenericMetricGroup` and `GenericValueMetricGroup`
will be either `GenericMetricGroup` or `GenericKeyMetricGroup`.
- `GenericValueMetricGroup` doesn't have logical scope and have a
user-defined variable, whose name is its parent's group name and value is its
group name.
## Verifying this change
This change added tests and can be verified as follows:
- Added test that verify the behavior of `MetricGroup#addGroup(String
key, String value)`
- Manually verfied the new method works by rewriting the committed offset
metric in kafka connector and monitoring it through prometheus reporter.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changed class annotated with
`@Public(Evolving)`: yes
- The serializers: don't know
- The runtime per-record code paths (performance sensitive): no
- Anything that affects deployment or recovery: JobManager (and its
components), Checkpointing, Yarn/Mesos, ZooKeeper: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? yes
- If yes, how is the feature documented? docs and JavaDocs
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/tony810430/flink FLINK-7692
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/flink/pull/5115.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #5115
----
commit 6bec109fc52b7f49727e9440b1ce4170f71354d3
Author: zentol <[email protected]>
Date: 2017-11-28T14:35:07Z
Basic scaffold
commit e81ca3fe67adfb7b6d515dacbcb2ed992d83cfb0
Author: Tony Wei <[email protected]>
Date: 2017-11-30T05:55:01Z
[FLINK-7692] Support user-defined variables in Metrics
----
---