[
https://issues.apache.org/jira/browse/FLINK-7692?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16275907#comment-16275907
]
ASF GitHub Bot commented on FLINK-7692:
---------------------------------------
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
----
> Support user-defined variables in Metrics
> -----------------------------------------
>
> Key: FLINK-7692
> URL: https://issues.apache.org/jira/browse/FLINK-7692
> Project: Flink
> Issue Type: Improvement
> Components: Metrics
> Affects Versions: 1.4.0
> Reporter: Chesnay Schepler
> Assignee: Wei-Che Wei
> Priority: Minor
> Fix For: 1.5.0
>
>
> Reporters that identify metrics with a set of key-value pairs are currently
> limited to the variables defined by Flink, like the taskmanager ID, with
> users not being able to supply their own.
> This is inconsistent with reporters that use metric identifiers that freely
> include user-defined groups constructted via {{MetricGroup#addGroup(String
> name)}}.
> I propose adding a new method {{MetricGroup#addGroup(String key, String
> name)}} that adds a new key-value pair to the {{variables}} map in it's
> constructor. When constructing the metric identifier the key should be
> included as well, resulting in the same result as when constructing the
> metric groups tree via {{group.addGroup(key).addGroup(value)}}.
> For this a new {{KeyedGenericMetricGroup}} should be created that resembles
> the unkeyed version, with slight modifications to the constructor and
> {{getScopeComponents}} method.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)