You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by pn...@apache.org on 2023/12/11 13:19:09 UTC
(flink) 01/06: [hotfix][metrics] Reduce indentation level in #addMetric
This is an automated email from the ASF dual-hosted git repository.
pnowojski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
commit 066f34fde304b90e4ee3f12627b84ec1dd636ffd
Author: Piotr Nowojski <pi...@gmail.com>
AuthorDate: Tue Sep 26 15:27:57 2023 +0200
[hotfix][metrics] Reduce indentation level in #addMetric
---
.../metrics/groups/AbstractMetricGroup.java | 58 +++++++++++-----------
1 file changed, 30 insertions(+), 28 deletions(-)
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/metrics/groups/AbstractMetricGroup.java b/flink-runtime/src/main/java/org/apache/flink/runtime/metrics/groups/AbstractMetricGroup.java
index 44eb8c2b251..59537604c77 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/metrics/groups/AbstractMetricGroup.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/metrics/groups/AbstractMetricGroup.java
@@ -390,41 +390,43 @@ public abstract class AbstractMetricGroup<A extends AbstractMetricGroup<?>> impl
}
// add the metric only if the group is still open
synchronized (this) {
- if (!closed) {
- // immediately put without a 'contains' check to optimize the common case (no
- // collision)
- // collisions are resolved later
- Metric prior = metrics.put(name, metric);
-
- // check for collisions with other metric names
- if (prior == null) {
- // no other metric with this name yet
-
- if (groups.containsKey(name)) {
- // we warn here, rather than failing, because metrics are tools that should
- // not fail the
- // program when used incorrectly
- LOG.warn(
- "Name collision: Adding a metric with the same name as a metric subgroup: '"
- + name
- + "'. Metric might not get properly reported. "
- + Arrays.toString(scopeComponents));
- }
+ if (closed) {
+ return;
+ }
- registry.register(metric, name, this);
- } else {
- // we had a collision. put back the original value
- metrics.put(name, prior);
+ // immediately put without a 'contains' check to optimize the common case (no
+ // collision)
+ // collisions are resolved later
+ Metric prior = metrics.put(name, metric);
+
+ // check for collisions with other metric names
+ if (prior == null) {
+ // no other metric with this name yet
- // we warn here, rather than failing, because metrics are tools that should not
- // fail the
+ if (groups.containsKey(name)) {
+ // we warn here, rather than failing, because metrics are tools that should
+ // not fail the
// program when used incorrectly
LOG.warn(
- "Name collision: Group already contains a Metric with the name '"
+ "Name collision: Adding a metric with the same name as a metric subgroup: '"
+ name
- + "'. Metric will not be reported."
+ + "'. Metric might not get properly reported. "
+ Arrays.toString(scopeComponents));
}
+
+ registry.register(metric, name, this);
+ } else {
+ // we had a collision. put back the original value
+ metrics.put(name, prior);
+
+ // we warn here, rather than failing, because metrics are tools that should not
+ // fail the
+ // program when used incorrectly
+ LOG.warn(
+ "Name collision: Group already contains a Metric with the name '"
+ + name
+ + "'. Metric will not be reported."
+ + Arrays.toString(scopeComponents));
}
}
}